]> Dogcows Code - chaz/openbox/blobdiff - openbox/frame.c
make the client destructor a GDestroyNotify
[chaz/openbox] / openbox / frame.c
index 6c3b418a50c1face281f6b01cdb6771a1c17d841..3bceec997a2f2aed40fac936123b125f474517cd 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)
@@ -18,6 +19,8 @@
                           f->cbwidth_y)
 
 static void layout_title(ObFrame *self);
+static void flash_done(gpointer data);
+static gboolean flash_timeout(gpointer data);
 
 static Window createWindow(Window parent, unsigned long mask,
                           XSetWindowAttributes *attrib)
@@ -39,6 +42,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;
@@ -338,7 +342,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));
 
@@ -473,6 +477,8 @@ void frame_release_client(ObFrame *self, ObClient *client)
     g_hash_table_remove(window_map, &self->tlresize);
     g_hash_table_remove(window_map, &self->trresize);
 
+    ob_main_loop_timeout_remove(ob_main_loop, flash_timeout);
+
     frame_free(self);
 }
 
@@ -779,3 +785,58 @@ void frame_frame_gravity(ObFrame *self, int *x, int *y)
        break;
     }
 }
+
+static void flash_done(gpointer data)
+{
+    ObFrame *self = data;
+
+    if (self->focused != self->flash_on)
+        frame_adjust_focus(self, self->focused);
+}
+
+static gboolean flash_timeout(gpointer data)
+{
+    ObFrame *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;
+    {
+        gboolean focused;
+        
+        focused = self->focused; /* save the focused flag */
+        frame_adjust_focus(self, self->flash_on);
+        self->focused = focused;
+    }
+
+    return TRUE; /* go again */
+}
+
+void frame_flash_start(ObFrame *self)
+{
+    self->flash_on = self->focused;
+
+    if (!self->flashing)
+        ob_main_loop_timeout_add(ob_main_loop,
+                                 G_USEC_PER_SEC * 0.75,
+                                 flash_timeout,
+                                 self,
+                                 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(ObFrame *self)
+{
+    self->flashing = FALSE;
+}
This page took 0.028072 seconds and 4 git commands to generate.