From 40b5af1d60332d26e4e132714049fc9b6e5ab382 Mon Sep 17 00:00:00 2001 From: Benoit Gschwind Date: Fri, 22 Feb 2008 21:55:20 +0100 Subject: [PATCH] Flashing is now a part of obclient --- engines/default/plugin.c | 64 ++++++---------------------------------- engines/default/plugin.h | 7 ----- openbox/client.c | 57 +++++++++++++++++++++++++++++++++-- openbox/client.h | 11 +++++++ 4 files changed, 74 insertions(+), 65 deletions(-) diff --git a/engines/default/plugin.c b/engines/default/plugin.c index 168e5f26..faf30820 100644 --- a/engines/default/plugin.c +++ b/engines/default/plugin.c @@ -417,8 +417,7 @@ void frame_ungrab(gpointer _self, GHashTable * window_map) g_hash_table_remove(window_map, &self->rgriptop); g_hash_table_remove(window_map, &self->rgripbottom); - obt_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self, - TRUE); + } ObFrameContext frame_context(gpointer _self, Window win, gint x, gint y) @@ -594,26 +593,6 @@ void frame_unfocus(gpointer self) OBDEFAULTFRAME(self)->focused = FALSE; } -void frame_flash_start(gpointer _self) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - self->flash_on = self->focused; - - if (!self->flashing) - obt_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 0.6, - flash_timeout, self, g_direct_equal, flash_done); - g_get_current_time(&self->flash_end); - g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5); - - self->flashing = TRUE; -} - -void frame_flash_stop(gpointer _self) -{ - ObDefaultFrame * self = (ObDefaultFrame *) _self; - self->flashing = FALSE; -} - void frame_set_decorations(gpointer self, ObFrameDecorations d) { OBDEFAULTFRAME(self)->decorations = d; @@ -1293,37 +1272,6 @@ static gboolean is_button_present(ObDefaultFrame *_self, const gchar *lc, return FALSE; } -void flash_done(gpointer data) -{ - ObDefaultFrame *self = data; - - if (self->focused != self->flash_on) - frame_adjust_focus(self, self->focused); -} - -gboolean flash_timeout(gpointer data) -{ - ObDefaultFrame *self = data; - GTimeVal now; - - g_get_current_time(&now); - if (now.tv_sec > self->flash_end.tv_sec - || (now.tv_sec == self->flash_end.tv_sec && now.tv_usec - >= self->flash_end.tv_usec)) - self->flashing = FALSE; - - if (!self->flashing) - return FALSE; /* we are done */ - - self->flash_on = !self->flash_on; - if (!self->focused) { - frame_adjust_focus(self, self->flash_on); - self->focused = FALSE; - } - - return TRUE; /* go again */ -} - void layout_title(ObDefaultFrame * self) { gchar *lc; @@ -1630,8 +1578,8 @@ ObFrameEngine plugin = { frame_set_is_max_vert, /* */ frame_set_is_max_horz, /* */ frame_set_is_shaded, /* */ - frame_flash_start, /* */ - frame_flash_stop, /* */ + 0, //frame_flash_start, /* */ + 0, //frame_flash_stop, /* */ frame_set_decorations, /* */ frame_update_title, /* */ /* This give the window area */ @@ -1658,3 +1606,9 @@ ObFrameEngine * get_info() { return &plugin; } + +gboolean flash_timeout(gpointer data) +{ + return TRUE; +} + diff --git a/engines/default/plugin.h b/engines/default/plugin.h index b3627250..3cb46275 100644 --- a/engines/default/plugin.h +++ b/engines/default/plugin.h @@ -147,10 +147,6 @@ struct _ObDefaultFrame gboolean focused; gboolean need_render; - gboolean flashing; - gboolean flash_on; - GTimeVal flash_end; - GTimeVal iconify_animation_end; }; @@ -205,9 +201,6 @@ gboolean frame_is_visible(gpointer self); gboolean frame_is_max_horz(gpointer self); gboolean frame_is_max_vert(gpointer self); -void flash_done(gpointer data); -gboolean flash_timeout(gpointer data); - void layout_title(ObDefaultFrame *); void set_theme_statics(gpointer self); void free_theme_statics(gpointer self); diff --git a/openbox/client.c b/openbox/client.c index af27ec9a..03ce9cc6 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -817,7 +817,8 @@ void client_unmanage(ObClient *self) obt_display, ob_screen), self->area.x, self->area.y); } - frame_engine->frame_ungrab(self->frame, window_map); + frame_engine->frame_ungrab(self->frame, window_map); + obt_main_loop_timeout_remove_data(ob_main_loop, client_flash_timeout, self, TRUE); frame_engine->frame_free(self->frame); self->frame = NULL; @@ -3552,9 +3553,9 @@ void client_hilite(ObClient *self, gboolean hilite) self->demands_attention = hilite && !client_focused(self); if (self->frame != NULL) { /* if we're mapping, just set the state */ if (self->demands_attention) - frame_engine->frame_flash_start(self->frame); + client_flash_start(self); else - frame_engine->frame_flash_stop(self->frame); + client_flash_stop(self); client_change_state(self); } } @@ -4554,3 +4555,53 @@ void client_hide_frame(ObClient * self) XUnmapWindow(obt_display, self->w_client); self->ignore_unmaps++; } + +gboolean client_flash_timeout(gpointer data) +{ + ObClient * self = (ObClient *) data; + GTimeVal now; + g_get_current_time(&now); + + if (now.tv_sec > self->flash_end.tv_sec + || (now.tv_sec == self->flash_end.tv_sec && now.tv_usec + >= self->flash_end.tv_usec)) + self->flashing = FALSE; + + if (!self->flashing) + return FALSE; /* we are done */ + + self->flash_on = !self->flash_on; + if (!self->focused) { + frame_engine->frame_set_is_focus(self->frame, self->flash_on); + frame_engine->frame_update_skin (self->frame); + self->focused = FALSE; + } + return TRUE; /* go again */ +} + +void client_flash_start(ObClient * self) +{ + self->flash_on = self->focused; + if (!self->flashing) + obt_main_loop_timeout_add(ob_main_loop, G_USEC_PER_SEC * 0.6, + client_flash_timeout, self, g_direct_equal, client_flash_done); + g_get_current_time(&self->flash_end); + g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 5); + + self->flashing = TRUE; +} + +void client_flash_stop(ObClient * self) +{ + self->flashing = FALSE; +} + +void client_flash_done(gpointer data) +{ + ObClient * self = (ObClient *) data; + if (self->focused != self->flash_on) + { + frame_engine->frame_set_is_focus(self->frame, self->focused); + frame_engine->frame_update_skin (self->frame); + } +} diff --git a/openbox/client.h b/openbox/client.h index 209cdd11..1a944774 100644 --- a/openbox/client.h +++ b/openbox/client.h @@ -318,6 +318,12 @@ struct _ObClient /*! A boolean used for algorithms which need to mark clients as visited */ gboolean visited; + + /* Manage flashing */ + gboolean focused; + gboolean flashing; + gboolean flash_on; + GTimeVal flash_end; }; extern GList *client_list; @@ -730,4 +736,9 @@ gboolean client_has_group_siblings(ObClient *self); void client_show_frame(ObClient *); void client_hide_frame(ObClient *); + +gboolean client_flash_timeout(gpointer); +void client_flash_start(ObClient *); +void client_flash_stop(ObClient *); +void client_flash_done(gpointer); #endif -- 2.34.1