]> Dogcows Code - chaz/openbox/commitdiff
make the window.h interface more consistent with the rest of openbox, hide the window...
authorDana Jansens <danakj@orodu.net>
Sun, 20 Jan 2008 07:56:12 +0000 (02:56 -0500)
committerDana Jansens <danakj@orodu.net>
Thu, 31 Jan 2008 17:25:30 +0000 (12:25 -0500)
12 files changed:
openbox/client.c
openbox/dock.c
openbox/dock.h
openbox/event.c
openbox/focus_cycle_indicator.c
openbox/focus_cycle_popup.c
openbox/frame.c
openbox/menuframe.c
openbox/openbox.c
openbox/popup.c
openbox/window.c
openbox/window.h

index c91d6e3b00a7f9ee1981e0e88697479f29657a80..9986015c29d9ac3a35bd824552717bc8d6a5f67c 100644 (file)
@@ -274,7 +274,7 @@ void client_manage(Window window)
     /* create the ObClient struct, and populate it from the hints on the
        window */
     self = g_new0(ObClient, 1);
-    self->obwin.type = Window_Client;
+    self->obwin.type = OB_WINDOW_CLASS_CLIENT;
     self->window = window;
 
     /* non-zero defaults */
@@ -597,7 +597,7 @@ void client_manage(Window window)
 
     /* add to client list/map */
     client_list = g_list_append(client_list, self);
-    g_hash_table_insert(window_map, &self->window, self);
+    window_add(&self->window, CLIENT_AS_WINDOW(self));
 
     /* this has to happen after we're in the client_list */
     if (STRUT_EXISTS(self->strut))
@@ -705,7 +705,7 @@ void client_unmanage(ObClient *self)
 
     client_list = g_list_remove(client_list, self);
     stacking_remove(self);
-    g_hash_table_remove(window_map, &self->window);
+    window_remove(self->window);
 
     /* once the client is out of the list, update the struts to remove its
        influence */
@@ -1285,13 +1285,13 @@ void client_update_transient_for(ObClient *self)
 
     if (XGetTransientForHint(obt_display, self->window, &t)) {
         if (t != self->window) { /* cant be transient to itself! */
-            target = g_hash_table_lookup(window_map, &t);
+            ObWindow *tw = window_find(t);
             /* if this happens then we need to check for it*/
-            g_assert(target != self);
-            if (target && !WINDOW_IS_CLIENT(target)) {
-                /* this can happen when a dialog is a child of
-                   a dockapp, for example */
-                target = NULL;
+            g_assert(tw != CLIENT_AS_WINDOW(self));
+            if (target && WINDOW_IS_CLIENT(tw)) {
+                /* watch out for windows with a parent that is something
+                   different, like a dockapp for example */
+                target = WINDOW_AS_CLIENT(tw);
             }
         }
 
index dba74f684923d53ffb28ea04844f7bb18c6bcebc..291cd1d0a27c7ff224cae1acd9e66b425623880e 100644 (file)
@@ -78,7 +78,7 @@ void dock_startup(gboolean reconfig)
                       0, 0, 0, 0, 0, 0, 0, 0);
 
     dock = g_new0(ObDock, 1);
-    dock->obwin.type = Window_Dock;
+    dock->obwin.type = OB_WINDOW_CLASS_DOCK;
 
     dock->hidden = TRUE;
 
@@ -102,7 +102,7 @@ void dock_startup(gboolean reconfig)
     OBT_PROP_SET32(dock->frame, NET_WM_WINDOW_TYPE, ATOM,
                    OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK));
 
-    g_hash_table_insert(window_map, &dock->frame, dock);
+    window_add(&dock->frame, DOCK_AS_WINDOW(dock));
     stacking_add(DOCK_AS_WINDOW(dock));
 }
 
@@ -120,7 +120,7 @@ void dock_shutdown(gboolean reconfig)
 
     XDestroyWindow(obt_display, dock->frame);
     RrAppearanceFree(dock->a_frame);
-    g_hash_table_remove(window_map, &dock->frame);
+    window_remove(dock->frame);
     stacking_remove(dock);
 }
 
@@ -131,7 +131,6 @@ void dock_add(Window win, XWMHints *wmhints)
     gchar **data;
 
     app = g_new0(ObDockApp, 1);
-    app->obwin.type = Window_DockApp;
     app->win = win;
     app->icon_win = (wmhints->flags & IconWindowHint) ?
         wmhints->icon_window : win;
@@ -184,8 +183,6 @@ void dock_add(Window win, XWMHints *wmhints)
 
     dock_app_grab_button(app, TRUE);
 
-    g_hash_table_insert(window_map, &app->icon_win, app);
-
     ob_debug("Managed Dock App: 0x%lx (%s)\n", app->icon_win, app->class);
 }
 
@@ -203,8 +200,6 @@ void dock_remove(ObDockApp *app, gboolean reparent)
     XChangeSaveSet(obt_display, app->icon_win, SetModeDelete);
     XSync(obt_display, False);
 
