]> Dogcows Code - chaz/openbox/blobdiff - src/Window.cc
xinerama support for maximizing windows
[chaz/openbox] / src / Window.cc
index 90224fe5bb73f39dcfe945a94bf5d8bb0060a7b8..85144ffdae54da8bb00c00e1acd12bf4c82c2082 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
 
 #include "i18n.hh"
 #include "blackbox.hh"
+#include "Clientmenu.hh"
 #include "Font.hh"
 #include "GCCache.hh"
 #include "Iconmenu.hh"
@@ -175,12 +176,6 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
     return;
   }
 
-  if (isKDESystrayWindow()) {
-    screen->addSystrayWindow(client.window);
-    delete this;
-    return;
-  }
-
   frame.window = createToplevelWindow();
   frame.plate = createChildWindow(frame.window);
   associateClientWindow();
@@ -199,32 +194,16 @@ BlackboxWindow::BlackboxWindow(Blackbox *b, Window w, BScreen *s) {
   // adjust the window decorations/behavior based on the window type
   switch (window_type) {
   case Type_Desktop:
-    // desktop windows are not managed by us, we just make sure they stay on the
-    // bottom.
-    return;
-
   case Type_Dock:
   case Type_Menu:
-    // docks (such as kicker) and menus (as used by kde for the 'desktop menu'
-    // which mimics apple, cannot be moved, and appear on all workspaces
-    // also, these have no decorations
-    functions &= ~(Func_Move);
-    decorations &= ~Decor_Titlebar;
-    flags.stuck = True;
   case Type_Toolbar:
   case Type_Utility:
-    // these windows have minimal decorations, only a titlebar, and cannot
-    // be resized or iconified
-    decorations &= ~(Decor_Maximize | Decor_Handle | Decor_Border |
-                     Decor_Iconify);
-    functions &= ~(Func_Resize | Func_Maximize | Func_Iconify);
-    break;
-
   case Type_Splash:
-    // splash screens have no functionality or decorations, they are left up
-    // to the application which created them
+    // 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;
 
   case Type_Dialog:
@@ -840,24 +819,27 @@ void BlackboxWindow::reconfigure(void) {
 
 
 void BlackboxWindow::grabButtons(void) {
-  if ((! screen->isSloppyFocus()) || screen->doClickRaise())
+  if (! screen->isSloppyFocus() || screen->doClickRaise())
     // grab button 1 for changing focus/raising
     blackbox->grabButton(Button1, 0, frame.plate, True, ButtonPressMask,
-                         GrabModeSync, GrabModeSync, frame.plate, None);
-
+                         GrabModeSync, GrabModeSync, frame.plate, None,
+                         screen->allowScrollLock());
+  
   if (functions & Func_Move)
     blackbox->grabButton(Button1, Mod1Mask, frame.window, True,
                          ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
-                         GrabModeAsync, frame.window,
-                         blackbox->getMoveCursor());
+                         GrabModeAsync, frame.window, None,
+                         screen->allowScrollLock());
   if (functions & Func_Resize)
     blackbox->grabButton(Button3, Mod1Mask, frame.window, True,
                          ButtonReleaseMask | ButtonMotionMask, GrabModeAsync,
-                         GrabModeAsync, frame.window, None);
+                         GrabModeAsync, frame.window, None,
+                         screen->allowScrollLock());
   // alt+middle lowers the window
   blackbox->grabButton(Button2, Mod1Mask, frame.window, True,
                        ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
-                       frame.window, None);
+                       frame.window, None,
+                       screen->allowScrollLock());
 }
 
 
@@ -1441,15 +1423,6 @@ void BlackboxWindow::getTransientInfo(void) {
 }
 
 
