]> Dogcows Code - chaz/openbox/blobdiff - openbox/focus_cycle_popup.c
Redraw the focus cycle popup when the list of focusable windows changes, rather than...
[chaz/openbox] / openbox / focus_cycle_popup.c
index df3558dff5110e59e91f3cb562cd8ed8be614af3..aff84579de7187eb86053fe544b92e7ac06566e7 100644 (file)
@@ -185,7 +185,8 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets,
                                iconic_windows,
                                all_desktops,
                                dock_windows,
-                               desktop_windows))
+                               desktop_windows,
+                               FALSE))
         {
             gchar *text = popup_get_name(ft);
 
@@ -216,6 +217,22 @@ static void popup_setup(ObFocusCyclePopup *p, gboolean create_targets,
     p->maxtextw = maxwidth;
 }
 
+static void popup_cleanup(void)
+{
+    while(popup.targets) {
+        ObFocusCyclePopupTarget *t = popup.targets->data;
+
+        RrImageUnref(t->icon);
+        g_free(t->text);
+        XDestroyWindow(ob_display, t->win);
+        g_free(t);
+
+        popup.targets = g_list_delete_link(popup.targets, popup.targets);
+    }
+    popup.n_targets = 0;
+    popup.last_target = NULL;
+}
+
 static gchar *popup_get_name(ObClient *c)
 {
     ObClient *p;
@@ -260,7 +277,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c)
     const ObFocusCyclePopupTarget *newtarget;
     gint newtargetx, newtargety;
 
-    screen_area = screen_physical_area_active();
+    screen_area = screen_physical_area_primary(FALSE);
 
     /* get the outside margins */
     RrMargins(p->a_bg, &ml, &mt, &mr, &mb);
@@ -478,18 +495,7 @@ void focus_cycle_popup_hide(void)
 
     popup.mapped = FALSE;
 
-    while(popup.targets) {
-        ObFocusCyclePopupTarget *t = popup.targets->data;
-
-        RrImageUnref(t->icon);
-        g_free(t->text);
-        XDestroyWindow(ob_display, t->win);
-        g_free(t);
-
-        popup.targets = g_list_delete_link(popup.targets, popup.targets);
-    }
-    popup.n_targets = 0;
-    popup.last_target = NULL;
+    popup_cleanup();
 
     g_free(popup.hilite_rgba);
     popup.hilite_rgba = NULL;
@@ -514,7 +520,7 @@ void focus_cycle_popup_single_show(struct _ObClient *c,
         g_assert(popup.targets == NULL);
 
         /* position the popup */
-        a = screen_physical_area_active();
+        a = screen_physical_area_primary(FALSE);
         icon_popup_position(single_popup, CenterGravity,
                             a->x + a->width / 2, a->y + a->height / 2);
         icon_popup_height(single_popup, POPUP_HEIGHT);
@@ -534,3 +540,55 @@ void focus_cycle_popup_single_hide(void)
 {
     icon_popup_hide(single_popup);
 }
+
+GList* focus_cycle_popup_is_showing(ObClient *client)
+{
+    if (popup.mapped) {
+        GList *it;
+
+        for (it = popup.targets; it; it = g_list_next(it)) {
+            ObFocusCyclePopupTarget *t = it->data;
+            if (t->client == client)
+                return it;
+        }
+    }
+    return NULL;
+}
+
+ObClient* focus_cycle_popup_revert(ObClient *target)
+{
+    GList *it;
+
+    if (!popup.mapped) return NULL;
+
+    for (it = popup.targets; it; it = g_list_next(it)) {
+        ObFocusCyclePopupTarget *t = it->data;
+        if (t->client == target) {
+            if (it->prev)
+                return ((ObFocusCyclePopupTarget*)it->prev->data)->client;
+            else if (it->next)
+                return ((ObFocusCyclePopupTarget*)it->next->data)->client;
+            else
+                return NULL;
+        }
+    }
+    g_assert_not_reached();
+}
+
+void focus_cycle_popup_refresh(ObClient *target,
+                               gboolean iconic_windows,
+                               gboolean all_desktops,
+                               gboolean dock_windows,
+                               gboolean desktop_windows)
+{
+    if (!popup.mapped) return;
+
+    popup_cleanup();
+    popup_setup(&popup, TRUE, iconic_windows, all_desktops,
+                dock_windows, desktop_windows);
+
+    popup.mapped = FALSE;
+    popup_render(&popup, target);
+    XFlush(ob_display);
+    popup.mapped = TRUE;
+}
This page took 0.024594 seconds and 4 git commands to generate.