]> Dogcows Code - chaz/openbox/commitdiff
add a slight delay to the focus/desktop switch dialogs. so if you hit the key really...
authorDana Jansens <danakj@orodu.net>
Wed, 2 May 2007 00:59:07 +0000 (00:59 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 2 May 2007 00:59:07 +0000 (00:59 +0000)
make the keychain popup use the new delay popup facilities

openbox/focus.c
openbox/keyboard.c
openbox/popup.c
openbox/popup.h
openbox/screen.c

index c1d5147773aac2366b27f138648885a7f238e35b..aac6675e3a1fc7ccf18aaf0b64ce27bb822116cd 100644 (file)
@@ -318,10 +318,10 @@ static void popup_cycle(ObClient *c, gboolean show)
                                 (p->iconic ? p->icon_title : p->title),
                                 NULL);
             */
-        icon_popup_show(focus_cycle_popup,
-                        (title ? title :
-                         (c->iconic ? c->icon_title : c->title)),
-                        client_icon(p, 48, 48));
+        icon_popup_delay_show(focus_cycle_popup, G_USEC_PER_SEC/12,
+                              (title ? title :
+                               (c->iconic ? c->icon_title : c->title)),
+                              client_icon(p, 48, 48));
         g_free(title);
     }
 }
index c1151eb392eda2b8bb803c37390a08ae12148d63..1509f69f11a8dfe2c5acb6a0987796e47e6bbf4e 100644 (file)
@@ -75,14 +75,6 @@ static gboolean chain_timeout(gpointer data)
     return FALSE; /* don't repeat */
 }
 
-static gboolean popup_show_timeout(gpointer data)
-{
-    gchar *text = data;
-    popup_show(popup, text);
-
-    return FALSE; /* don't repeat */
-}
-
 static void set_curpos(KeyBindingTree *newpos)
 {
     grab_keys(FALSE);
@@ -103,19 +95,11 @@ static void set_curpos(KeyBindingTree *newpos)
         }
 
         popup_position(popup, NorthWestGravity, 10, 10);
-        if (popup->mapped) {
-            popup_show_timeout(text);
-            g_free(text);
-        } else {
-            ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
-            /* 1 second delay for the popup to show */
-            ob_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC,
-                                     popup_show_timeout, text,
-                                     g_direct_equal, g_free);
-        }
+        /* 1 second delay for the popup to show */
+        popup_delay_show(popup, G_USEC_PER_SEC, text);
+        g_free(text);
     } else {
         popup_hide(popup);
-        ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
     }
 }
 
@@ -362,7 +346,6 @@ void keyboard_shutdown(gboolean reconfig)
     interactive_states = NULL;
 
     ob_main_loop_timeout_remove(ob_main_loop, chain_timeout);
-    ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
 
     keyboard_unbind_all();
     set_curpos(NULL);
index 392aa9d164228b5b497c3ace11576c0286ed70a1..a3c94653dd9ed0f98ff02484e67a628ed7a80415 100644 (file)
 #include "stacking.h"
 #include "event.h"
 #include "screen.h"
+#include "mainloop.h"
 #include "render/render.h"
 #include "render/theme.h"
 
+static gboolean popup_show_timeout(gpointer data)
+{
+    ObPopup *self = data;
+    
+    XMapWindow(ob_display, self->bg);
+    stacking_raise(INTERNAL_AS_WINDOW(self));
+    self->mapped = TRUE;
+    self->delay_mapped = FALSE;
+
+    return FALSE; /* don't repeat */
+}
+
 ObPopup *popup_new(gboolean hasicon)
 {
     XSetWindowAttributes attrib;
@@ -128,7 +141,7 @@ void popup_set_text_align(ObPopup *self, RrJustify align)
     self->a_text->texture[0].data.text.justify = align;
 }
 
-void popup_show(ObPopup *self, gchar *text)
+void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
 {
     gint l, t, r, b;
     gint x, y, w, h;
@@ -230,10 +243,19 @@ void popup_show(ObPopup *self, gchar *text)
                             iconw, texth, self->draw_icon_data);
     }
 
+    /* do the actual showing */
     if (!self->mapped) {
-        XMapWindow(ob_display, self->bg);
-        stacking_raise(INTERNAL_AS_WINDOW(self));
-        self->mapped = TRUE;
+        if (usec) {
+            /* don't kill previous show timers */
+            if (!self->delay_mapped) {
+                ob_main_loop_timeout_add(ob_main_loop, usec,
+                                         popup_show_timeout, self,
+                                         g_direct_equal, NULL);
+                self->delay_mapped = TRUE;
+            }
+        } else {
+            popup_show_timeout(self);
+        }
     }
 }
 
@@ -245,6 +267,9 @@ void popup_hide(ObPopup *self)
 
         /* kill enter events cause by this unmapping */
         event_ignore_queued_enters();
