]> Dogcows Code - chaz/openbox/blobdiff - openbox/focus_cycle_indicator.c
make the window.h interface more consistent with the rest of openbox, hide the window...
[chaz/openbox] / openbox / focus_cycle_indicator.c
index 203a85ff92170c453e3549de246c6d81c218959b..2242b3d3d9e276bda481c65e2b473ed2604972d6 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "focus_cycle.h"
+#include "focus_cycle_indicator.h"
 #include "client.h"
 #include "openbox.h"
 #include "frame.h"
 
 #define FOCUS_INDICATOR_WIDTH 6
 
-struct
+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;
 static RrColor      *color_white;
+static gboolean      visible;
 
 static Window create_window(Window parent, gulong mask,
                             XSetWindowAttributes *attrib)
 {
-    return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0,
+    return XCreateWindow(obt_display, parent, 0, 0, 1, 1, 0,
                          RrDepth(ob_rr_inst), InputOutput,
                          RrVisual(ob_rr_inst), mask, attrib);
-                       
+
 }
 
 void focus_cycle_indicator_startup(gboolean reconfig)
 {
     XSetWindowAttributes attr;
 
+    visible = FALSE;
+
     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(ob_display, ob_screen);
-    focus_indicator.top.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    attr.background_pixel = BlackPixel(obt_display, ob_screen);
+    focus_indicator.top.window =
+        create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.left.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    focus_indicator.left.window =
+        create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.right.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    focus_indicator.right.window =
+        create_window(RootWindow(obt_display, ob_screen),
                       CWOverrideRedirect | CWBackPixel, &attr);
-    focus_indicator.bottom.win =
-        create_window(RootWindow(ob_display, ob_screen),
+    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));
+    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);
 
@@ -105,32 +117,40 @@ void focus_cycle_indicator_shutdown(gboolean reconfig)
 
     RrAppearanceFree(a_focus_indicator);
 
-    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));
+    window_remove(focus_indicator.top.window);
+    window_remove(focus_indicator.left.window);
+    window_remove(focus_indicator.right.window);
+    window_remove(focus_indicator.bottom.window);
 
-    XDestroyWindow(ob_display, focus_indicator.top.win);
-    XDestroyWindow(ob_display, focus_indicator.left.win);
-    XDestroyWindow(ob_display, focus_indicator.right.win);
-    XDestroyWindow(ob_display, focus_indicator.bottom.win);
+    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.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)
 {
-    if (!c) {
+    if (!c && visible) {
         gulong ignore_start;
 
         /* kill enter events cause by this unmapping */
         ignore_start = event_start_ignore_all_enters();
 
-        XUnmapWindow(ob_display, focus_indicator.top.win);
-        XUnmapWindow(ob_display, focus_indicator.left.win);
-        XUnmapWindow(ob_display, focus_indicator.right.win);
-        XUnmapWindow(ob_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);
-    } else {
+
+        visible = FALSE;
+    }
+    else if (c) {
         /*
           if (c)
               frame_adjust_focus(c->frame, FALSE);
@@ -146,7 +166,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = c->frame->area.width;
         h = wt;
 
-        XMoveResizeWindow(ob_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;
@@ -164,15 +184,15 @@ 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->area.x;
+        x = c->frame->area.x;
         y = c->frame->area.y;
         w = wl;
         h = c->frame->area.height;
 
-        XMoveResizeWindow(ob_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;
@@ -190,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;
@@ -198,7 +218,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = wr;
         h = c->frame->area.height ;
 
-        XMoveResizeWindow(ob_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;
@@ -216,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;
@@ -224,7 +244,7 @@ void focus_cycle_draw_indicator(ObClient *c)
         w = c->frame->area.width;
         h = wb;
 
-        XMoveResizeWindow(ob_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;
@@ -242,12 +262,14 @@ 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(ob_display, focus_indicator.top.win);
-        XMapWindow(ob_display, focus_indicator.left.win);
-        XMapWindow(ob_display, focus_indicator.right.win);
-        XMapWindow(ob_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;
     }
 }
This page took 0.029351 seconds and 4 git commands to generate.