]> Dogcows Code - chaz/openbox/blobdiff - openbox/frame.c
get rid of the "inner" window
[chaz/openbox] / openbox / frame.c
index b6b6ac9322a9e4d4a1b057136448c65e04238e3f..51de9321c550f98f234c4747424e1385f76df5a3 100644 (file)
 #define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \
                            ButtonMotionMask | PointerMotionMask | \
                            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_ANIMATE_ICONIFY_TIME 150000 /* .15 seconds */
 #define FRAME_ANIMATE_ICONIFY_STEP_TIME (G_USEC_PER_SEC / 60) /* 60 Hz */
@@ -116,11 +111,8 @@ 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);
+    self->plate = createWindow(self->window, visual, mask, &attrib);
 
     /* create the visible decor windows */
 
@@ -148,6 +140,11 @@ ObFrame *frame_new(ObClient *client)
     self->left = createWindow(self->window, NULL, mask, &attrib);
     self->right = createWindow(self->window, NULL, mask, &attrib);
 
+    self->innerleft = createWindow(self->window, NULL, mask, &attrib);
+    self->innertop = createWindow(self->window, NULL, mask, &attrib);
+    self->innerright = createWindow(self->window, NULL, mask, &attrib);
+    self->innerbottom = createWindow(self->window, NULL, mask, &attrib);
+
     self->label = createWindow(self->title, NULL, mask, &attrib);
     self->max = createWindow(self->title, NULL, mask, &attrib);
     self->close = createWindow(self->title, NULL, mask, &attrib);
@@ -176,7 +173,6 @@ ObFrame *frame_new(ObClient *client)
 
     /* the other stuff is shown based on decor settings */
     XMapWindow(ob_display, self->plate);
-    XMapWindow(ob_display, self->inner);
     XMapWindow(ob_display, self->label);
 
     self->max_press = self->close_press = self->desk_press = 
