-}
-
-
-void BScreen::reconfigure(void) {
- // don't reconfigure while saving the initial rc file, it's a waste and it
- // breaks somethings (workspace names)
- if (blackbox->state() == Openbox::State_Starting) return;
-
- load_rc();
- LoadStyle();
-
- // we need to do this explicitly, because just loading this value from the rc
- // does nothing
- changeWorkspaceCount(resource.workspaces);
-
- XGCValues gcv;
- gcv.foreground = WhitePixel(otk::OBDisplay::display,
- getScreenNumber());
- gcv.function = GXinvert;
- gcv.subwindow_mode = IncludeInferiors;
- XChangeGC(otk::OBDisplay::display, opGC,
- GCForeground | GCFunction | GCSubwindowMode, &gcv);
-
- const char *s = "0: 0000 x 0: 0000";
-
- geom_w = resource.wstyle.font->measureString(s) + resource.bevel_width * 2;
- geom_h = resource.wstyle.font->height() + resource.bevel_width * 2;
-
- otk::BTexture* texture = &(resource.wstyle.l_focus);
- geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
- if (geom_pixmap == ParentRelative) {
- texture = &(resource.wstyle.t_focus);
- geom_pixmap = texture->render(geom_w, geom_h, geom_pixmap);
- }
- if (! geom_pixmap)
- XSetWindowBackground(otk::OBDisplay::display, geom_window,
- texture->color().pixel());
- else
- XSetWindowBackgroundPixmap(otk::OBDisplay::display,
- geom_window, geom_pixmap);
-
- XSetWindowBorderWidth(otk::OBDisplay::display, geom_window,
- resource.border_width);
- XSetWindowBorder(otk::OBDisplay::display, geom_window,
- resource.border_color.pixel());
-
- typedef std::vector<int> SubList;
- SubList remember_subs;
-
- raiseWindows(0, 0);
-
- std::for_each(workspacesList.begin(), workspacesList.end(),
- std::mem_fun(&Workspace::reconfigure));
-
- BlackboxWindowList::iterator iit = iconList.begin();
- for (; iit != iconList.end(); ++iit) {
- BlackboxWindow *bw = *iit;
- if (bw->validateClient())
- bw->reconfigure();
- }
-
- otk::BImageControl::timeout(image_control);
-}
-
-
-void BScreen::LoadStyle(void) {
- Configuration style(False);
-
- const char *sfile = blackbox->getStyleFilename();
- if (sfile != NULL) {
- style.setFile(sfile);
- if (! style.load()) {
- style.setFile(DEFAULTSTYLE);
- if (! style.load())
- style.create(); // hardcoded default values will be used.
- }
- }
-
- // merge in the rc file
- style.merge(config->file(), True);
-
- string s;
-
- // load fonts/fontsets
- if (resource.wstyle.font)
- delete resource.wstyle.font;
-
- resource.wstyle.font = readDatabaseFont("window.", style);
-
- // load window config
- resource.wstyle.t_focus =
- readDatabaseTexture("window.title.focus", "white", style);
- resource.wstyle.t_unfocus =
- readDatabaseTexture("window.title.unfocus", "black", style);
- resource.wstyle.l_focus =
- readDatabaseTexture("window.label.focus", "white", style);
- resource.wstyle.l_unfocus =
- readDatabaseTexture("window.label.unfocus", "black", style);
- resource.wstyle.h_focus =
- readDatabaseTexture("window.handle.focus", "white", style);
- resource.wstyle.h_unfocus =
- readDatabaseTexture("window.handle.unfocus", "black", style);
- resource.wstyle.g_focus =
- readDatabaseTexture("window.grip.focus", "white", style);
- resource.wstyle.g_unfocus =
- readDatabaseTexture("window.grip.unfocus", "black", style);
- resource.wstyle.b_focus =
- readDatabaseTexture("window.button.focus", "white", style);
- resource.wstyle.b_unfocus =
- readDatabaseTexture("window.button.unfocus", "black", style);
- resource.wstyle.b_pressed =
- readDatabaseTexture("window.button.pressed", "black", style);
-
- //if neither of these can be found, we will use the previous resource
- resource.wstyle.b_pressed_focus =
- readDatabaseTexture("window.button.pressed.focus", "black", style, true);
- resource.wstyle.b_pressed_unfocus =
- readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
-
- if (resource.wstyle.close_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
- if (resource.wstyle.max_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
- if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
- if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
-
- resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
- resource.wstyle.icon_button.mask =
- resource.wstyle.icon_button.mask = None;
+
+ // XXX: handle any requested states such as maximized
+
+ otk::display->ungrab();
+
+ // add to the screen's list
+ clients.push_back(client);
+ // this puts into the stacking order, then raises it
+ _stacking.push_back(client);
+ raiseWindow(client);
+ // update the root properties
+ changeClientList();
+
+ openbox->bindings()->grabButtons(true, client);
+
+ // call the python NEWWINDOW binding
+ EventData data(_number, client, EventNewWindow, 0);
+ openbox->bindings()->fireEvent(&data);
+
+#ifdef DEBUG
+ printf("Managed window 0x%lx\n", window);
+#endif
+}
+
+
+void Screen::unmanageWindow(Client *client)
+{
+ Frame *frame = client->frame;
+
+ // call the python CLOSEWINDOW binding
+ EventData data(_number, client, EventCloseWindow, 0);
+ openbox->bindings()->fireEvent(&data);
+
+ openbox->bindings()->grabButtons(false, client);
+
+ // remove from the wm's map
+ openbox->removeClient(client->window());
+ openbox->removeClient(frame->window());
+ openbox->removeClient(frame->plate());
+ openbox->removeClient(frame->titlebar());
+ openbox->removeClient(frame->label());
+ openbox->removeClient(frame->button_max());
+ openbox->removeClient(frame->button_iconify());
+ openbox->removeClient(frame->button_stick());
+ openbox->removeClient(frame->button_close());
+ openbox->removeClient(frame->handle());
+ openbox->removeClient(frame->grip_left());
+ openbox->removeClient(frame->grip_right());
+ // unregister for handling events
+ openbox->clearHandler(client->window());