- if (! config->getValue(screenstr + "placementIgnoreShaded",
- resource.ignore_shaded))
- resource.ignore_shaded = true;
-
- if (! config->getValue(screenstr + "placementIgnoreMaximized",
- resource.ignore_maximized))
- resource.ignore_maximized = true;
-
- if (! config->getValue(screenstr + "disableBindingsWithScrollLock",
- resource.allow_scroll_lock))
- resource.allow_scroll_lock = false;
-
- if (! config->getValue(screenstr + "workspaceWarping",
- resource.workspace_warping))
- resource.workspace_warping = false;
-
- resource.root_scroll = NormalScroll;
- if (config->getValue(screenstr + "rootScrollDirection", s)) {
- if (s == "None")
- resource.root_scroll = NoScroll;
- else if (s == "Reverse")
- resource.root_scroll = ReverseScroll;
- }
-}
-
-
-void BScreen::changeWorkspaceCount(unsigned int new_count) {
- assert(new_count > 0);
-
- if (new_count < workspacesList.size()) {
- // shrink
- for (unsigned int i = workspacesList.size(); i > new_count; --i)
- removeLastWorkspace();
- // removeLast already sets the current workspace to the
- // last available one.
- } else if (new_count > workspacesList.size()) {
- // grow
- for(unsigned int i = workspacesList.size(); i < new_count; ++i)
- addWorkspace();
- }
-}
-
-
-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->isStartup()) 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(blackbox->getXDisplay(),
- getScreenNumber());
- gcv.function = GXinvert;
- gcv.subwindow_mode = IncludeInferiors;
- XChangeGC(blackbox->getXDisplay(), 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;
-
- 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(blackbox->getXDisplay(), geom_window,
- texture->color().pixel());
- else
- XSetWindowBackgroundPixmap(blackbox->getXDisplay(),
- geom_window, geom_pixmap);
-
- XSetWindowBorderWidth(blackbox->getXDisplay(), geom_window,
- resource.border_width);
- XSetWindowBorder(blackbox->getXDisplay(), 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();
- }
-
- image_control->timeout();
-}
-
-
-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(blackbox->getXDisplay(), resource.wstyle.close_button.mask);
- if (resource.wstyle.max_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.max_button.mask);
- if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), resource.wstyle.icon_button.mask);
- if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(blackbox->getXDisplay(), 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;
+ // specify that if we exit, the window should not be destroyed and should be
+ // reparented back to root automatically
+ XChangeSaveSet(**otk::display, window, SetModeInsert);
+
+ // create the decoration frame for the client window
+ client->frame = new Frame(client, &_style);
+ // register the plate for events (map req's)
+ // this involves removing itself from the handler list first, since it is
+ // auto added to the list, being a widget. we won't get any events on the
+ // plate except for events for the client (SubstructureRedirectMask)
+ openbox->clearHandler(client->frame->plate());
+ openbox->registerHandler(client->frame->plate(), client);
+
+ // add to the wm's map
+ openbox->addClient(client->frame->window(), client);
+ openbox->addClient(client->frame->plate(), client);
+ openbox->addClient(client->frame->titlebar(), client);
+ openbox->addClient(client->frame->label(), client);
+ openbox->addClient(client->frame->button_max(), client);
+ openbox->addClient(client->frame->button_iconify(), client);
+ openbox->addClient(client->frame->button_alldesk(), client);
+ openbox->addClient(client->frame->button_close(), client);
+ openbox->addClient(client->frame->handle(), client);
+ openbox->addClient(client->frame->grip_left(), client);
+ openbox->addClient(client->frame->grip_right(), client);
+
+ // reparent the client to the frame
+ client->frame->grabClient();
+
+ if (!(openbox->state() == Openbox::State_Starting ||
+ client->positionRequested())) {
+ // position the window intelligenty .. hopefully :)
+ // call the python PLACEWINDOW binding
+ EventData data(_number, client, EventPlaceWindow, 0);
+ openbox->bindings()->fireEvent(&data);
+ }
+
+ // if on the current desktop.. (or all desktops)
+ if (client->desktop() == _desktop ||
+ client->desktop() == (signed)0xffffffff) {
+ client->frame->show();
+ }
+
+ client->applyStartupState();
+
+ 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_alldesk());
+ 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());