]> Dogcows Code - chaz/openbox/blobdiff - openbox/frame.c
playing a bit with grabs
[chaz/openbox] / openbox / frame.c
index 4d32064c3d9c0aea05bb501074a201c733821f94..c1bacb67a6254815d06763f4016beed3c24abb7c 100644 (file)
 #include "moveresize.h"
 #include "render/theme.h"
 
-#define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask | \
-                         FocusChangeMask)
+#define PLATE_EVENTMASK (SubstructureRedirectMask | FocusChangeMask)
 #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
-                         ButtonPressMask | ButtonReleaseMask | \
-                         VisibilityChangeMask)
+                         ButtonPressMask | ButtonReleaseMask)
 #define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \
-                           ButtonMotionMask | ExposureMask | \
+                           ButtonMotionMask | \
                            EnterWindowMask | LeaveWindowMask)
+/* The inner window does not need enter/leave events.
+   If it does get them, then it needs its own context for enter events
+   because sloppy focus will focus the window when you enter the inner window
+   from the frame. */
+#define INNER_EVENTMASK (ButtonPressMask)
 
 #define FRAME_HANDLE_Y(f) (f->innersize.top + f->client->area.height + \
                            f->cbwidth_y)
@@ -81,8 +84,6 @@ ObFrame *frame_new(ObClient *client)
 
     self = g_new0(ObFrame, 1);
 
-    self->obscured = TRUE;
-
     visual = check_32bit_client(client);
 
     /* create the non-visible decor windows */
@@ -103,15 +104,21 @@ ObFrame *frame_new(ObClient *client)
     self->window = createWindow(RootWindow(ob_display, ob_screen), visual,
                                 mask, &attrib);
 
+    attrib.event_mask = INNER_EVENTMASK;
+    self->inner = createWindow(self->window, visual, mask, &attrib);
+
+    mask &= ~CWEventMask;
+    self->plate = createWindow(self->inner, visual, mask, &attrib);
+
     /* create the visible decor windows */
 
+    mask = CWEventMask;
     if (visual) {
         /* client has a 32-bit visual */
         mask |= CWColormap | CWBackPixel | CWBorderPixel;
         attrib.colormap = RrColormap(ob_rr_inst);
     }
     attrib.event_mask = ELEMENT_EVENTMASK;
-    self->inner = createWindow(self->window, NULL, mask, &attrib);
     self->title = createWindow(self->window, NULL, mask, &attrib);
 
     mask |= CWCursor;
@@ -138,11 +145,6 @@ ObFrame *frame_new(ObClient *client)
     attrib.cursor = ob_cursor(OB_CURSOR_SOUTHEAST);
     self->rgrip = createWindow(self->handle, NULL, mask, &attrib); 
 
-    /* create the plate window which holds the client */
-
-    mask &= ~(CWEventMask | CWCursor);
-    self->plate = createWindow(self->inner, visual, mask, &attrib);
-
     self->focused = FALSE;
 
     /* the other stuff is shown based on decor settings */
@@ -167,6 +169,8 @@ static void set_theme_statics(ObFrame *self)
     /* set colors/appearance/sizes for stuff that doesn't change */
     XSetWindowBorder(ob_display, self->window,
                      RrColorPixel(ob_rr_theme->frame_b_color));
+    XSetWindowBorder(ob_display, self->inner,
+                     RrColorPixel(ob_rr_theme->frame_b_color));
     XSetWindowBorder(ob_display, self->title,
                      RrColorPixel(ob_rr_theme->frame_b_color));
     XSetWindowBorder(ob_display, self->handle,
@@ -344,6 +348,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
         /* set border widths */
         if (!fake) {
             XSetWindowBorderWidth(ob_display, self->window, self->bwidth);
+            XSetWindowBorderWidth(ob_display, self->inner, self->bwidth);
             XSetWindowBorderWidth(ob_display, self->title,  self->rbwidth);
             XSetWindowBorderWidth(ob_display, self->handle, self->rbwidth);
             XSetWindowBorderWidth(ob_display, self->lgrip,  self->rbwidth);
@@ -428,19 +433,19 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             /* move and resize the inner border window which contains the plate
              */
             XMoveResizeWindow(ob_display, self->inner,
-                              self->innersize.left - self->cbwidth_x,
-                              self->innersize.top - self->cbwidth_y,
+                              self->innersize.left - self->cbwidth_x -
+                              self->bwidth,
+                              self->innersize.top - self->cbwidth_y -
+                              self->bwidth,
                               self->client->area.width +
                               self->cbwidth_x * 2,
                               self->client->area.height +
                               self->cbwidth_y * 2);
 
-            /* move and resize the plate */
-            XMoveResizeWindow(ob_display, self->plate,
-                              self->cbwidth_x,
-                              self->cbwidth_y,
-                              self->client->area.width,
-                              self->client->area.height);
+            /* move the plate */
+            XMoveWindow(ob_display, self->plate,
+                        self->cbwidth_x, self->cbwidth_y);
+
             /* when the client has StaticGravity, it likes to move around. */
             XMoveWindow(ob_display, self->client->window, 0, 0);
         }
@@ -514,6 +519,13 @@ void frame_adjust_focus(ObFrame *self, gboolean hilite)
     XFlush(ob_display);
 }
 
+void frame_adjust_client_area(ObFrame *self)
+{
+    /* resize the plate */
+    XResizeWindow(ob_display, self->plate,
+                  self->client->area.width, self->client->area.height);
+}
+
 void frame_adjust_title(ObFrame *self)
 {
     framerender_frame(self);
@@ -821,7 +833,7 @@ ObFrameContext frame_context(ObClient *client, Window win)
     }
 
     self = client->frame;
-    if (win == self->plate) {
+    if (win == self->inner || win == self->plate) {
         /* conceptually, this is the desktop, as far as users are
            concerned */
         if (client->type == OB_CLIENT_TYPE_DESKTOP)
@@ -830,7 +842,6 @@ ObFrameContext frame_context(ObClient *client, Window win)
     }
 
     if (win == self->window)    return OB_FRAME_CONTEXT_FRAME;
-    if (win == self->inner)     return OB_FRAME_CONTEXT_FRAME;
     if (win == self->title)     return OB_FRAME_CONTEXT_TITLEBAR;
     if (win == self->label)     return OB_FRAME_CONTEXT_TITLEBAR;
     if (win == self->handle)    return OB_FRAME_CONTEXT_HANDLE;
This page took 0.024501 seconds and 4 git commands to generate.