@@ -375,6 +371,42 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
         /* position/size and map/unmap all the windows */
 
         if (!fake) {
+            if (self->cbwidth_x) {
+                XMoveResizeWindow(ob_display, self->innerleft,
+                                  self->size.left - self->cbwidth_x,
+                                  self->size.top,
+                                  self->cbwidth_x, self->client->area.height);
+                XMoveResizeWindow(ob_display, self->innerright,
+                                  self->size.left + self->client->area.width,
+                                  self->size.top,
+                                  self->cbwidth_x, self->client->area.height);
+
+                XMapWindow(ob_display, self->innerleft);
+                XMapWindow(ob_display, self->innerright);
+            } else {
+                XUnmapWindow(ob_display, self->innerleft);
+                XUnmapWindow(ob_display, self->innerright);
+            }
+
+            if (self->cbwidth_y) {
+                XMoveResizeWindow(ob_display, self->innertop,
+                                  self->size.left - self->cbwidth_x,
+                                  self->size.top - self->cbwidth_y,
+                                  self->client->area.width +
+                                  self->cbwidth_x * 2, self->cbwidth_y);
+                XMoveResizeWindow(ob_display, self->innerbottom,
+                                  self->size.left - self->cbwidth_x,
+                                  self->size.top + self->client->area.height,
+                                  self->client->area.width +
+                                  self->cbwidth_x * 2, self->cbwidth_y);
+
+                XMapWindow(ob_display, self->innertop);
+                XMapWindow(ob_display, self->innerbottom);
+            } else {
+                XUnmapWindow(ob_display, self->innertop);
+                XUnmapWindow(ob_display, self->innerbottom);
+            }
+
             if (self->bwidth) {
                 gint titlesides;
 
@@ -678,21 +710,9 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
             } else
                 XUnmapWindow(ob_display, self->right);
 
-            /* move and resize the inner border window which contains the plate
-             */
-            XMoveResizeWindow(ob_display, self->inner,
-                              0,
-                              self->size.top - self->cbwidth_y,
-                              self->client->area.width +
-                              self->cbwidth_x * 2 +
-                              (!self->max_horz ? self->bwidth * 2 : 0),
-                              self->client->area.height +
-                              self->cbwidth_y * 2);
-
             /* move the plate */
             XMoveWindow(ob_display, self->plate,
-                        (!self->max_horz ? self->bwidth : 0) + self->cbwidth_x,
-                        self->cbwidth_y);
+                        self->size.left, self->size.top);
 
             /* when the client has StaticGravity, it likes to move around. */
             XMoveWindow(ob_display, self->client->window,
@@ -782,6 +802,7 @@ static void frame_adjust_cursors(ObFrame *self)
         XChangeWindowAttributes(ob_display, self->handle, CWCursor, &a);
         XChangeWindowAttributes(ob_display, self->handletop, CWCursor, &a);
         XChangeWindowAttributes(ob_display, self->handlebottom, CWCursor, &a);
+        XChangeWindowAttributes(ob_display, self->innerbottom, CWCursor, &a);
 
         /* these ones don't */
         a.cursor = ob_cursor(r ? OB_CURSOR_NORTHWEST : OB_CURSOR_NONE);
@@ -796,8 +817,10 @@ static void frame_adjust_cursors(ObFrame *self)
         XChangeWindowAttributes(ob_display, self->titleright, CWCursor, &a);
         a.cursor = ob_cursor(r ? OB_CURSOR_WEST : OB_CURSOR_NONE);
         XChangeWindowAttributes(ob_display, self->left, CWCursor, &a);
+        XChangeWindowAttributes(ob_display, self->innerleft, CWCursor, &a);
         a.cursor = ob_cursor(r ? OB_CURSOR_EAST : OB_CURSOR_NONE);
         XChangeWindowAttributes(ob_display, self->right, CWCursor, &a);
+        XChangeWindowAttributes(ob_display, self->innerright, CWCursor, &a);
         a.cursor = ob_cursor(r ? OB_CURSOR_SOUTHWEST : OB_CURSOR_NONE);
         XChangeWindowAttributes(ob_display, self->lgrip, CWCursor, &a);
         XChangeWindowAttributes(ob_display, self->handleleft, CWCursor, &a);
@@ -856,13 +879,11 @@ void frame_grab_client(ObFrame *self)
     /*
       When reparenting the client window, it is usually not mapped yet, since
       this occurs from a MapRequest. However, in the case where Openbox is
-      starting up, the window is already mapped, so we'll see unmap events for
-      it. There are 2 unmap events generated that we see, one with the 'event'
-      member set the root window, and one set to the client, but both get
-      handled and need to be ignored.
+      starting up, the window is already mapped, so we'll see an unmap event
+      for it.
     */
     if (ob_state() == OB_STATE_STARTING)
-        self->client->ignore_unmaps += 2;
+        ++self->client->ignore_unmaps;
 
     /* select the event mask on the client's parent (to receive config/map
        req's) the ButtonPress is to catch clicks on the client border */
@@ -871,7 +892,10 @@ void frame_grab_client(ObFrame *self)
     /* set all the windows for the frame in the window_map */
     g_hash_table_insert(window_map, &self->window, self->client);
     g_hash_table_insert(window_map, &self->plate, self->client);
-    g_hash_table_insert(window_map, &self->inner, self->client);
+    g_hash_table_insert(window_map, &self->innerleft, self->client);
+    g_hash_table_insert(window_map, &self->innertop, self->client);
+    g_hash_table_insert(window_map, &self->innerright, self->client);
+    g_hash_table_insert(window_map, &self->innerbottom, self->client);
     g_hash_table_insert(window_map, &self->title, self->client);
     g_hash_table_insert(window_map, &self->label, self->client);
     g_hash_table_insert(window_map, &self->max, self->client);
@@ -947,7 +971,10 @@ void frame_release_client(ObFrame *self)
     /* remove all the windows for the frame from the window_map */
     g_hash_table_remove(window_map, &self->window);
     g_hash_table_remove(window_map, &self->plate);
-    g_hash_table_remove(window_map, &self->inner);
+    g_hash_table_remove(window_map, &self->innerleft);
+    g_hash_table_remove(window_map, &self->innertop);
+    g_hash_table_remove(window_map, &self->innerright);
+    g_hash_table_remove(window_map, &self->innerbottom);
     g_hash_table_remove(window_map, &self->title);
     g_hash_table_remove(window_map, &self->label);
     g_hash_table_remove(window_map, &self->max);
@@ -1016,7 +1043,7 @@ static void layout_title(ObFrame *self)
     /* position of the left most button */
     const gint left = ob_rr_theme->paddingx + 1;
     /* position of the right most button */
-    const gint right = self->width - bwidth;
+    const gint right = self->width;
 
     /* turn them all off */
     self->icon_on = self->desk_on = self->shade_on = self->iconify_on =
@@ -1057,43 +1084,49 @@ static void layout_title(ObFrame *self)
                 if ((self->icon_on = is_button_present(self, lc, i))) {
                     /* icon is bigger than buttons */
                     self->label_width -= bwidth + 2;
-                    self->icon_x = x;
+                    if (i > 0) self->icon_x = x;
                     x += i * (bwidth + 2);
+                    if (i < 0) self->icon_x = x;
                 }
             } else if (*lc == 'D') {
                 if (firstcon) *firstcon = OB_FRAME_CONTEXT_ALLDESKTOPS;
                 if ((self->desk_on = is_button_present(self, lc, i))) {
                     self->label_width -= bwidth;
-                    self->desk_x = x;
+                    if (i > 0) self->desk_x = x;
                     x += i * bwidth;
+                    if (i < 0) self->desk_x = x;
                 }
             } else if (*lc == 'S') {
                 if (firstcon) *firstcon = OB_FRAME_CONTEXT_SHADE;
                 if ((self->shade_on = is_button_present(self, lc, i))) {
                     self->label_width -= bwidth;
-                    self->shade_x = x;
+                    if (i > 0) self->shade_x = x;
                     x += i * bwidth;
+                    if (i < 0) self->shade_x = x;
                 }
             } else if (*lc == 'I') {
                 if (firstcon) *firstcon = OB_FRAME_CONTEXT_ICONIFY;
                 if ((self->iconify_on = is_button_present(self, lc, i))) {
                     self->label_width -= bwidth;
-                    self->iconify_x = x;
+                    if (i > 0) self->iconify_x = x;
                     x += i * bwidth;
+                    if (i < 0) self->iconify_x = x;
                 }
             } else if (*lc == 'M') {
                 if (firstcon) *firstcon = OB_FRAME_CONTEXT_MAXIMIZE;
                 if ((self->max_on = is_button_present(self, lc, i))) {
                     self->label_width -= bwidth;
-                    self->max_x = x;
+                    if (i > 0) self->max_x = x;
                     x += i * bwidth;
+                    if (i < 0) self->max_x = x;
                 }
             } else if (*lc == 'C') {
                 if (firstcon) *firstcon = OB_FRAME_CONTEXT_CLOSE;
                 if ((self->close_on = is_button_present(self, lc, i))) {
                     self->label_width -= bwidth;
-                    self->close_x = x;
+                    if (i > 0) self->close_x = x;
                     x += i * bwidth;
+                    if (i < 0) self->close_x = x;
                 }
             } else
                 continue; /* don't set firstcon */
