| 1036 | } |
| 1037 | |
| 1038 | void Manager::_closeWindow(Window* window, bool redraw_background) |
| 1039 | { |
| 1040 | if (!hasChild(window)) |
| 1041 | return; |
| 1042 | |
| 1043 | gfx::Region reg1; |
| 1044 | if (redraw_background) |
| 1045 | window->getRegion(reg1); |
| 1046 | |
| 1047 | // Close all windows to this desktop |
| 1048 | if (window->isDesktop()) { |
| 1049 | while (!children().empty()) { |
| 1050 | Window* child = static_cast<Window*>(children().front()); |
| 1051 | if (child == window) |
| 1052 | break; |
| 1053 | else { |
| 1054 | gfx::Region reg2; |
| 1055 | window->getRegion(reg2); |
| 1056 | reg1.createUnion(reg1, reg2); |
| 1057 | |
| 1058 | _closeWindow(child, false); |
| 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | // Free all widgets of special states. |
| 1064 | if (capture_widget && capture_widget->window() == window) |
| 1065 | freeCapture(); |
| 1066 | |
| 1067 | if (mouse_widget && mouse_widget->window() == window) |
| 1068 | freeMouse(); |
| 1069 | |
| 1070 | if (focus_widget && focus_widget->window() == window) |
| 1071 | freeFocus(); |
| 1072 | |
| 1073 | // Hide window. |
| 1074 | window->setVisible(false); |
| 1075 | |
| 1076 | // Close message. |
| 1077 | Message* msg = new Message(kCloseMessage); |
| 1078 | msg->addRecipient(window); |
| 1079 | enqueueMessage(msg); |
| 1080 | |
| 1081 | // Update manager list stuff. |
| 1082 | removeChild(window); |
| 1083 | |
| 1084 | // Redraw background. |
| 1085 | invalidateRegion(reg1); |
| 1086 | |
| 1087 | // Maybe the window is in the "new_windows" list. |
| 1088 | WidgetsList::iterator it = |
| 1089 | std::find(new_windows.begin(), new_windows.end(), window); |
| 1090 | if (it != new_windows.end()) |
| 1091 | new_windows.erase(it); |
| 1092 | |
| 1093 | // Update mouse widget (as it can be a widget below the |
| 1094 | // recently closed window). |
| 1095 | Widget* widget = pick(ui::get_mouse_position()); |
no test coverage detected