-    g_hash_table_remove(window_map, &app->icon_win);
-
     if (reparent)
         XReparentWindow(obt_display, app->icon_win,
                         RootWindow(obt_display, ob_screen), app->x, app->y);
@@ -654,3 +649,17 @@ void dock_get_area(Rect *a)
     RECT_SET(*a, dock->area.x, dock->area.y,
              dock->area.width, dock->area.height);
 }
+
+ObDockApp* dock_find_dockapp(Window xwin)
+{
+    g_assert(xwin != None);
+    GList *it;
+    /* there are never that many dock apps, so we can use a list here instead
+       of a hash table */
+    for (it = dock->dock_apps; it; it = g_list_next(it)) {
+        ObDockApp *app = it->data;
+        if (app->icon_win == xwin)
+            return app;
+    }
+    return NULL;
+}
index 57c1f393170e4aa8568166f0ac2a0928b30109c9..25e31c0b841851a21d2896f86eb4b68991b50b03 100644 (file)
@@ -47,8 +47,6 @@ struct _ObDock
 };
 
 struct _ObDockApp {
-    ObWindow obwin;
-
     gint ignore_unmaps;
 
     Window icon_win;
@@ -81,4 +79,6 @@ void dock_app_configure(ObDockApp *app, gint w, gint h);
 
 void dock_get_area(Rect *a);
 
+ObDockApp* dock_find_dockapp(Window xwin);
+
 #endif
index bbaf11c5e62891c1e9b3616da81195050687978e..7867e9669425bd621ffe105a09e30d3d5ac74867 100644 (file)
@@ -335,7 +335,7 @@ static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
            but has disappeared.
         */
         if (in_client_only) {
-            ObWindow *w = g_hash_table_lookup(window_map, &e->xfocus.window);
+            ObWindow *w = window_find(e->xfocus.window);
             if (!w || !WINDOW_IS_CLIENT(w))
                 return FALSE;
         }
@@ -463,26 +463,24 @@ static void event_process(const XEvent *ec, gpointer data)
     e = &ee;
 
     window = event_get_window(e);
-    if ((obwin = g_hash_table_lookup(window_map, &window))) {
+    if ((obwin = window_find(window))) {
         switch (obwin->type) {
-        case Window_Dock:
+        case OB_WINDOW_CLASS_DOCK:
             dock = WINDOW_AS_DOCK(obwin);
             break;
-        case Window_DockApp:
-            dockapp = WINDOW_AS_DOCKAPP(obwin);
-            break;
-        case Window_Client:
+        case OB_WINDOW_CLASS_CLIENT:
             client = WINDOW_AS_CLIENT(obwin);
             break;
-        case Window_Menu:
-            /* not to be used for events */
-            g_assert_not_reached();
+        case OB_WINDOW_CLASS_MENUFRAME:
+            /* XXX use this to handle events more uniformly */
             break;
-        case Window_Internal:
+        case OB_WINDOW_CLASS_INTERNALWINDOW:
             /* we don't do anything with events directly on these windows */
             break;
         }
     }
+    else
+        dockapp = dock_find_dockapp(window);
 
     event_set_curtime(e);
     event_curserial = e->xany.serial;
@@ -713,8 +711,8 @@ static void event_process(const XEvent *ec, gpointer data)
         else {
             ObWindow *w;
 
-            if ((w = g_hash_table_lookup(window_map, &e->xbutton.subwindow)) &&
-                WINDOW_IS_INTERNAL(w))
+            if ((w = window_find(e->xbutton.subwindow)) &&
+                WINDOW_IS_INTERNALWINDOW(w))
             {
                 event_handle_user_input(client, e);
             }
@@ -1113,8 +1111,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             /* get the sibling */
             if (e->xconfigurerequest.value_mask & CWSibling) {
                 ObWindow *win;
-                win = g_hash_table_lookup(window_map,
-                                          &e->xconfigurerequest.above);
+                win = window_find(e->xconfigurerequest.above);
                 if (win && WINDOW_IS_CLIENT(win) &&
                     WINDOW_AS_CLIENT(win) != client)
                 {
@@ -1447,8 +1444,7 @@ static void event_handle_client(ObClient *client, XEvent *e)
             } else {
                 ObClient *sibling = NULL;
                 if (e->xclient.data.l[1]) {
-                    ObWindow *win = g_hash_table_lookup
-                        (window_map, &e->xclient.data.l[1]);
+                    ObWindow *win = window_find(e->xclient.data.l[1]);
                     if (WINDOW_IS_CLIENT(win) &&
                         WINDOW_AS_CLIENT(win) != client)
                     {
index a9ca3a2f33667d36998c7c7c0c72225083cccac7..2242b3d3d9e276bda481c65e2b473ed2604972d6 100644 (file)
 
 static struct
 {
-    InternalWindow top;
-    InternalWindow left;
-    InternalWindow right;
-    InternalWindow bottom;
+    ObInternalWindow top;
+    ObInternalWindow left;
+    ObInternalWindow right;
+    ObInternalWindow bottom;
 } focus_indicator;
 
 static RrAppearance *a_focus_indicator;
@@ -59,38 +59,38 @@ void focus_cycle_indicator_startup(gboolean reconfig)
 
     if (reconfig) return;
 
-    focus_indicator.top.obwin.type = Window_Internal;
-    focus_indicator.left.obwin.type = Window_Internal;
-    focus_indicator.right.obwin.type = Window_Internal;
-    focus_indicator.bottom.obwin.type = Window_Internal;
+    focus_indicator.top.obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
+    focus_indicator.left.obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
+    focus_indicator.right.obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
+    focus_indicator.bottom.obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
 
     attr.override_redirect = True;
     attr.background_pixel = BlackPixel(obt_display, ob_screen);
-    focus_indicator.top.win =
+    focus_indicator.top.window =
         create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.left.win =
+    focus_indicator.left.window =
         create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.right.win =
+    focus_indicator.right.window =
         create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.bottom.win =
+    focus_indicator.bottom.window =
         create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
 
-    stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.top));
-    stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.left));
-    stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.right));
-    stacking_add(INTERNAL_AS_WINDOW(&focus_indicator.bottom));
-    g_hash_table_insert(window_map, &focus_indicator.top.win,
-                        &focus_indicator.top);
-    g_hash_table_insert(window_map, &focus_indicator.left.win,
-                        &focus_indicator.left);
-    g_hash_table_insert(window_map, &focus_indicator.right.win,
-                        &focus_indicator.right);
-    g_hash_table_insert(window_map, &focus_indicator.bottom.win,
-                        &focus_indicator.bottom);
+    stacking_add(INTERNALWINDOW_AS_WINDOW(&focus_indicator.top));
+    stacking_add(INTERNALWINDOW_AS_WINDOW(&focus_indicator.left));
+    stacking_add(INTERNALWINDOW_AS_WINDOW(&focus_indicator.right));
+    stacking_add(INTERNALWINDOW_AS_WINDOW(&focus_indicator.bottom));
+    window_add(&focus_indicator.top.window,
+               INTERNALWINDOW_AS_WINDOW(&focus_indicator.top));
+    window_add(&focus_indicator.left.window,
+               INTERNALWINDOW_AS_WINDOW(&focus_indicator.left));
+    window_add(&focus_indicator.right.window,
+               INTERNALWINDOW_AS_WINDOW(&focus_indicator.right));
+    window_add(&focus_indicator.bottom.window,
+               INTERNALWINDOW_AS_WINDOW(&focus_indicator.bottom));
 
     color_white = RrColorNew(ob_rr_inst, 0xff, 0xff, 0xff);
 
@@ -117,20 +117,20 @@ void focus_cycle_indicator_shutdown(gboolean reconfig)
 
     RrAppearanceFree(a_focus_indicator);
 
-    g_hash_table_remove(window_map, &focus_indicator.top.win);
-    g_hash_table_remove(window_map, &focus_indicator.left.win);
-    g_hash_table_remove(window_map, &focus_indicator.right.win);
-    g_hash_table_remove(window_map, &focus_indicator.bottom.win);
+    window_remove(focus_indicator.top.window);
+    window_remove(focus_indicator.left.window);
+    window_remove(focus_indicator.right.window);
+    window_remove(focus_indicator.bottom.window);
 
-    stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.top));
-    stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.left));
-    stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.right));
-    stacking_remove(INTERNAL_AS_WINDOW(&focus_indicator.bottom));
+    stacking_remove(INTERNALWINDOW_AS_WINDOW(&focus_indicator.top));
+    stacking_remove(INTERNALWINDOW_AS_WINDOW(&focus_indicator.left));
+    stacking_remove(INTERNALWINDOW_AS_WINDOW(&focus_indicator.right));
+    stacking_remove(INTERNALWINDOW_AS_WINDOW(&focus_indicator.bottom));
 
