]> Dogcows Code - chaz/openbox/blobdiff - openbox/frame.c
add code to flash the frame
[chaz/openbox] / openbox / frame.c
index 633b7cef383fd76dd69918da18d458d718c1e71a..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;
@@ -213,6 +215,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
 {
     if (resized) {
         self->decorations = self->client->decorations;
+        self->max_horz = self->client->max_horz;
 
         if (self->decorations & OB_FRAME_DECOR_BORDER) {
             self->bwidth = ob_rr_theme->bwidth;
@@ -222,11 +225,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
         }
         self->rbwidth = self->bwidth;
 
-        if (self->client->max_vert && self->client->max_horz)
-            self->client->decorations =
-                self->decorations &= ~OB_FRAME_DECOR_HANDLE;
-
-        if (self->client->max_horz)
+        if (self->max_horz)
             self->bwidth = self->cbwidth_x = 0;
 
         STRUT_SET(self->innersize,
@@ -235,7 +234,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                   self->cbwidth_x,
                   self->cbwidth_y);
         self->width = self->client->area.width + self->cbwidth_x * 2 -
-            (self->client->max_horz ? self->rbwidth * 2 : 0);
+            (self->max_horz ? self->rbwidth * 2 : 0);
         self->width = MAX(self->width, 1); /* no lower than 1 */
 
         /* set border widths */
@@ -341,7 +340,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved,
                  self->client->area.width +
                  self->size.left + self->size.right,
                  (self->client->shaded ?
-                   ob_rr_theme->title_height + self->bwidth*2:
+                   ob_rr_theme->title_height + self->rbwidth * 2:
                    self->client->area.height +
                    self->size.top + self->size.bottom));
 
@@ -782,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;
+}
This page took 0.022606 seconds and 4 git commands to generate.