X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fframe.c;h=3a8b57fea61e300955fb82fd07eead05e6127332;hb=973507ff28b5d71433b3d0583e757fbc82b254c5;hp=bdae34e3df04deed7c7576c024d2656dc0c31b4b;hpb=2494762dbf89e0ea8eb72c460c6f7281fa0a2204;p=chaz%2Fopenbox diff --git a/openbox/frame.c b/openbox/frame.c index bdae34e3..3a8b57fe 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -4,11 +4,13 @@ #include "extensions.h" #include "config.h" #include "framerender.h" +#include "mainloop.h" #include "render/theme.h" #define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask) #define FRAME_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ - ButtonPressMask | ButtonReleaseMask) + ButtonPressMask | ButtonReleaseMask | \ + VisibilityChangeMask) #define ELEMENT_EVENTMASK (ButtonPressMask | ButtonReleaseMask | \ ButtonMotionMask | ExposureMask | \ EnterWindowMask | LeaveWindowMask) @@ -17,6 +19,11 @@ 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) @@ -36,7 +43,9 @@ ObFrame *frame_new() self = g_new(ObFrame, 1); self->visible = FALSE; + self->obscured = TRUE; self->decorations = 0; + self->flashing = FALSE; /* create all of the decor windows */ mask = CWOverrideRedirect | CWEventMask; @@ -81,9 +90,19 @@ ObFrame *frame_new() XMapWindow(ob_display, self->lgrip); XMapWindow(ob_display, self->rgrip); XMapWindow(ob_display, self->label); - XMapWindow(ob_display, self->tlresize); - XMapWindow(ob_display, self->trresize); + 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 @@ -213,6 +237,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,10 +247,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, } self->rbwidth = self->bwidth; - if (self->client->max_vert && self->client->max_horz) - 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, @@ -234,7 +256,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 */ @@ -271,10 +293,16 @@ void frame_adjust_area(ObFrame *self, gboolean moved, self->width, ob_rr_theme->title_height); XMapWindow(ob_display, self->title); - XMoveWindow(ob_display, self->tlresize, 0, 0); - XMoveWindow(ob_display, self->trresize, - self->width - ob_rr_theme->grip_width, 0); - + if (self->decorations & OB_FRAME_DECOR_GRIPS) { + XMoveWindow(ob_display, self->tlresize, 0, 0); + XMoveWindow(ob_display, self->trresize, + self->width - ob_rr_theme->grip_width, 0); + XMapWindow(ob_display, self->tlresize); + XMapWindow(ob_display, self->trresize); + } else { + XUnmapWindow(ob_display, self->tlresize); + XUnmapWindow(ob_display, self->trresize); + } } else XUnmapWindow(ob_display, self->title); } @@ -334,7 +362,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)); @@ -469,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(ob_main_loop, flash_timeout); + frame_free(self); } @@ -597,8 +627,8 @@ static void layout_title(ObFrame *self) ObFrameContext frame_context_from_string(char *name) { - if (!g_ascii_strcasecmp("root", name)) - return OB_FRAME_CONTEXT_ROOT; + if (!g_ascii_strcasecmp("desktop", name)) + return OB_FRAME_CONTEXT_DESKTOP; else if (!g_ascii_strcasecmp("client", name)) return OB_FRAME_CONTEXT_CLIENT; else if (!g_ascii_strcasecmp("titlebar", name)) @@ -634,13 +664,27 @@ ObFrameContext frame_context(ObClient *client, Window win) { ObFrame *self; - if (win == RootWindow(ob_display, ob_screen)) return OB_FRAME_CONTEXT_ROOT; + if (win == RootWindow(ob_display, ob_screen)) + return OB_FRAME_CONTEXT_DESKTOP; if (client == NULL) return OB_FRAME_CONTEXT_NONE; - if (win == client->window) return OB_FRAME_CONTEXT_CLIENT; + if (win == client->window) { + /* conceptually, this is the desktop, as far as users are + concerned */ + if (client->type == OB_CLIENT_TYPE_DESKTOP) + return OB_FRAME_CONTEXT_DESKTOP; + return OB_FRAME_CONTEXT_CLIENT; + } self = client->frame; + if (win == self->plate) { + /* conceptually, this is the desktop, as far as users are + concerned */ + if (client->type == OB_CLIENT_TYPE_DESKTOP) + return OB_FRAME_CONTEXT_DESKTOP; + return OB_FRAME_CONTEXT_CLIENT; + } + if (win == self->window) return OB_FRAME_CONTEXT_FRAME; - if (win == self->plate) return OB_FRAME_CONTEXT_CLIENT; if (win == self->title) return OB_FRAME_CONTEXT_TITLEBAR; if (win == self->label) return OB_FRAME_CONTEXT_TITLEBAR; if (win == self->handle) return OB_FRAME_CONTEXT_HANDLE; @@ -761,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; +}