]> Dogcows Code - chaz/openbox/commitdiff
some slit fixes, support resizing slitapps
authorDana Jansens <danakj@orodu.net>
Sat, 10 May 2003 22:20:08 +0000 (22:20 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 10 May 2003 22:20:08 +0000 (22:20 +0000)
openbox/event.c
openbox/slit.c
openbox/slit.h

index c96583dc4d1f7309ca5cc9235a88790ff7b546b8..9a351f73ceec24a0f4af0cb11c0ef1d078f8aad0 100644 (file)
@@ -381,7 +381,7 @@ static void event_process(XEvent *e)
 
     window = event_get_window(e);
     if (!(client = g_hash_table_lookup(client_map, &window)))
-        if (!(slitapp = g_hash_table_lookup(slit_map, &window)))
+        if (!(slitapp = g_hash_table_lookup(slit_app_map, &window)))
             menu = g_hash_table_lookup(menu_map, &window);
 
     event_set_lasttime(e);
@@ -924,5 +924,8 @@ static void event_handle_slitapp(SlitApp *app, XEvent *e)
     case ReparentNotify:
        slit_remove(app, FALSE);
        break;
+    case ConfigureNotify:
+        slit_app_configure(app, e->xconfigure.width, e->xconfigure.height);
+        break;
     }
 }
index 1ed32a24e56c784a2e4986e9d30cb2eb20341238..98eb010e8b4047072b5e5779a56070cb3228738a 100644 (file)
@@ -4,10 +4,7 @@
 #include "render/theme.h"
 #include "render/render.h"
 
-#ifdef HAVE_LIMITS_H
-#  include <limits.h>
-#endif
-
+#define SLIT_EVENT_MASK (EnterNotifyMask | LeaveNotifyMask)
 #define SLITAPP_EVENT_MASK (StructureNotifyMask)
 
 struct Slit {
@@ -23,6 +20,8 @@ struct Slit {
     int w, h;
 
     gboolean horz;
+    gboolean hide;
+    gboolean hidden;
 
     Appearance *a_frame;
 
@@ -30,6 +29,7 @@ struct Slit {
 };
 
 GHashTable *slit_map = NULL;
+GHashTable *slit_app_map = NULL;
 
 static Slit *slit;
 static int nslits;
@@ -42,12 +42,16 @@ void slit_startup()
     int i;
 
     slit_map = g_hash_table_new(g_int_hash, g_int_equal);
+    slit_app_map = g_hash_table_new(g_int_hash, g_int_equal);
 
     nslits = 1;
     slit = g_new0(struct Slit, nslits);
 
     for (i = 0; i < nslits; ++i) {
-        slit[i].horz = TRUE;
+        slit[i].horz = FALSE;
+        slit[i].hide = TRUE;
+        slit[i].hidden = FALSE;
+        slit[i].pos = SlitPos_TopRight;
 
         attrib.override_redirect = True;
         slit[i].frame = XCreateWindow(ob_display, ob_root, 0, 0, 1, 1, 0,
@@ -56,6 +60,8 @@ void slit_startup()
         slit[i].a_frame = appearance_copy(theme_a_unfocused_title);
         XSetWindowBorder(ob_display, slit[i].frame, theme_b_color->pixel);
         XSetWindowBorderWidth(ob_display, slit[i].frame, theme_bwidth);
+
+        g_hash_table_insert(slit_map, &slit[i].frame, &slit[i]);
     }
 }
 
@@ -66,7 +72,10 @@ void slit_shutdown()
     for (i = 0; i < nslits; ++i) {
         XDestroyWindow(ob_display, slit[i].frame);
         appearance_free(slit[i].a_frame);
+        g_hash_table_remove(slit_map, &slit[i].frame);
     }
+    g_hash_table_destroy(slit_app_map);
+    g_hash_table_destroy(slit_map);
 }
 
 void slit_add(Window win, XWMHints *wmhints, XWindowAttributes *attrib)
@@ -88,8 +97,8 @@ void slit_add(Window win, XWMHints *wmhints, XWindowAttributes *attrib)
 
     s->slit_apps = g_list_append(s->slit_apps, app);
     slit_configure(s);
-    XReparentWindow(ob_display, app->icon_win, s->frame, app->x, app->y);
 
+    XReparentWindow(ob_display, app->icon_win, s->frame, app->x, app->y);
     /*
       This is the same case as in frame.c for client windows. When Openbox is
       starting, the window is already mapped so we see unmap events occur for
@@ -100,8 +109,12 @@ void slit_add(Window win, XWMHints *wmhints, XWindowAttributes *attrib)
     if (ob_state == State_Starting)
        app->ignore_unmaps += 2;
 
-    if (app->win != app->icon_win)
-        XMoveWindow(ob_display, app->win, 100, 100);
+    if (app->win != app->icon_win) {
+        /* have to map it so that it can be re-managed on a restart */
+        XMoveWindow(ob_display, app->win, -1000, -1000);
+        XMapWindow(ob_display, app->win);
+    }
+    g_message("   Slitting 0x%lx 0x%lx", app->icon_win, app->win);
     XMapWindow(ob_display, app->icon_win);
     XSync(ob_display, False);
 
