add a slight delay to the focus/desktop switch dialogs. so if you hit the key really fast there is no flicker. of course if you hit it fast but not fast enough there is still flicker. is this cool or does this make it feel bad? i dunno. we'll see.. make the keychain popup use the new delay popup facilities
Dana Jansens danakj@orodu.net
5 files changed,
53 insertions(+),
38 deletions(-)
M
openbox/focus.c
→
openbox/focus.c
@@ -318,10 +318,10 @@ " - ",
(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); } }
M
openbox/keyboard.c
→
openbox/keyboard.c
@@ -75,14 +75,6 @@ keyboard_reset_chains(0);
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 @@ g_free(oldtext);
} 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 @@ g_slist_free(interactive_states);
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);
M
openbox/popup.c
→
openbox/popup.c
@@ -25,9 +25,22 @@ #include "client.h"
#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 @@ {
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 @@ t + ob_rr_theme->paddingy,
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 @@ self->mapped = FALSE;
/* 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 @@ g_free(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 @@ self->a_icon->texture[0].data.rgba.data = icon->data;
} 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 @@ g_free(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 @@
self->desks = screen_num_desktops; self->curdesk = desk; - popup_show(self->popup, text); + popup_delay_show(self->popup, usec, text); }
M
openbox/popup.h
→
openbox/popup.h
@@ -48,6 +48,7 @@ gint y;
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 @@
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 @@
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))
M
openbox/screen.c
→
openbox/screen.c
@@ -601,7 +601,8 @@ a->x + a->width / 2, a->y + a->height / 2);
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); } }