@@ -1217,7 +1250,7 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y)
     }
 
     self = client->frame;
-    if (win == self->inner || win == self->plate) {
+    if (win == self->plate) {
         /* conceptually, this is the desktop, as far as users are
            concerned */
         if (client->type == OB_CLIENT_TYPE_DESKTOP)
@@ -1300,6 +1333,7 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y)
     if (win == self->rgriptop)          return OB_FRAME_CONTEXT_BLCORNER;
     if (win == self->rgripbottom)       return OB_FRAME_CONTEXT_BLCORNER;
     if (win == self->title)             return OB_FRAME_CONTEXT_TITLEBAR;
+    if (win == self->titlebottom)       return OB_FRAME_CONTEXT_TITLEBAR;
     if (win == self->titleleft)         return OB_FRAME_CONTEXT_TLCORNER;
     if (win == self->titletopleft)      return OB_FRAME_CONTEXT_TLCORNER;
     if (win == self->titleright)        return OB_FRAME_CONTEXT_TRCORNER;
@@ -1312,6 +1346,10 @@ ObFrameContext frame_context(ObClient *client, Window win, gint x, gint y)
     if (win == self->trrresize)         return OB_FRAME_CONTEXT_TRCORNER;
     if (win == self->left)              return OB_FRAME_CONTEXT_LEFT;
     if (win == self->right)             return OB_FRAME_CONTEXT_RIGHT;
+    if (win == self->innertop)          return OB_FRAME_CONTEXT_TITLEBAR;
+    if (win == self->innerleft)         return OB_FRAME_CONTEXT_LEFT;
+    if (win == self->innerbottom)       return OB_FRAME_CONTEXT_BOTTOM;
+    if (win == self->innerright)        return OB_FRAME_CONTEXT_RIGHT;
     if (win == self->max)               return OB_FRAME_CONTEXT_MAXIMIZE;
     if (win == self->iconify)           return OB_FRAME_CONTEXT_ICONIFY;
     if (win == self->close)             return OB_FRAME_CONTEXT_CLOSE;
@@ -1343,7 +1381,8 @@ void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h)
     case SouthEastGravity:
     case EastGravity:
         /* the right side of the client will be the right side of the frame */
-        *x -= self->size.right + self->size.left - self->client->border_width*2;
+        *x -= self->size.right + self->size.left -
+            self->client->border_width * 2;
         break;
 
     case ForgetGravity:
@@ -1372,7 +1411,8 @@ void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h)
     case SouthEastGravity:
     case SouthGravity:
         /* the bottom of the client will be the bottom of the frame */
-        *y -= self->size.bottom + self->size.top - self->client->border_width*2;
+        *y -= self->size.bottom + self->size.top -
+            self->client->border_width * 2;
         break;
 
     case ForgetGravity:
@@ -1402,7 +1442,8 @@ void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h)
     case EastGravity:
     case SouthEastGravity:
         /* the right side of the client will be the right side of the frame */
-        *x += self->size.right + self->size.left - self->client->border_width*2;
+        *x += self->size.right + self->size.left -
+            self->client->border_width * 2;
         break;
     case StaticGravity:
     case ForgetGravity:
@@ -1428,7 +1469,8 @@ void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h)
     case SouthGravity:
     case SouthEastGravity:
         /* the bottom of the client will be the bottom of the frame */
-        *y += self->size.bottom + self->size.top - self->client->border_width*2;
+        *y += self->size.bottom + self->size.top -
+            self->client->border_width * 2;
         break;
     case StaticGravity:
     case ForgetGravity:
This page took 0.029977 seconds and 4 git commands to generate.