]> Dogcows Code - chaz/openbox/blobdiff - openbox/frame.c
match the func prototypes in the header
[chaz/openbox] / openbox / frame.c
index 37470e3cc15e678fa68df450fb1c4ac8c62a6826..fe5ddc49c3a5a37f822c05ae7f3e230ea5c572e2 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)
                           f->cbwidth_y)
 
 static void layout_title(ObFrame *self);
+static void flash_done(gpointer data);
+static gboolean flash_timeout(gpointer data);
+
+static void set_theme_statics(ObFrame *self);
+static void free_theme_statics(ObFrame *self);
 
 static Window createWindow(Window parent, unsigned long mask,
                           XSetWindowAttributes *attrib)
@@ -39,6 +45,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;
@@ -84,6 +91,18 @@ ObFrame *frame_new()
     XMapWindow(ob_display, self->rgrip);
     XMapWindow(ob_display, self->label);
 
+    self->max_press = self->close_press = self->desk_press = 
+       self->iconify_press = self->shade_press = FALSE;
+    self->max_hover = self->close_hover = self->desk_hover = 
+       self->iconify_hover = self->shade_hover = FALSE;
+
+    set_theme_statics(self);
+
+    return (ObFrame*)self;
+}
+
+static void set_theme_statics(ObFrame *self)
+{
     /* set colors/appearance/sizes for stuff that doesn't change */
     XSetWindowBorder(ob_display, self->window, ob_rr_theme->b_color->pixel);
     XSetWindowBorder(ob_display, self->title, ob_rr_theme->b_color->pixel);
@@ -121,16 +140,9 @@ ObFrame *frame_new()
         RrAppearanceCopy(ob_rr_theme->a_unfocused_handle);
     self->a_focused_handle = RrAppearanceCopy(ob_rr_theme->a_focused_handle);
     self->a_icon = RrAppearanceCopy(ob_rr_theme->a_icon);
-
-    self->max_press = self->close_press = self->desk_press = 
-       self->iconify_press = self->shade_press = FALSE;
-    self->max_hover = self->close_hover = self->desk_hover = 
-       self->iconify_hover = self->shade_hover = FALSE;
-
-    return (ObFrame*)self;
 }
 
-static void frame_free(ObFrame *self)
+static void free_theme_statics(ObFrame *self)
 {
     RrAppearanceFree(self->a_unfocused_title); 
     RrAppearanceFree(self->a_focused_title);
@@ -139,6 +151,11 @@ static void frame_free(ObFrame *self)
     RrAppearanceFree(self->a_unfocused_handle);
     RrAppearanceFree(self->a_focused_handle);
     RrAppearanceFree(self->a_icon);
+}
+
+static void frame_free(ObFrame *self)
+{
+    free_theme_statics(self);
 
     XDestroyWindow(ob_display, self->window);
 
@@ -162,6 +179,13 @@ void frame_hide(ObFrame *self)
     }
 }
 
+void frame_adjust_theme(ObFrame *self)
+{
+    free_theme_statics(self);
+    set_theme_statics(self);
+    frame_adjust_area(self, TRUE, TRUE, FALSE);
+}
+
 void frame_adjust_shape(ObFrame *self)
 {
 #ifdef SHAPE
@@ -473,6 +497,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_data(ob_main_loop, flash_timeout, self);
+
     frame_free(self);
 }
 
@@ -779,3 +805,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.024226 seconds and 4 git commands to generate.