Make edges windows more like how I think it should be.
authorMikael Magnusson <mikachu@comhem.se>
Wed, 23 Jan 2008 03:18:00 +0000 (04:18 +0100)
committerMikael Magnusson <mikachu@comhem.se>
Sat, 8 Mar 2008 16:21:12 +0000 (17:21 +0100)
openbox/edges.c
openbox/edges.h

index 259d1bfd278397d810c4780dffb22bdc26969693..2296b02604aff0f3192eefef51f239c51e501f1e 100644 (file)
@@ -7,62 +7,46 @@
 #include <glib.h>
 
 #warning Do something clever with xinerama
-Window edge[OB_NUM_EDGES];
+ObEdge *edge[OB_NUM_EDGES];
 #warning put in config.c and parse configs of course
 gboolean config_edge_enabled[OB_NUM_EDGES] = {1, 1, 1, 1, 1, 1, 1, 1};
 
 #define EDGE_WIDTH 10
 #define CORNER_SIZE 20
-static void get_position(ObEdge edge, Rect screen, Rect *rect)
+static void get_position(ObEdgeLocation edge, Rect screen, Rect *rect)
 {
     switch (edge) {
         case OB_EDGE_TOP:
-            rect->x = CORNER_SIZE;
-            rect->y = 0;
-            rect->width = screen.width - 2 * CORNER_SIZE;
-            rect->height = EDGE_WIDTH;
+            RECT_SET(*rect, CORNER_SIZE, 0,
+                     screen.width - 2 * CORNER_SIZE, EDGE_WIDTH);
             break;
         case OB_EDGE_TOPRIGHT:
-            rect->x = screen.width - CORNER_SIZE;
-            rect->y = 0;
-            rect->width = CORNER_SIZE;
-            rect->height = CORNER_SIZE;
+            RECT_SET(*rect, screen.width - CORNER_SIZE, 0,
+                     CORNER_SIZE, CORNER_SIZE);
             break;
         case OB_EDGE_RIGHT:
-            rect->x = screen.width - EDGE_WIDTH;
-            rect->y = CORNER_SIZE;
-            rect->width = EDGE_WIDTH;
-            rect->height = screen.height - 2 * CORNER_SIZE;
+            RECT_SET(*rect, screen.width - EDGE_WIDTH, CORNER_SIZE,
+                     EDGE_WIDTH, screen.height - 2 * CORNER_SIZE);
             break;
         case OB_EDGE_BOTTOMRIGHT:
-            rect->x = screen.width - CORNER_SIZE;
-            rect->y = screen.height - CORNER_SIZE;
-            rect->width = CORNER_SIZE;
-            rect->height = CORNER_SIZE;
+            RECT_SET(*rect, screen.width - CORNER_SIZE,
+                     screen.height - CORNER_SIZE,
+                     CORNER_SIZE, CORNER_SIZE);
             break;
         case OB_EDGE_BOTTOM:
-            rect->x = CORNER_SIZE;
-            rect->y = screen.height - EDGE_WIDTH;
-            rect->width = screen.width - 2 * CORNER_SIZE;
-            rect->height = EDGE_WIDTH;
+            RECT_SET(*rect, CORNER_SIZE, screen.height - EDGE_WIDTH,
+                     screen.width - 2 * CORNER_SIZE, EDGE_WIDTH);
             break;
         case OB_EDGE_BOTTOMLEFT:
-            rect->x = 0;
-            rect->y = screen.height - CORNER_SIZE;
-            rect->width = CORNER_SIZE;
-            rect->height = CORNER_SIZE;
+            RECT_SET(*rect, 0, screen.height - CORNER_SIZE,
+                     CORNER_SIZE, CORNER_SIZE);
             break;
         case OB_EDGE_LEFT:
-            rect->x = 0;
-            rect->y = CORNER_SIZE;
-            rect->width = EDGE_WIDTH;
-            rect->height = screen.height - CORNER_SIZE;
+            RECT_SET(*rect, 0, CORNER_SIZE,
+                     EDGE_WIDTH, screen.height - CORNER_SIZE);
             break;
         case OB_EDGE_TOPLEFT:
-            rect->x = 0;
-            rect->y = 0;
-            rect->width = CORNER_SIZE;
-            rect->height = CORNER_SIZE;
+            RECT_SET(*rect, 0, 0, CORNER_SIZE, CORNER_SIZE);
             break;
     }
 }
@@ -82,11 +66,19 @@ void edges_startup(gboolean reconfigure)
     for (i=0; i < OB_NUM_EDGES; i++) {
         if (!config_edge_enabled[i])
             continue;
+
+        edge[i] = g_new(ObEdge, 1);
+        edge[i]->obwin.type = OB_WINDOW_CLASS_INTERNAL;
+
         get_position(i, *screen, &r);
-        edge[i] = XCreateWindow(obt_display, RootWindow(obt_display, ob_screen),
-                                r.x, r.y, r.width, r.height, 0, 0, InputOnly,
-                                CopyFromParent, CWOverrideRedirect, &xswa);
-        XMapWindow(obt_display, edge[i]);
+        edge[i]->win = XCreateWindow(obt_display, RootWindow(obt_display, ob_screen),
+                                     r.x, r.y, r.width, r.height, 0, 0, InputOnly,
+                                     CopyFromParent, CWOverrideRedirect, &xswa);
+        XMapWindow(obt_display, edge[i]->win);
+
+        stacking_add(INTERNAL_AS_WINDOW(edge[i]));
+        window_add(&edge[i]->win, INTERNAL_AS_WINDOW(edge[i]));
+
         printf("mapped edge window %i at %03i %03i %02i %02i\n", i, r.x, r.y, r.width, r.height);
         fflush(stdout);
     }
@@ -100,6 +92,8 @@ void edges_shutdown(gboolean reconfigure)
 {
     gint i;
 
-    for (i=0; i < OB_NUM_EDGES; i++)
-        XDestroyWindow(obt_display, edge[i]);
+    for (i=0; i < OB_NUM_EDGES; i++) {
+        XDestroyWindow(obt_display, edge[i]->win);
+        g_free(edge[i]);
+    }
 }
index a3fe1361fdda4af78e1c9c097d68da22e9b9e1fe..7bf33115eeda75a949db6ae5f7231d1990d090a4 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __edges_h
 #define __edges_h
 
+#include "window.h"
+
 typedef enum
 {
     OB_EDGE_TOP,
@@ -12,7 +14,15 @@ typedef enum
     OB_EDGE_LEFT,
     OB_EDGE_TOPLEFT,
     OB_NUM_EDGES
-} ObEdge;
+} ObEdgeLocation;
+
+typedef struct _ObEdge ObEdge;
+
+struct _ObEdge
+{
+    ObWindow obwin;
+    Window win;
+};
 
 void edges_startup(gboolean reconfigure);
 void edges_shutdown(gboolean reconfigure);