-bool BlackboxWindow::isKDESystrayWindow(void) {
-  Window systray;
-  if (xatom->getValue(client.window, XAtom::kde_net_wm_system_tray_window_for,
-                      XAtom::window, systray) && systray)
-    return True;
-  return False;
-}
-
-
 BlackboxWindow *BlackboxWindow::getTransientFor(void) const {
   if (client.transient_for &&
       client.transient_for != (BlackboxWindow*) ~0ul)
@@ -1819,8 +1792,21 @@ void BlackboxWindow::maximize(unsigned int button) {
   blackbox_attrib.premax_h =
     client.rect.height() + frame.margin.top + frame.margin.bottom;
 
-  const Rect &screen_area = screen->availableArea();
-  frame.changing = screen_area;
+#ifdef    XINERAMA
+  if (screen->isXineramaActive() && blackbox->doXineramaMaximizing()) {
+    // find the area to use
+    RectList availableAreas = screen->allAvailableAreas();
+    RectList::iterator it, end = availableAreas.end();
+
+    for (it = availableAreas.begin(); it != end; ++it)
+      if (it->intersects(frame.rect)) break;
+    if (it == end) // the window isn't inside an area
+      it = availableAreas.begin(); // so just default to the first one
+
+    frame.changing = *it;
+  } else
+#endif
+  frame.changing = screen->availableArea();
 
   switch(button) {
   case 1:
@@ -1942,11 +1928,10 @@ void BlackboxWindow::stick(void) {
 
     if (! flags.iconic)
       screen->reassociateWindow(this, BSENTINEL, True);
-    else
-      // temporary fix since sticky windows suck. set the hint to what we
-      // actually hold in our data.
-      xatom->setValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal,
-                      blackbox_attrib.workspace);
+    // temporary fix since sticky windows suck. set the hint to what we
+    // actually hold in our data.
+    xatom->setValue(client.window, XAtom::net_wm_desktop, XAtom::cardinal,
+                    blackbox_attrib.workspace);
 
     setState(current_state);
   } else {
@@ -2070,6 +2055,9 @@ void BlackboxWindow::setFocusFlag(bool focus) {
 
   if (isFocused())
     blackbox->setFocusedWindow(this);
+  
+  Clientmenu *menu = screen->getWorkspace(blackbox_attrib.workspace)->getMenu();
+  menu->setItemSelected(window_number, isFocused());
 }
 
 
@@ -2538,16 +2526,23 @@ void BlackboxWindow::mapRequestEvent(const XMapRequestEvent *re) {
   default:
     show();
     screen->getWorkspace(blackbox_attrib.workspace)->raiseWindow(this);
-    if (! blackbox->isStartup() && (isTransient() || screen->doFocusNew())) {
-      XSync(blackbox->getXDisplay(), False); // make sure the frame is mapped..
-      setInputFocus();
+    if (isNormal()) {
+      if (! blackbox->isStartup()) {
+        XSync(blackbox->getXDisplay(), False); // make sure the frame is mapped
+        if (screen->doFocusNew()|| (isTransient() && getTransientFor() &&
+                                    getTransientFor()->isFocused())) {
+          setInputFocus();
+        }
+        if (screen->getPlacementPolicy() == BScreen::ClickMousePlacement) {
+          int x, y, rx, ry;
+          Window c, r;
+          unsigned int m;
+          XQueryPointer(blackbox->getXDisplay(), screen->getRootWindow(),
+                        &r, &c, &rx, &ry, &x, &y, &m);
+          beginMove(rx, ry);
+        }
+      }
     }
-    int x, y, rx, ry;
-    Window c, r;
-    unsigned int m;
-    XQueryPointer(screen->getBlackbox()->getXDisplay(), screen->getRootWindow(),
-                  &r, &c, &rx, &ry, &x, &y, &m);
-    beginMove(rx, ry);
     break;
   }
 }
@@ -2742,7 +2737,7 @@ void BlackboxWindow::configureRequestEvent(const XConfigureRequestEvent *cr) {
     configure(req.x(), req.y(), req.width(), req.height());
   }
 
-  if (cr->value_mask & CWStackMode) {
+  if (cr->value_mask & CWStackMode && !isDesktop()) {
     switch (cr->detail) {
     case Below:
     case BottomIf:
This page took 0.024798 seconds and 4 git commands to generate.