Flashing is now a part of obclient
authorBenoit Gschwind <doth.gschwind@gmail.com>
Fri, 22 Feb 2008 20:55:20 +0000 (21:55 +0100)
committerBenoit Gschwind <doth.gschwind@gmail.com>
Fri, 22 Feb 2008 20:55:20 +0000 (21:55 +0100)
engines/default/plugin.c
engines/default/plugin.h
openbox/client.c
openbox/client.h

index 168e5f26488c557dd162056645d46e4a4f0ccc7d..faf308207158c9518f961b8480ea9d092b42c8bf 100644 (file)
@@ -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;
+}
+
index b3627250af0f7976636bb3bde371572329761480..3cb46275fa244fa490864ac0d1d49b50eab2c1bf 100644 (file)
@@ -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);
index af27ec9a6c2e7017833dfa785de1f65d07e1850c..03ce9cc681a5a17ec4a1452bd0a4438e7f1de986 100644 (file)
@@ -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);
+    }
+}
index 209cdd11c0e93d696bfa04e8ac9ede2b487a89dd..1a9447743217e9e26d00d6334f21456e82a15bf7 100644 (file)
@@ -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