-    XDestroyWindow(obt_display, focus_indicator.top.win);
-    XDestroyWindow(obt_display, focus_indicator.left.win);
-    XDestroyWindow(obt_display, focus_indicator.right.win);
-    XDestroyWindow(obt_display, focus_indicator.bottom.win);
+    XDestroyWindow(obt_display, focus_indicator.top.window);
+    XDestroyWindow(obt_display, focus_indicator.left.window);
+    XDestroyWindow(obt_display, focus_indicator.right.window);
+    XDestroyWindow(obt_display, focus_indicator.bottom.window);
 }
 
 void focus_cycle_draw_indicator(ObClient *c)
@@ -141,10 +141,10 @@ void focus_cycle_draw_indicator(ObClient *c)
         /* kill enter events cause by this unmapping */
         ignore_start = event_start_ignore_all_enters();
 
-        XUnmapWindow(obt_display, focus_indicator.top.win);
-        XUnmapWindow(obt_display, focus_indicator.left.win);
-        XUnmapWindow(obt_display, focus_indicator.right.win);
-        XUnmapWindow(obt_display, focus_indicator.bottom.win);
+        XUnmapWindow(obt_display, focus_indicator.top.window);
+        XUnmapWindow(obt_display, focus_indicator.left.window);
+        XUnmapWindow(obt_display, focus_indicator.right.window);
+        XUnmapWindow(obt_display, focus_indicator.bottom.window);
 
         event_end_ignore_all_enters(ignore_start);
 