+    } else if (self->delay_mapped) {
+        ob_main_loop_timeout_remove(ob_main_loop, popup_show_timeout);
+        self->delay_mapped = FALSE;
     }
 }
 
@@ -288,8 +313,8 @@ void icon_popup_free(ObIconPopup *self)
     }
 }
 
-void icon_popup_show(ObIconPopup *self,
-                     gchar *text, const ObClientIcon *icon)
+void icon_popup_delay_show(ObIconPopup *self, gulong usec,
+                           gchar *text, const ObClientIcon *icon)
 {
     if (icon) {
         self->a_icon->texture[0].type = RR_TEXTURE_RGBA;
@@ -299,7 +324,7 @@ void icon_popup_show(ObIconPopup *self,
     } else
         self->a_icon->texture[0].type = RR_TEXTURE_NONE;
 
-    popup_show(self->popup, text);
+    popup_delay_show(self->popup, usec, text);
 }
 
 static void pager_popup_draw_icon(gint px, gint py, gint w, gint h,
@@ -448,7 +473,8 @@ void pager_popup_free(ObPagerPopup *self)
     }
 }
 
-void pager_popup_show(ObPagerPopup *self, gchar *text, guint desk)
+void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
+                            gchar *text, guint desk)
 {
     guint i;
 
@@ -475,5 +501,5 @@ void pager_popup_show(ObPagerPopup *self, gchar *text, guint desk)
     self->desks = screen_num_desktops;
     self->curdesk = desk;
 
-    popup_show(self->popup, text);
+    popup_delay_show(self->popup, usec, text);
 }
index 3ce0b5ccf106b870345d32fab276efd91a68fed3..66e0fcab68fdc4738b83d757451261528e8e0db8 100644 (file)
@@ -48,6 +48,7 @@ struct _ObPopup
     gint w;
     gint h;
     gboolean mapped;
+    gboolean delay_mapped;
  
     void (*draw_icon)(gint x, gint y, gint w, gint h, gpointer data);
     gpointer draw_icon_data;
@@ -91,7 +92,8 @@ void popup_width_to_strings(ObPopup *self, gchar **strings, gint max);
 
 void popup_set_text_align(ObPopup *self, RrJustify align);
 
-void popup_show(ObPopup *self, gchar *text);
+#define popup_show(s, t) popup_delay_show((s),0,(t))
+void popup_delay_show(ObPopup *self, gulong usec, gchar *text);
 void popup_hide(ObPopup *self);
 
 RrAppearance *popup_icon_appearance(ObPopup *self);
@@ -100,8 +102,9 @@ RrAppearance *popup_icon_appearance(ObPopup *self);
 ObIconPopup *icon_popup_new();
 void icon_popup_free(ObIconPopup *self);
 
-void icon_popup_show(ObIconPopup *self,
-                     gchar *text, const struct _ObClientIcon *icon);
+#define icon_popup_show(s, t, i) icon_popup_delay_show((s),0,(t),(i))
+void icon_popup_delay_show(ObIconPopup *self, gulong usec,
+                           gchar *text, const struct _ObClientIcon *icon);
 #define icon_popup_hide(p) popup_hide((p)->popup)
 #define icon_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
 #define icon_popup_width(p, w) popup_width((p)->popup,(w))
@@ -115,7 +118,9 @@ void icon_popup_show(ObIconPopup *self,
 ObPagerPopup *pager_popup_new();
 void pager_popup_free(ObPagerPopup *self);
 
-void pager_popup_show(ObPagerPopup *self, gchar *text, guint desk);
+#define pager_popup_show(s, t, d) paper_popup_delay_show((s),0,(t),(d;2D))
+void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
+                            gchar *text, guint desk);
 #define pager_popup_hide(p) popup_hide((p)->popup)
 #define pager_popup_position(p, g, x, y) popup_position((p)->popup,(g),(x),(y))
 #define pager_popup_width(p, w) popup_width((p)->popup,(w))
index a302828baf1a7a293d87dc995e6efce2cbb687a5..25b7a46d0f918d49771e6f78bd0002bd15e44d89 100644 (file)
@@ -601,7 +601,8 @@ void screen_desktop_popup(guint d, gboolean show)
         pager_popup_width(desktop_cycle_popup, MAX(a->width/3, POPUP_WIDTH));
         pager_popup_height(desktop_cycle_popup, POPUP_HEIGHT);
 
-        pager_popup_show(desktop_cycle_popup, screen_desktop_names[d], d);
+        pager_popup_delay_show(desktop_cycle_popup, G_USEC_PER_SEC/12,
+                               screen_desktop_names[d], d);
     }
 }
 
This page took 0.03445 seconds and 4 git commands to generate.