X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FWindow.cc;h=27c6f9454315dd309117fee1678f01fc563faddc;hb=0f710360990e6d079116d951295c21664e2e0fce;hp=fae990b63cb0e92435ac7cfd701788bce0526af9;hpb=2d5e1c55f132a0a834eb28146fe60c8e2ca8e665;p=chaz%2Fopenbox diff --git a/src/Window.cc b/src/Window.cc index fae990b6..27c6f945 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -126,8 +126,8 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { blackbox_attrib.workspace = window_number = BSENTINEL; - blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack - = blackbox_attrib.decoration = 0l; + blackbox_attrib.flags = blackbox_attrib.attrib = blackbox_attrib.stack = 0l; + blackbox_attrib.decoration = DecorNormal; blackbox_attrib.premax_x = blackbox_attrib.premax_y = 0; blackbox_attrib.premax_w = blackbox_attrib.premax_h = 0; @@ -145,9 +145,9 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { frame.ulabel = frame.flabel = frame.ubutton = frame.fbutton = None; frame.pbutton = frame.ugrip = frame.fgrip = None; - decorations = Decor_Titlebar | Decor_Border | Decor_Handle | - Decor_Iconify | Decor_Maximize; functions = Func_Resize | Func_Move | Func_Iconify | Func_Maximize; + mwm_decorations = Decor_Titlebar | Decor_Handle | Decor_Border | + Decor_Iconify | Decor_Maximize | Decor_Close; client.normal_hint_flags = 0; client.window_group = None; @@ -173,10 +173,8 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { // get size, aspect, minimum/maximum size and other hints set by the // client - if (! getBlackboxHints()) { - getMWMHints(); + if (! getBlackboxHints()) getNetWMHints(); - } getWMProtocols(); getWMHints(); @@ -194,46 +192,50 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) { // determine the window's type, so we can decide its decorations and // functionality, or if we should not manage it at all - getWindowType(); - - // adjust the window decorations/behavior based on the window type - - switch (window_type) { - case Type_Desktop: - case Type_Dock: - case Type_Menu: - case Type_Toolbar: - case Type_Utility: - case Type_Splash: - // none of these windows are decorated or manipulated by the window manager - decorations = 0; - functions = 0; - blackbox_attrib.workspace = 0; // we do need to belong to a workspace - flags.stuck = True; // we show up on all workspaces - break; + if (getWindowType()) { + // adjust the window decorations/behavior based on the window type + switch (window_type) { + case Type_Desktop: + case Type_Dock: + case Type_Menu: + blackbox_attrib.workspace = 0; // we do need to belong to a workspace + flags.stuck = True; // we show up on all workspaces + case Type_Splash: + // none of these windows are manipulated by the window manager + functions = 0; + break; - case Type_Dialog: - // dialogs cannot be maximized, and don't display a handle - decorations &= ~(Decor_Maximize | Decor_Handle); - functions &= ~Func_Maximize; - break; + case Type_Toolbar: + case Type_Utility: + // these windows get less functionality + functions &= ~(Func_Maximize | Func_Resize | Func_Iconify); + break; - case Type_Normal: - // normal windows retain all of the possible decorations and functionality - break; + case Type_Dialog: + // dialogs cannot be maximized + functions &= ~Func_Maximize; + break; + + case Type_Normal: + // normal windows retain all of the possible decorations and functionality + break; + } + } else { + getMWMHints(); } - setAllowedActions(); - // further adjeust the window's decorations/behavior based on window sizes if ((client.normal_hint_flags & PMinSize) && (client.normal_hint_flags & PMaxSize) && client.max_width <= client.min_width && client.max_height <= client.min_height) { - decorations &= ~(Decor_Maximize | Decor_Handle); functions &= ~(Func_Resize | Func_Maximize); } + setAllowedActions(); + + setupDecor(); + if (decorations & Decor_Titlebar) createTitlebar(); @@ -349,6 +351,9 @@ BlackboxWindow::~BlackboxWindow(void) { if (! timer) // window not managed... return; + if (flags.moving) + endMove(); + screen->removeStrut(&client.strut); screen->updateAvailableArea(); @@ -400,6 +405,67 @@ BlackboxWindow::~BlackboxWindow(void) { } +void BlackboxWindow::enableDecor(bool enable) { + blackbox_attrib.flags |= AttribDecoration; + blackbox_attrib.decoration = enable ? DecorNormal : DecorNone; + setupDecor(); + + // we can not be shaded if we lack a titlebar + if (! (decorations & Decor_Titlebar) && flags.shaded) + shade(); + + if (flags.visible && frame.window) { + XMapSubwindows(blackbox->getXDisplay(), frame.window); + XMapWindow(blackbox->getXDisplay(), frame.window); + } + + reconfigure(); + setState(current_state); +} + + +void BlackboxWindow::setupDecor() { + if (blackbox_attrib.decoration != DecorNone) { + // start with everything on + decorations = + (mwm_decorations & Decor_Titlebar ? Decor_Titlebar : 0) | + (mwm_decorations & Decor_Border ? Decor_Border : 0) | + (mwm_decorations & Decor_Handle ? Decor_Handle : 0) | + (mwm_decorations & Decor_Iconify ? Decor_Iconify : 0) | + (mwm_decorations & Decor_Maximize ? Decor_Maximize : 0) | + (mwm_decorations & Decor_Close ? Decor_Close : 0); + + if (! (functions & Func_Close)) decorations &= ~Decor_Close; + if (! (functions & Func_Maximize)) decorations &= ~Decor_Maximize; + if (! (functions & Func_Iconify)) decorations &= ~Decor_Iconify; + if (! (functions & Func_Resize)) decorations &= ~Decor_Handle; + + switch (window_type) { + case Type_Desktop: + case Type_Dock: + case Type_Menu: + case Type_Splash: + // none of these windows are decorated by the window manager at all + decorations = 0; + break; + + case Type_Toolbar: + case Type_Utility: + decorations &= ~(Decor_Border); + break; + + case Type_Dialog: + decorations &= ~Decor_Handle; + break; + + case Type_Normal: + break; + } + } else { + decorations = 0; + } +} + /* * Creates a new top level window, with a given location, size, and border * width. @@ -532,11 +598,6 @@ void BlackboxWindow::decorate(void) { if (decorations & Decor_Border) { frame.fborder_pixel = screen->getWindowStyle()->f_focus.pixel(); frame.uborder_pixel = screen->getWindowStyle()->f_unfocus.pixel(); - blackbox_attrib.flags |= AttribDecoration; - blackbox_attrib.decoration = DecorNormal; - } else { - blackbox_attrib.flags |= AttribDecoration; - blackbox_attrib.decoration = DecorNone; } if (decorations & Decor_Handle) { @@ -947,7 +1008,7 @@ void BlackboxWindow::updateStrut(void) { } -void BlackboxWindow::getWindowType(void) { +bool BlackboxWindow::getWindowType(void) { unsigned long val; if (xatom->getValue(client.window, XAtom::net_wm_window_type, XAtom::atom, val)) { @@ -967,7 +1028,8 @@ void BlackboxWindow::getWindowType(void) { window_type = Type_Dialog; else //if (val[0] == xatom->getAtom(XAtom::net_wm_window_type_normal)) window_type = Type_Normal; - return; + + return True; } /* @@ -978,6 +1040,8 @@ void BlackboxWindow::getWindowType(void) { window_type = Type_Dialog; window_type = Type_Normal; + + return False; } @@ -1249,21 +1313,21 @@ void BlackboxWindow::getMWMHints(void) { if (mwm_hint->flags & MwmHintsDecorations) { if (mwm_hint->decorations & MwmDecorAll) { - decorations = Decor_Titlebar | Decor_Handle | Decor_Border | - Decor_Iconify | Decor_Maximize | Decor_Close; + mwm_decorations = Decor_Titlebar | Decor_Handle | Decor_Border | + Decor_Iconify | Decor_Maximize | Decor_Close; } else { - decorations = 0; + mwm_decorations = 0; if (mwm_hint->decorations & MwmDecorBorder) - decorations |= Decor_Border; + mwm_decorations |= Decor_Border; if (mwm_hint->decorations & MwmDecorHandle) - decorations |= Decor_Handle; + mwm_decorations |= Decor_Handle; if (mwm_hint->decorations & MwmDecorTitle) - decorations |= Decor_Titlebar; + mwm_decorations |= Decor_Titlebar; if (mwm_hint->decorations & MwmDecorIconify) - decorations |= Decor_Iconify; + mwm_decorations |= Decor_Iconify; if (mwm_hint->decorations & MwmDecorMaximize) - decorations |= Decor_Maximize; + mwm_decorations |= Decor_Maximize; } } @@ -1336,31 +1400,16 @@ bool BlackboxWindow::getBlackboxHints(void) { if (blackbox_hint->flags & AttribDecoration) { switch (blackbox_hint->decoration) { case DecorNone: - decorations = 0; + blackbox_attrib.decoration = DecorNone; break; case DecorTiny: - decorations |= Decor_Titlebar | Decor_Iconify; - decorations &= ~(Decor_Border | Decor_Handle | Decor_Maximize); - functions &= ~(Func_Resize | Func_Maximize); - - break; - case DecorTool: - decorations |= Decor_Titlebar; - decorations &= ~(Decor_Iconify | Decor_Border | Decor_Handle); - functions &= ~(Func_Resize | Func_Maximize | Func_Iconify); - - break; - case DecorNormal: default: - decorations |= Decor_Titlebar | Decor_Border | Decor_Handle | - Decor_Iconify | Decor_Maximize; + // blackbox_attrib.decoration defaults to DecorNormal break; } - - reconfigure(); } delete [] blackbox_hint; @@ -2269,51 +2318,19 @@ void BlackboxWindow::restoreAttributes(void) { if (net->flags & AttribDecoration) { switch (net->decoration) { case DecorNone: - decorations = 0; - + enableDecor(False); break; + /* since tools only let you toggle this anyways, we'll just make that all + it supports for now. + */ default: case DecorNormal: - decorations |= Decor_Titlebar | Decor_Handle | Decor_Border | - Decor_Iconify | Decor_Maximize; - - break; - case DecorTiny: - decorations |= Decor_Titlebar | Decor_Iconify; - decorations &= ~(Decor_Border | Decor_Handle | Decor_Maximize); - - break; - case DecorTool: - decorations |= Decor_Titlebar; - decorations &= ~(Decor_Iconify | Decor_Border | Decor_Handle); - + enableDecor(True); break; } - - // sanity check the new decor - if (! (functions & Func_Resize) || isTransient()) - decorations &= ~(Decor_Maximize | Decor_Handle); - if (! (functions & Func_Maximize)) - decorations &= ~Decor_Maximize; - - if (decorations & Decor_Titlebar) { - if (functions & Func_Close) // close button is controlled by function - decorations |= Decor_Close; // not decor type - } else { - if (flags.shaded) // we can not be shaded if we lack a titlebar - shade(); - } - - if (flags.visible && frame.window) { - XMapSubwindows(blackbox->getXDisplay(), frame.window); - XMapWindow(blackbox->getXDisplay(), frame.window); - } - - reconfigure(); - setState(current_state); } // with the state set it will then be the map event's job to read the @@ -2698,9 +2715,9 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { // adjust the window decorations based on transience if (isTransient()) { - decorations &= ~(Decor_Maximize | Decor_Handle); functions &= ~Func_Maximize; setAllowedActions(); + setupDecor(); } reconfigure(); @@ -2736,17 +2753,15 @@ void BlackboxWindow::propertyNotifyEvent(const XPropertyEvent *pe) { ungrabButtons(); if (client.max_width <= client.min_width && client.max_height <= client.min_height) { - decorations &= ~(Decor_Maximize | Decor_Handle); functions &= ~(Func_Resize | Func_Maximize); } else { - if (! isTransient()) { - decorations |= Decor_Maximize | Decor_Handle; + if (! isTransient()) functions |= Func_Maximize; - } functions |= Func_Resize; } grabButtons(); setAllowedActions(); + setupDecor(); } Rect old_rect = frame.rect; @@ -3094,27 +3109,26 @@ bool BlackboxWindow::doWorkspaceWarping(int x_root, int y_root, setInputFocus(); /* - If the XWarpPointer is done after the configure, we can end up - grabbing another window, so made sure you do it first. - */ + We grab the X server here because we are moving the window and then the + mouse cursor. When one moves, it could end up putting the mouse cursor + over another window for a moment. This can cause the warp to iniate a + move on another window. + */ + XGrabServer(blackbox->getXDisplay()); int dest_x; if (x_root <= 0) { dest_x = screen->getRect().right() - 1; - XWarpPointer(blackbox->getXDisplay(), None, - screen->getRootWindow(), 0, 0, 0, 0, - dest_x, y_root); - configure(dx + (screen->getRect().width() - 1), dy, frame.rect.width(), frame.rect.height()); } else { dest_x = 0; - XWarpPointer(blackbox->getXDisplay(), None, - screen->getRootWindow(), 0, 0, 0, 0, - dest_x, y_root); - configure(dx - (screen->getRect().width() - 1), dy, frame.rect.width(), frame.rect.height()); } + XWarpPointer(blackbox->getXDisplay(), None, + screen->getRootWindow(), 0, 0, 0, 0, + dest_x, y_root); + XUngrabServer(blackbox->getXDisplay()); beginMove(dest_x, y_root); return true; @@ -3783,58 +3797,16 @@ void BlackboxWindow::changeBlackboxHints(const BlackboxHints *net) { if (net->flags & AttribDecoration) { switch (net->decoration) { case DecorNone: - decorations = 0; - + enableDecor(False); break; default: case DecorNormal: - decorations |= Decor_Titlebar | Decor_Border | Decor_Iconify; - - decorations = ((functions & Func_Resize) && !isTransient() ? - decorations | Decor_Handle : - decorations &= ~Decor_Handle); - decorations = (functions & Func_Maximize ? - decorations | Decor_Maximize : - decorations &= ~Decor_Maximize); - - break; - case DecorTiny: - decorations |= Decor_Titlebar | Decor_Iconify; - decorations &= ~(Decor_Border | Decor_Handle); - - decorations = (functions & Func_Maximize ? - decorations | Decor_Maximize : - decorations &= ~Decor_Maximize); - - break; - case DecorTool: - decorations |= Decor_Titlebar; - decorations &= ~(Decor_Iconify | Decor_Border); - - decorations = ((functions & Func_Resize) && !isTransient() ? - decorations | Decor_Handle : - decorations &= ~Decor_Handle); - decorations = (functions & Func_Maximize ? - decorations | Decor_Maximize : - decorations &= ~Decor_Maximize); - + enableDecor(True); break; } - - // we can not be shaded if we lack a titlebar - if (flags.shaded && ! (decorations & Decor_Titlebar)) - shade(); - - if (flags.visible && frame.window) { - XMapSubwindows(blackbox->getXDisplay(), frame.window); - XMapWindow(blackbox->getXDisplay(), frame.window); - } - - reconfigure(); - setState(current_state); } }