@@ -110,7 +123,7 @@ void slit_add(Window win, XWMHints *wmhints, XWindowAttributes *attrib)
     XChangeSaveSet(ob_display, app->icon_win, SetModeInsert);
     XSelectInput(ob_display, app->icon_win, SLITAPP_EVENT_MASK);
 
-    g_hash_table_insert(slit_map, &app->icon_win, app);
+    g_hash_table_insert(slit_app_map, &app->icon_win, app);
 
     g_message("Managed Slit App: 0x%lx", app->icon_win);
 }
@@ -131,7 +144,7 @@ void slit_remove(SlitApp *app, gboolean reparent)
     XChangeSaveSet(ob_display, app->icon_win, SetModeDelete);
     XSync(ob_display, False);
 
-    g_hash_table_remove(slit_map, &app->icon_win);
+    g_hash_table_remove(slit_app_map, &app->icon_win);
 
     if (reparent)
        XReparentWindow(ob_display, app->icon_win, ob_root, app->x, app->y);
@@ -179,71 +192,123 @@ static void slit_configure(Slit *self)
     self->w += theme_bwidth * 2;
     self->h += theme_bwidth * 2;
 
+    /* calculate position */
     switch (self->pos) {
     case SlitPos_Floating:
-        /* calculate position */
         self->x = self->user_x;
         self->y = self->user_y;
-
-        switch(self->gravity) {
-        case NorthGravity:
-        case CenterGravity:
-        case SouthGravity:
-            self->x -= self->w / 2;
-            break;
-        case NorthEastGravity:
-        case EastGravity:
-        case SouthEastGravity:
-            self->x -= self->w;
-            break;
-        }
-        switch(self->gravity) {
-        case WestGravity:
-        case CenterGravity:
-        case EastGravity:
-            self->y -= self->h / 2;
-            break;
-        case SouthWestGravity:
-        case SouthGravity:
-        case SouthEastGravity:
-            self->y -= self->h;
-            break;
-        }
         break;
     case SlitPos_TopLeft:
         self->x = 0;
         self->y = 0;
+        self->gravity = NorthWestGravity;
         break;
     case SlitPos_Top:
-        self->x = (screen_physical_size.width - self->w) / 2;
+        self->x = screen_physical_size.width / 2;
         self->y = 0;
+        self->gravity = NorthGravity;
         break;
     case SlitPos_TopRight:
-        self->x = screen_physical_size.width - self->w;
+        self->x = screen_physical_size.width;
         self->y = 0;
+        self->gravity = NorthEastGravity;
         break;
     case SlitPos_Left:
         self->x = 0;
-        self->y = (screen_physical_size.height - self->h) / 2;
+        self->y = screen_physical_size.height / 2;
+        self->gravity = WestGravity;
         break;
     case SlitPos_Right:
-        self->x = screen_physical_size.width - self->w;
-        self->y = (screen_physical_size.height - self->h) / 2;
+        self->x = screen_physical_size.width;
+        self->y = screen_physical_size.height / 2;
+        self->gravity = EastGravity;
         break;
     case SlitPos_BottomLeft:
         self->x = 0;
-        self->y = screen_physical_size.height - self->h;
+        self->y = screen_physical_size.height;
+        self->gravity = SouthWestGravity;
         break;
     case SlitPos_Bottom:
-        self->x = (screen_physical_size.width - self->w) / 2;
-        self->y = screen_physical_size.height - self->h;
+        self->x = screen_physical_size.width / 2;
+        self->y = screen_physical_size.height;
+        self->gravity = SouthGravity;
         break;
     case SlitPos_BottomRight:
-        self->x = screen_physical_size.width - self->w;
-        self->y = screen_physical_size.height - self->h;
+        self->x = screen_physical_size.width;
+        self->y = screen_physical_size.height;
+        self->gravity = SouthEastGravity;
+        break;
+    }
+
+    switch(self->gravity) {
+    case NorthGravity:
+    case CenterGravity:
+    case SouthGravity:
+        self->x -= self->w / 2;
+        break;
+    case NorthEastGravity:
+    case EastGravity:
+    case SouthEastGravity:
+        self->x -= self->w;
+        break;
+    }
+    switch(self->gravity) {
+    case WestGravity:
+    case CenterGravity:
+    case EastGravity:
+        self->y -= self->h / 2;
+        break;
+    case SouthWestGravity:
+    case SouthGravity:
+    case SouthEastGravity:
+        self->y -= self->h;
         break;
     }
 