@@ -166,7 +166,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = c->frame->area.width;
         h = wt;
 
-        XMoveResizeWindow(obt_display, focus_indicator.top.win,
+        XMoveResizeWindow(obt_display, focus_indicator.top.window,
                           x, y, w, h);
         a_focus_indicator->texture[0].data.lineart.x1 = 0;
         a_focus_indicator->texture[0].data.lineart.y1 = h-1;
@@ -184,7 +184,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = h-1;
         a_focus_indicator->texture[3].data.lineart.x2 = w - wr;
         a_focus_indicator->texture[3].data.lineart.y2 = h-1;
-        RrPaint(a_focus_indicator, focus_indicator.top.win,
+        RrPaint(a_focus_indicator, focus_indicator.top.window,
                 w, h);
 
         x = c->frame->area.x;
@@ -192,7 +192,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = wl;
         h = c->frame->area.height;
 
-        XMoveResizeWindow(obt_display, focus_indicator.left.win,
+        XMoveResizeWindow(obt_display, focus_indicator.left.window,
                           x, y, w, h);
         a_focus_indicator->texture[0].data.lineart.x1 = w-1;
         a_focus_indicator->texture[0].data.lineart.y1 = 0;
@@ -210,7 +210,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = wt-1;
         a_focus_indicator->texture[3].data.lineart.x2 = w-1;
         a_focus_indicator->texture[3].data.lineart.y2 = h - wb;
-        RrPaint(a_focus_indicator, focus_indicator.left.win,
+        RrPaint(a_focus_indicator, focus_indicator.left.window,
                 w, h);
 
         x = c->frame->area.x + c->frame->area.width - wr;
@@ -218,7 +218,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = wr;
         h = c->frame->area.height ;
 
-        XMoveResizeWindow(obt_display, focus_indicator.right.win,
+        XMoveResizeWindow(obt_display, focus_indicator.right.window,
                           x, y, w, h);
         a_focus_indicator->texture[0].data.lineart.x1 = 0;
         a_focus_indicator->texture[0].data.lineart.y1 = 0;
@@ -236,7 +236,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = wt-1;
         a_focus_indicator->texture[3].data.lineart.x2 = 0;
         a_focus_indicator->texture[3].data.lineart.y2 = h - wb;
-        RrPaint(a_focus_indicator, focus_indicator.right.win,
+        RrPaint(a_focus_indicator, focus_indicator.right.window,
                 w, h);
 
         x = c->frame->area.x;
@@ -244,7 +244,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = c->frame->area.width;
         h = wb;
 
-        XMoveResizeWindow(obt_display, focus_indicator.bottom.win,
+        XMoveResizeWindow(obt_display, focus_indicator.bottom.window,
                           x, y, w, h);
         a_focus_indicator->texture[0].data.lineart.x1 = 0;
         a_focus_indicator->texture[0].data.lineart.y1 = 0;
@@ -262,13 +262,13 @@ void focus_cycle_draw_indicator(ObClient *c)
         a_focus_indicator->texture[3].data.lineart.y1 = 0;
         a_focus_indicator->texture[3].data.lineart.x2 = w - wr;
         a_focus_indicator->texture[3].data.lineart.y2 = 0;
-        RrPaint(a_focus_indicator, focus_indicator.bottom.win,
+        RrPaint(a_focus_indicator, focus_indicator.bottom.window,
                 w, h);
 
-        XMapWindow(obt_display, focus_indicator.top.win);
-        XMapWindow(obt_display, focus_indicator.left.win);
-        XMapWindow(obt_display, focus_indicator.right.win);
-        XMapWindow(obt_display, focus_indicator.bottom.win);
+        XMapWindow(obt_display, focus_indicator.top.window);
+        XMapWindow(obt_display, focus_indicator.left.window);
+        XMapWindow(obt_display, focus_indicator.right.window);
+        XMapWindow(obt_display, focus_indicator.bottom.window);
 
         visible = TRUE;
     }
index 98998c88950396dca7de6b23473adde1bf5f9ef1..e4cf5c10cf95459bebcee1a2593fd626e305d6f8 100644 (file)
@@ -98,7 +98,7 @@ void focus_cycle_popup_startup(gboolean reconfig)
 
     single_popup = icon_popup_new();
 
-    popup.obwin.type = Window_Internal;
+    popup.obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
     popup.a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
     popup.a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
     popup.a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
@@ -127,16 +127,16 @@ void focus_cycle_popup_startup(gboolean reconfig)
 
     XMapWindow(obt_display, popup.text);
 
-    stacking_add(INTERNAL_AS_WINDOW(&popup));
-    g_hash_table_insert(window_map, &popup.bg, &popup);
+    stacking_add(INTERNALWINDOW_AS_WINDOW(&popup));
+    window_add(&popup.bg, INTERNALWINDOW_AS_WINDOW(&popup));
 }
 
 void focus_cycle_popup_shutdown(gboolean reconfig)
 {
     icon_popup_free(single_popup);
 
-    g_hash_table_remove(window_map, &popup.bg);
-    stacking_remove(INTERNAL_AS_WINDOW(&popup));
+    window_remove(popup.bg);
+    stacking_remove(INTERNALWINDOW_AS_WINDOW(&popup));
 
     while(popup.targets) {
         ObFocusCyclePopupTarget *t = popup.targets->data;
index e598b31736c31fac7f85a237e33a6c7a77a3849f..5b7ecac61276c148399cd8714119ba0190ccd76d 100644 (file)
@@ -999,51 +999,51 @@ void frame_grab_client(ObFrame *self)
     XSelectInput(obt_display, self->window, FRAME_EVENTMASK);
 
     /* 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->backback, self->client);
-    g_hash_table_insert(window_map, &self->backfront, 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->innerblb, self->client);
-    g_hash_table_insert(window_map, &self->innerbll, self->client);
-    g_hash_table_insert(window_map, &self->innerbrb, self->client);
-    g_hash_table_insert(window_map, &self->innerbrr, 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);
-    g_hash_table_insert(window_map, &self->close, self->client);
-    g_hash_table_insert(window_map, &self->desk, self->client);
-    g_hash_table_insert(window_map, &self->shade, self->client);
-    g_hash_table_insert(window_map, &self->icon, self->client);
-    g_hash_table_insert(window_map, &self->iconify, self->client);
-    g_hash_table_insert(window_map, &self->handle, self->client);
-    g_hash_table_insert(window_map, &self->lgrip, self->client);
-    g_hash_table_insert(window_map, &self->rgrip, self->client);
-    g_hash_table_insert(window_map, &self->topresize, self->client);
-    g_hash_table_insert(window_map, &self->tltresize, self->client);
-    g_hash_table_insert(window_map, &self->tllresize, self->client);
-    g_hash_table_insert(window_map, &self->trtresize, self->client);
-    g_hash_table_insert(window_map, &self->trrresize, self->client);
-    g_hash_table_insert(window_map, &self->left, self->client);
-    g_hash_table_insert(window_map, &self->right, self->client);
-    g_hash_table_insert(window_map, &self->titleleft, self->client);
-    g_hash_table_insert(window_map, &self->titletop, self->client);
-    g_hash_table_insert(window_map, &self->titletopleft, self->client);
-    g_hash_table_insert(window_map, &self->titletopright, self->client);
-    g_hash_table_insert(window_map, &self->titleright, self->client);
-    g_hash_table_insert(window_map, &self->titlebottom, self->client);
-    g_hash_table_insert(window_map, &self->handleleft, self->client);
-    g_hash_table_insert(window_map, &self->handletop, self->client);
-    g_hash_table_insert(window_map, &self->handleright, self->client);
-    g_hash_table_insert(window_map, &self->handlebottom, self->client);
-    g_hash_table_insert(window_map, &self->lgripleft, self->client);
-    g_hash_table_insert(window_map, &self->lgriptop, self->client);
-    g_hash_table_insert(window_map, &self->lgripbottom, self->client);
-    g_hash_table_insert(window_map, &self->rgripright, self->client);
-    g_hash_table_insert(window_map, &self->rgriptop, self->client);
-    g_hash_table_insert(window_map, &self->rgripbottom, self->client);
+    window_add(&self->window, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->backback, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->backfront, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerleft, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innertop, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerright, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerbottom, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerblb, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerbll, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerbrb, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->innerbrr, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->title, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->label, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->max, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->close, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->desk, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->shade, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->icon, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->iconify, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->handle, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->lgrip, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->rgrip, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->topresize, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->tltresize, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->tllresize, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->trtresize, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->trrresize, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->left, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->right, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titleleft, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titletop, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titletopleft, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titletopright, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titleright, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->titlebottom, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->handleleft, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->handletop, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->handleright, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->handlebottom, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->lgripleft, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->lgriptop, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->lgripbottom, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->rgripright, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->rgriptop, CLIENT_AS_WINDOW(self->client));
+    window_add(&self->rgripbottom, CLIENT_AS_WINDOW(self->client));
 }
 
 void frame_release_client(ObFrame *self)
@@ -1083,51 +1083,51 @@ 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->backback);
-    g_hash_table_remove(window_map, &self->backfront);
-    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->innerblb);
-    g_hash_table_remove(window_map, &self->innerbll);
-    g_hash_table_remove(window_map, &self->innerbrb);
-    g_hash_table_remove(window_map, &self->innerbrr);
-    g_hash_table_remove(window_map, &self->title);
-    g_hash_table_remove(window_map, &self->label);
-    g_hash_table_remove(window_map, &self->max);
-    g_hash_table_remove(window_map, &self->close);
-    g_hash_table_remove(window_map, &self->desk);
-    g_hash_table_remove(window_map, &self->shade);
-    g_hash_table_remove(window_map, &self->icon);
-    g_hash_table_remove(window_map, &self->iconify);
-    g_hash_table_remove(window_map, &self->handle);
-    g_hash_table_remove(window_map, &self->lgrip);
-    g_hash_table_remove(window_map, &self->rgrip);
-    g_hash_table_remove(window_map, &self->topresize);
-    g_hash_table_remove(window_map, &self->tltresize);
-    g_hash_table_remove(window_map, &self->tllresize);
-    g_hash_table_remove(window_map, &self->trtresize);
-    g_hash_table_remove(window_map, &self->trrresize);
-    g_hash_table_remove(window_map, &self->left);
-    g_hash_table_remove(window_map, &self->right);
-    g_hash_table_remove(window_map, &self->titleleft);
-    g_hash_table_remove(window_map, &self->titletop);
-    g_hash_table_remove(window_map, &self->titletopleft);
-    g_hash_table_remove(window_map, &self->titletopright);
-    g_hash_table_remove(window_map, &self->titleright);
-    g_hash_table_remove(window_map, &self->titlebottom);
-    g_hash_table_remove(window_map, &self->handleleft);
-    g_hash_table_remove(window_map, &self->handletop);
-    g_hash_table_remove(window_map, &self->handleright);
-    g_hash_table_remove(window_map, &self->handlebottom);
-    g_hash_table_remove(window_map, &self->lgripleft);
-    g_hash_table_remove(window_map, &self->lgriptop);
-    g_hash_table_remove(window_map, &self->lgripbottom);
-    g_hash_table_remove(window_map, &self->rgripright);
-    g_hash_table_remove(window_map, &self->rgriptop);
-    g_hash_table_remove(window_map, &self->rgripbottom);
+    window_remove(self->window);
+    window_remove(self->backback);
+    window_remove(self->backfront);
+    window_remove(self->innerleft);
+    window_remove(self->innertop);
+    window_remove(self->innerright);
+    window_remove(self->innerbottom);
+    window_remove(self->innerblb);
+    window_remove(self->innerbll);
+    window_remove(self->innerbrb);
+    window_remove(self->innerbrr);
+    window_remove(self->title);
+    window_remove(self->label);
+    window_remove(self->max);
+    window_remove(self->close);
+    window_remove(self->desk);
+    window_remove(self->shade);
+    window_remove(self->icon);
+    window_remove(self->iconify);
+    window_remove(self->handle);
+    window_remove(self->lgrip);
+    window_remove(self->rgrip);
+    window_remove(self->topresize);
+    window_remove(self->tltresize);
+    window_remove(self->tllresize);
+    window_remove(self->trtresize);
+    window_remove(self->trrresize);
+    window_remove(self->left);
+    window_remove(self->right);
+    window_remove(self->titleleft);
+    window_remove(self->titletop);
+    window_remove(self->titletopleft);
+    window_remove(self->titletopright);
+    window_remove(self->titleright);
+    window_remove(self->titlebottom);
+    window_remove(self->handleleft);
+    window_remove(self->handletop);
+    window_remove(self->handleright);
+    window_remove(self->handlebottom);
+    window_remove(self->lgripleft);
+    window_remove(self->lgriptop);
+    window_remove(self->lgripbottom);
+    window_remove(self->rgripright);
+    window_remove(self->rgriptop);
+    window_remove(self->rgripbottom);
 
     obt_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, TRUE);
 }
index f8f0a6bcd3cf1898492e7a5b5e97e431bf0f6f1b..2abb82c68a0600515080b6b3321f2a208dad8e48 100644 (file)
@@ -77,7 +77,7 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client)
     XSetWindowAttributes attr;
 
     self = g_new0(ObMenuFrame, 1);
-    self->type = Window_Menu;
+    self->type = OB_WINDOW_CLASS_MENUFRAME;
     self->menu = menu;
     self->selected = NULL;
     self->client = client;
@@ -95,7 +95,8 @@ ObMenuFrame* menu_frame_new(ObMenu *menu, guint show_from, ObClient *client)
     self->a_title = RrAppearanceCopy(ob_rr_theme->a_menu_title);
     self->a_items = RrAppearanceCopy(ob_rr_theme->a_menu);
 
-    stacking_add(MENU_AS_WINDOW(self));
+    window_add(&self->window, MENUFRAME_AS_WINDOW(self));
+    stacking_add(MENUFRAME_AS_WINDOW(self));
 
     return self;
 }
@@ -108,7 +109,8 @@ void menu_frame_free(ObMenuFrame *self)
             self->entries = g_list_delete_link(self->entries, self->entries);
         }
 
-        stacking_remove(MENU_AS_WINDOW(self));
+        stacking_remove(MENUFRAME_AS_WINDOW(self));
+        window_remove(self->window);
 
         XDestroyWindow(obt_display, self->window);
 
@@ -179,6 +181,8 @@ static ObMenuEntryFrame* menu_entry_frame_new(ObMenuEntry *entry,
     self->a_text_title =
         RrAppearanceCopy(ob_rr_theme->a_menu_text_title);
 
+    window_add(&self->window, MENUFRAME_AS_WINDOW(self->frame));
+
     return self;
 }
 
@@ -187,6 +191,8 @@ static void menu_entry_frame_free(ObMenuEntryFrame *self)
     if (self) {
         menu_entry_unref(self->entry);
 
+        window_remove(self->window);
+
         XDestroyWindow(obt_display, self->text);
         XDestroyWindow(obt_display, self->window);
         g_hash_table_remove(menu_frame_map, &self->text);
index e2897e7d4e250a43d678333aad7bca5241424d1c..ed64682361f726d15ea9405cd5dfc8e8a1b441fb 100644 (file)
@@ -302,8 +302,7 @@ gint main(gint argc, gchar **argv)
                 /* focus what was focused if a wm was already running */
                 if (OBT_PROP_GET32(RootWindow(obt_display, ob_screen),
                                    NET_ACTIVE_WINDOW, WINDOW, &xid) &&
-                    (w = g_hash_table_lookup(window_map, &xid)) &&
-                    WINDOW_IS_CLIENT(w))
+                    (w = window_find(xid)) && WINDOW_IS_CLIENT(w))
                 {
                     client_focus(WINDOW_AS_CLIENT(w));
                 }
index 13465d3f050b481303093f1ea805e9102ee5f326..21beda58faccbd04d4c7c17d44f2de0c1c466abe 100644 (file)
@@ -33,7 +33,7 @@ ObPopup *popup_new(void)
     XSetWindowAttributes attrib;
     ObPopup *self = g_new0(ObPopup, 1);
 
-    self->obwin.type = Window_Internal;
+    self->obwin.type = OB_WINDOW_CLASS_INTERNALWINDOW;
     self->gravity = NorthWestGravity;
     self->x = self->y = self->textw = self->h = 0;
     self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
@@ -56,8 +56,8 @@ ObPopup *popup_new(void)
 
     XMapWindow(obt_display, self->text);
 
-    stacking_add(INTERNAL_AS_WINDOW(self));
-    g_hash_table_insert(window_map, &self->bg, self);
+    stacking_add(INTERNALWINDOW_AS_WINDOW(self));
+    window_add(&self->bg, INTERNALWINDOW_AS_WINDOW(self));
     return self;
 }
 
@@ -68,7 +68,7 @@ void popup_free(ObPopup *self)
         XDestroyWindow(obt_display, self->text);
         RrAppearanceFree(self->a_bg);
         RrAppearanceFree(self->a_text);
-        g_hash_table_remove(window_map, &self->bg);
+        window_remove(self->bg);
         stacking_remove(self);
         g_free(self);
     }
@@ -141,7 +141,7 @@ static gboolean popup_show_timeout(gpointer data)
     ObPopup *self = data;
 
     XMapWindow(obt_display, self->bg);
-    stacking_raise(INTERNAL_AS_WINDOW(self));
+    stacking_raise(INTERNALWINDOW_AS_WINDOW(self));
     self->mapped = TRUE;
     self->delay_mapped = FALSE;
 
index c5e6a4ea9c81eb63e89e1806b1ea690c5dc2cbe6..32f1ea52ca0aae9d9b84ee6ab9c3773946959349 100644 (file)
@@ -23,7 +23,7 @@
 #include "client.h"
 #include "frame.h"
 
-GHashTable *window_map;
+static GHashTable *window_map;
 
 static guint window_hash(Window *w) { return *w; }
 static gboolean window_comp(Window *w1, Window *w2) { return *w1 == *w2; }
@@ -46,18 +46,14 @@ void window_shutdown(gboolean reconfig)
 Window window_top(ObWindow *self)
 {
     switch (self->type) {
-    case Window_Menu:
-        return ((ObMenuFrame*)self)->window;
-    case Window_Dock:
-        return ((ObDock*)self)->frame;
-    case Window_DockApp:
-        /* not to be used for stacking */
-        g_assert_not_reached();
-        break;
-    case Window_Client:
-        return ((ObClient*)self)->frame->window;
-    case Window_Internal:
-        return ((InternalWindow*)self)->win;
+    case OB_WINDOW_CLASS_MENUFRAME:
+        return WINDOW_AS_MENUFRAME(self)->window;
+    case OB_WINDOW_CLASS_DOCK:
+        return WINDOW_AS_DOCK(self)->frame;
+    case OB_WINDOW_CLASS_CLIENT:
+        return WINDOW_AS_CLIENT(self)->frame->window;
+    case OB_WINDOW_CLASS_INTERNALWINDOW:
+        return WINDOW_AS_INTERNALWINDOW(self)->window;
     }
     g_assert_not_reached();
     return None;
@@ -66,19 +62,33 @@ Window window_top(ObWindow *self)
 ObStackingLayer window_layer(ObWindow *self)
 {
     switch (self->type) {
-    case Window_Menu:
-        return OB_STACKING_LAYER_INTERNAL;
-    case Window_Dock:
+    case OB_WINDOW_CLASS_DOCK:
         return config_dock_layer;
-    case Window_DockApp:
-        /* not to be used for stacking */
-        g_assert_not_reached();
-        break;
-    case Window_Client:
+    case OB_WINDOW_CLASS_CLIENT:
         return ((ObClient*)self)->layer;
-    case Window_Internal:
+    case OB_WINDOW_CLASS_MENUFRAME:
+    case OB_WINDOW_CLASS_INTERNALWINDOW:
         return OB_STACKING_LAYER_INTERNAL;
     }
     g_assert_not_reached();
     return None;
 }
+
+ObWindow* window_find(Window xwin)
+{
+    g_assert(xwin != None);
+    return g_hash_table_lookup(window_map, &xwin);
+}
+
+void window_add(Window *xwin, ObWindow *win)
+{
+    g_assert(xwin != NULL);
+    g_assert(win != NULL);
+    g_hash_table_insert(window_map, xwin, win);
+}
+
+void window_remove(Window xwin)
+{
+    g_assert(xwin != None);
+    g_hash_table_remove(window_map, &xwin);
+}
index a172cfce62f10664bcb708e8deb0d9b4464ff3b8..ccd8def211bca0b148f3e66706937ecb3dac7b22 100644 (file)
@@ -28,55 +28,56 @@ typedef struct _ObWindow         ObWindow;
 typedef struct _ObInternalWindow ObInternalWindow;
 
 typedef enum {
-    Window_Menu,
-    Window_Dock,
-    Window_DockApp, /* used for events but not stacking */
-    Window_Client,
-    Window_Internal /* used for stacking but not events (except to filter
-                       events on the root window) */
+    OB_WINDOW_CLASS_MENUFRAME,
+    OB_WINDOW_CLASS_DOCK,
+    OB_WINDOW_CLASS_CLIENT,
+    OB_WINDOW_CLASS_INTERNALWINDOW
 } Window_InternalType;
 
-struct _ObWindow
-{
+/* In order to be an ObWindow, you need to make this struct the top of your
+   struct */
+struct _ObWindow {
     Window_InternalType type;
 };
 
-/* Wrapper for internal stuff. If its struct matches this then it can be used
-   as an ObWindow */
-typedef struct InternalWindow {
-    ObWindow obwin;
-    Window win;
-} InternalWindow;
-
-#define WINDOW_IS_MENU(win) (((ObWindow*)win)->type == Window_Menu)
-#define WINDOW_IS_DOCK(win) (((ObWindow*)win)->type == Window_Dock)
-#define WINDOW_IS_DOCKAPP(win) (((ObWindow*)win)->type == Window_DockApp)
-#define WINDOW_IS_CLIENT(win) (((ObWindow*)win)->type == Window_Client)
-#define WINDOW_IS_INTERNAL(win) (((ObWindow*)win)->type == Window_Internal)
+#define WINDOW_IS_MENUFRAME(win) \
+    (((ObWindow*)win)->type == OB_WINDOW_CLASS_MENUFRAME)
+#define WINDOW_IS_DOCK(win) \
+    (((ObWindow*)win)->type == OB_WINDOW_CLASS_DOCK)
+#define WINDOW_IS_CLIENT(win) \
+    (((ObWindow*)win)->type == OB_WINDOW_CLASS_CLIENT)
+#define WINDOW_IS_INTERNALWINDOW(win) \
+    (((ObWindow*)win)->type == OB_WINDOW_CLASS_INTERNALWINDOW)
 
 struct _ObMenu;
 struct _ObDock;
 struct _ObDockApp;
 struct _ObClient;
 
-#define WINDOW_AS_MENU(win) ((struct _ObMenuFrame*)win)
+#define WINDOW_AS_MENUFRAME(win) ((struct _ObMenuFrame*)win)
 #define WINDOW_AS_DOCK(win) ((struct _ObDock*)win)
-#define WINDOW_AS_DOCKAPP(win) ((struct _ObDockApp*)win)
 #define WINDOW_AS_CLIENT(win) ((struct _ObClient*)win)
-#define WINDOW_AS_INTERNAL(win) ((struct InternalWindow*)win)
+#define WINDOW_AS_INTERNALWINDOW(win) ((struct _ObInternalWindow*)win)
 
-#define MENU_AS_WINDOW(menu) ((ObWindow*)menu)
+#define MENUFRAME_AS_WINDOW(menu) ((ObWindow*)menu)
 #define DOCK_AS_WINDOW(dock) ((ObWindow*)dock)
-#define DOCKAPP_AS_WINDOW(dockapp) ((ObWindow*)dockapp)
 #define CLIENT_AS_WINDOW(client) ((ObWindow*)client)
-#define INTERNAL_AS_WINDOW(intern) ((ObWindow*)intern)
+#define INTERNALWINDOW_AS_WINDOW(intern) ((ObWindow*)intern)
 
-extern GHashTable *window_map;
-
-void window_startup(gboolean reconfig);
+void window_startup (gboolean reconfig);
 void window_shutdown(gboolean reconfig);
 
-Window window_top(ObWindow *self);
+Window          window_top  (ObWindow *self);
 ObStackingLayer window_layer(ObWindow *self);
 
+ObWindow* window_find  (Window xwin);
+void      window_add   (Window *xwin, ObWindow *win);
+void      window_remove(Window xwin);
+
+/* Internal openbox-owned windows like the alt-tab popup */
+struct _ObInternalWindow {
+    ObWindow obwin;
+    Window window;
+};
+
 #endif
This page took 0.065906 seconds and 4 git commands to generate.