]> Dogcows Code - chaz/openbox/commitdiff
add code to flash the frame
authorDana Jansens <danakj@orodu.net>
Mon, 1 Sep 2003 02:57:19 +0000 (02:57 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 1 Sep 2003 02:57:19 +0000 (02:57 +0000)
openbox/frame.c
openbox/frame.h

index 37470e3cc15e678fa68df450fb1c4ac8c62a6826..7c26d7068eefca58a51c5fbc398031609906365c 100644 (file)
@@ -4,6 +4,7 @@
 #include "extensions.h"
 #include "config.h"
 #include "framerender.h"
+#include "mainloop.h"
 #include "render/theme.h"
 
 #define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask)
@@ -39,6 +40,7 @@ ObFrame *frame_new()
     self->visible = FALSE;
     self->obscured = TRUE;
     self->decorations = 0;
+    self->flashing = FALSE;
 
     /* create all of the decor windows */
     mask = CWOverrideRedirect | CWEventMask;
@@ -779,3 +781,55 @@ void frame_frame_gravity(ObFrame *self, int *x, int *y)
        break;
     }
 }
+
+static void flash_done(gpointer data)
+{
+    ObFrame *self = data;
+    self->flashing = FALSE;
+
+    if (self->focused != self->flash_on)
+        frame_adjust_focus(self, self->focused);
+}
+
+static gboolean flash_timeout(gpointer data)
+{
+    ObFrame *self = data;
+    GTimeVal now;
+    gboolean focused;
+
+    g_message("flash");
+
+    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)) {
+        g_message("done flashing");
+        return FALSE; /* we are done */
+    }
+
+    self->flash_on = !self->flash_on;
+    g_message("on %d", self->flash_on);
+    {
+        focused = self->focused; /* save the focused flag */
+        frame_adjust_focus(self, self->flash_on);
+        self->focused = focused;
+    }
+
+    return TRUE; /* go again */
+}
+
+void frame_flash(ObFrame *self)
+{
+    self->flash_on = self->focused;
+
+    if (!self->flashing)
+        ob_main_loop_timeout_add(ob_main_loop,
+                                 G_USEC_PER_SEC / 2,
+                                 flash_timeout,
+                                 self,
+                                 flash_done);
+    g_get_current_time(&self->flash_end);
+    g_time_val_add(&self->flash_end, G_USEC_PER_SEC * 4);
+    
+    self->flashing = TRUE;
+}
index 572d18b6353198affc06456724878ba243d6633c..d5a9c7ce0412711c6b946c755123ec180fb1741e 100644 (file)
@@ -114,6 +114,10 @@ struct _ObFrame
     gboolean  iconify_hover;
 
     gboolean  focused;
+
+    gboolean  flashing;
+    gboolean  flash_on;
+    GTimeVal  flash_end;
 };
 
 ObFrame *frame_new();
@@ -145,5 +149,6 @@ void frame_client_gravity(ObFrame *self, int *x, int *y);
 */
 void frame_frame_gravity(ObFrame *self, int *x, int *y);
 
+void frame_flash(ObFrame *self);
 
 #endif
This page took 0.032442 seconds and 4 git commands to generate.