+    if (self->hide && self->hidden) {
+        g_message("hidden");
+        switch (self->pos) {
+        case SlitPos_Floating:
+            break;
+        case SlitPos_TopLeft:
+            if (self->horz)
+                self->y -= self->h - theme_bwidth;
+            else
+                self->x -= self->w - theme_bwidth;
+            break;
+        case SlitPos_Top:
+            self->y -= self->h - theme_bwidth;
+            break;
+        case SlitPos_TopRight:
+            if (self->horz)
+                self->y -= self->h - theme_bwidth;
+            else
+                self->x += self->w - theme_bwidth;
+            break;
+        case SlitPos_Left:
+            self->x -= self->w - theme_bwidth;
+            break;
+        case SlitPos_Right:
+            self->x += self->w - theme_bwidth;
+            break;
+        case SlitPos_BottomLeft:
+            if (self->horz)
+                self->y += self->h - theme_bwidth;
+            else
+                self->x -= self->w - theme_bwidth;
+            break;
+        case SlitPos_Bottom:
+            self->y += self->h - theme_bwidth;
+            break;
+        case SlitPos_BottomRight:
+            if (self->horz)
+                self->y += self->h - theme_bwidth;
+            else
+                self->x += self->w - theme_bwidth;
+            break;
+        }    
+    }
+
     /* not used for actually sizing shit */
     self->w -= theme_bwidth * 2;
     self->h -= theme_bwidth * 2;
@@ -258,3 +323,10 @@ static void slit_configure(Slit *self)
     } else
         XUnmapWindow(ob_display, self->frame);
 }
+
+void slit_app_configure(SlitApp *app, int w, int h)
+{
+    app->w = w;
+    app->h = h;
+    slit_configure(app->slit);
+}
index f3fce18ecf5973f2b0612250ec87c8791f65d853..d7e9efa7bf8351de74236ec7ab4cbdb752016961 100644 (file)
@@ -31,7 +31,7 @@ typedef enum {
     SlitPos_Left
 } SlitPosition;
 
-extern GHashTable *slit_map;
+extern GHashTable *slit_app_map;
 
 void slit_startup();
 void slit_shutdown();
@@ -43,4 +43,6 @@ void slit_add(Window win, XWMHints *wmhints, XWindowAttributes *attrib);
 void slit_remove_all();
 void slit_remove(SlitApp *app, gboolean reparent);
 
+void slit_app_configure(SlitApp *app, int w, int h);
+
 #endif
This page took 0.031921 seconds and 4 git commands to generate.