]> Dogcows Code - chaz/openbox/commitdiff
supply focus_cycle_draw_indicator which draws/moves/resizes the focus cycling indicator
authorDana Jansens <danakj@orodu.net>
Thu, 9 Oct 2003 19:17:51 +0000 (19:17 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 9 Oct 2003 19:17:51 +0000 (19:17 +0000)
openbox/focus.c
openbox/focus.h

index 0140226ed5509c42b430f6834ea4b1e64e3e4a6b..44f8edb213c89cef51313efa7509ce133643c231 100644 (file)
@@ -362,6 +362,132 @@ static void popup_cycle(ObClient *c, gboolean show)
     }
 }
 
+void focus_cycle_draw_indicator()
+{
+    if (!focus_cycle_target) {
+        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);
+    } else {
+        /*
+          if (focus_cycle_target)
+              frame_adjust_focus(focus_cycle_target->frame, FALSE);
+          frame_adjust_focus(focus_cycle_target->frame, TRUE);
+        */
+        int x, y, w, h;
+        int wt, wl, wr, wb;
+
+        wt = wl = wr = wb = MAX(5, ob_rr_theme->handle_height);
+
+        x = focus_cycle_target->frame->area.x;
+        y = focus_cycle_target->frame->area.y;
+        w = focus_cycle_target->frame->area.width;
+        h = wt;
+
+        XMoveResizeWindow(ob_display, focus_indicator.top.win,
+                          x, y, w, h);
+        a_focus_indicator->texture[0].data.lineart.x1 = 0;
+        a_focus_indicator->texture[0].data.lineart.y1 = h-1;
+        a_focus_indicator->texture[0].data.lineart.x2 = 0;
+        a_focus_indicator->texture[0].data.lineart.y2 = 0;
+        a_focus_indicator->texture[1].data.lineart.x1 = 0;
+        a_focus_indicator->texture[1].data.lineart.y1 = 0;
+        a_focus_indicator->texture[1].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[1].data.lineart.y2 = 0;
+        a_focus_indicator->texture[2].data.lineart.x1 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y1 = 0;
+        a_focus_indicator->texture[2].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[3].data.lineart.x1 = (wl-1);
+        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,
+                w, h);
+
+        x = focus_cycle_target->frame->area.x;
+        y = focus_cycle_target->frame->area.y;
+        w = wl;
+        h = focus_cycle_target->frame->area.height;
+
+        XMoveResizeWindow(ob_display, focus_indicator.left.win,
+                          x, y, w, h);
+        a_focus_indicator->texture[0].data.lineart.x1 = w-1;
+        a_focus_indicator->texture[0].data.lineart.y1 = 0;
+        a_focus_indicator->texture[0].data.lineart.x2 = 0;
+        a_focus_indicator->texture[0].data.lineart.y2 = 0;
+        a_focus_indicator->texture[1].data.lineart.x1 = 0;
+        a_focus_indicator->texture[1].data.lineart.y1 = 0;
+        a_focus_indicator->texture[1].data.lineart.x2 = 0;
+        a_focus_indicator->texture[1].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x1 = 0;
+        a_focus_indicator->texture[2].data.lineart.y1 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[3].data.lineart.x1 = w-1;
+        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,
+                w, h);
+
+        x = focus_cycle_target->frame->area.x +
+            focus_cycle_target->frame->area.width - wr;
+        y = focus_cycle_target->frame->area.y;
+        w = wr;
+        h = focus_cycle_target->frame->area.height ;
+
+        XMoveResizeWindow(ob_display, focus_indicator.right.win,
+                          x, y, w, h);
+        a_focus_indicator->texture[0].data.lineart.x1 = 0;
+        a_focus_indicator->texture[0].data.lineart.y1 = 0;
+        a_focus_indicator->texture[0].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[0].data.lineart.y2 = 0;
+        a_focus_indicator->texture[1].data.lineart.x1 = w-1;
+        a_focus_indicator->texture[1].data.lineart.y1 = 0;
+        a_focus_indicator->texture[1].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[1].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x1 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y1 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x2 = 0;
+        a_focus_indicator->texture[2].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[3].data.lineart.x1 = 0;
+        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,
+                w, h);
+
+        x = focus_cycle_target->frame->area.x;
+        y = focus_cycle_target->frame->area.y +
+            focus_cycle_target->frame->area.height - wb;
+        w = focus_cycle_target->frame->area.width;
+        h = wb;
+
+        XMoveResizeWindow(ob_display, focus_indicator.bottom.win,
+                          x, y, w, h);
+        a_focus_indicator->texture[0].data.lineart.x1 = 0;
+        a_focus_indicator->texture[0].data.lineart.y1 = 0;
+        a_focus_indicator->texture[0].data.lineart.x2 = 0;
+        a_focus_indicator->texture[0].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[1].data.lineart.x1 = 0;
+        a_focus_indicator->texture[1].data.lineart.y1 = h-1;
+        a_focus_indicator->texture[1].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[1].data.lineart.y2 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x1 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y1 = h-1;
+        a_focus_indicator->texture[2].data.lineart.x2 = w-1;
+        a_focus_indicator->texture[2].data.lineart.y2 = 0;
+        a_focus_indicator->texture[3].data.lineart.x1 = wl-1;
+        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,
+                w, h);
+    }
+}
+
 static gboolean valid_focus_target(ObClient *ft)
 {
     /* we don't use client_can_focus here, because that doesn't let you
@@ -421,132 +547,10 @@ void focus_cycle(gboolean forward, gboolean linear,
         ft = it->data;
         if (valid_focus_target(ft)) {
             if (ft != focus_cycle_target) { /* prevents flicker */
-                /*
-                if (focus_cycle_target)
-                    frame_adjust_focus(focus_cycle_target->frame, FALSE);
-                */
                 focus_cycle_target = ft;
-                /*
-                frame_adjust_focus(focus_cycle_target->frame, TRUE);
-                */
-                {
-                    int x, y, w, h;
-                    int wt, wl, wr, wb;
-
-                    wt = wl = wr = wb = MAX(5, ob_rr_theme->handle_height);
-
-                    x = focus_cycle_target->frame->area.x;
-                    y = focus_cycle_target->frame->area.y;
-                    w = focus_cycle_target->frame->area.width;
-                    h = wt;
-
-                    XMoveResizeWindow(ob_display, focus_indicator.top.win,
-                                      x, y, w, h);
-                    a_focus_indicator->texture[0].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y1 = h-1;
-                    a_focus_indicator->texture[0].data.lineart.x2 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y2 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[1].data.lineart.y2 = 0;
-                    a_focus_indicator->texture[2].data.lineart.x1 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[2].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[3].data.lineart.x1 = (wl-1);
-                    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,
-                            w, h);
-
-                    x = focus_cycle_target->frame->area.x;
-                    y = focus_cycle_target->frame->area.y;
-                    w = wl;
-                    h = focus_cycle_target->frame->area.height;
-
-                    XMoveResizeWindow(ob_display, focus_indicator.left.win,
-                                      x, y, w, h);
-                    a_focus_indicator->texture[0].data.lineart.x1 = w-1;
-                    a_focus_indicator->texture[0].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.x2 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y2 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x2 = 0;
-                    a_focus_indicator->texture[1].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[2].data.lineart.y1 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[3].data.lineart.x1 = w-1;
-                    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,
-                            w, h);
-
-                    x = focus_cycle_target->frame->area.x +
-                        focus_cycle_target->frame->area.width - wr;
-                    y = focus_cycle_target->frame->area.y;
-                    w = wr;
-                    h = focus_cycle_target->frame->area.height ;
-
-                    XMoveResizeWindow(ob_display, focus_indicator.right.win,
-                                      x, y, w, h);
-                    a_focus_indicator->texture[0].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[0].data.lineart.y2 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x1 = w-1;
-                    a_focus_indicator->texture[1].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[1].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x1 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y1 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x2 = 0;
-                    a_focus_indicator->texture[2].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[3].data.lineart.x1 = 0;
-                    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,
-                            w, h);
-
-                    x = focus_cycle_target->frame->area.x;
-                    y = focus_cycle_target->frame->area.y +
-                        focus_cycle_target->frame->area.height - wb;
-                    w = focus_cycle_target->frame->area.width;
-                    h = wb;
-
-                    XMoveResizeWindow(ob_display, focus_indicator.bottom.win,
-                                      x, y, w, h);
-                    a_focus_indicator->texture[0].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y1 = 0;
-                    a_focus_indicator->texture[0].data.lineart.x2 = 0;
-                    a_focus_indicator->texture[0].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[1].data.lineart.x1 = 0;
-                    a_focus_indicator->texture[1].data.lineart.y1 = h-1;
-                    a_focus_indicator->texture[1].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[1].data.lineart.y2 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x1 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y1 = h-1;
-                    a_focus_indicator->texture[2].data.lineart.x2 = w-1;
-                    a_focus_indicator->texture[2].data.lineart.y2 = 0;
-                    a_focus_indicator->texture[3].data.lineart.x1 = wl-1;
-                    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,
-                            w, h);
-                }
+                focus_cycle_draw_indicator();
             }
             popup_cycle(ft, dialog);
-            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);
             return;
         }
     } while (it != start);
@@ -555,17 +559,13 @@ done_cycle:
     if (done && focus_cycle_target)
         client_activate(focus_cycle_target, FALSE);
 
-    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);
-
     t = NULL;
     first = NULL;
     focus_cycle_target = NULL;
     g_list_free(order);
     order = NULL;
 
+    focus_cycle_draw_indicator();
     popup_cycle(ft, FALSE);
 
     return;
index f60ff61aa53811067f46392d65df2f20dde2e410..4a3f0b1a3c4fa2889514acdd19d68680970813f6 100644 (file)
@@ -61,6 +61,7 @@ void focus_cycle(gboolean forward, gboolean linear,
                  gboolean dialog, gboolean done, gboolean cancel);
 void focus_directional_cycle(ObDirection dir,
                              gboolean dialog, gboolean done, gboolean cancel);
+void focus_cycle_draw_indicator();
 
 /*! Add a new client into the focus order */
 void focus_order_add_new(struct _ObClient *c);
This page took 0.030928 seconds and 4 git commands to generate.