X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fframe.c;h=5d7ec6c1b22f12060ed5ecd50831b08e7a03ba3c;hb=def76092b587e7e9a2b212dc5211773e336525e1;hp=3bceec997a2f2aed40fac936123b125f474517cd;hpb=5dafdaf2856aa709db57cd06e080faa8cf01faee;p=chaz%2Fopenbox diff --git a/openbox/frame.c b/openbox/frame.c index 3bceec99..5d7ec6c1 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -1,10 +1,31 @@ +/* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*- + + frame.c for the Openbox window manager + Copyright (c) 2003 Ben Jansens + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + See the COPYING file for a copy of the GNU General Public License. +*/ + #include "frame.h" #include "client.h" #include "openbox.h" #include "extensions.h" +#include "prop.h" #include "config.h" #include "framerender.h" #include "mainloop.h" +#include "focus.h" +#include "moveresize.h" #include "render/theme.h" #define PLATE_EVENTMASK (SubstructureRedirectMask | ButtonPressMask) @@ -22,7 +43,10 @@ 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, +static void set_theme_statics(ObFrame *self); +static void free_theme_statics(ObFrame *self); + +static Window createWindow(Window parent, gulong mask, XSetWindowAttributes *attrib) { return XCreateWindow(ob_display, parent, 0, 0, 1, 1, 0, @@ -34,15 +58,12 @@ static Window createWindow(Window parent, unsigned long mask, ObFrame *frame_new() { XSetWindowAttributes attrib; - unsigned long mask; + gulong mask; ObFrame *self; - self = g_new(ObFrame, 1); + self = g_new0(ObFrame, 1); - self->visible = FALSE; self->obscured = TRUE; - self->decorations = 0; - self->flashing = FALSE; /* create all of the decor windows */ mask = CWOverrideRedirect | CWEventMask; @@ -88,12 +109,29 @@ 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); - XSetWindowBorder(ob_display, self->handle, ob_rr_theme->b_color->pixel); - XSetWindowBorder(ob_display, self->rgrip, ob_rr_theme->b_color->pixel); - XSetWindowBorder(ob_display, self->lgrip, ob_rr_theme->b_color->pixel); + XSetWindowBorder(ob_display, self->window, + RrColorPixel(ob_rr_theme->b_color)); + XSetWindowBorder(ob_display, self->title, + RrColorPixel(ob_rr_theme->b_color)); + XSetWindowBorder(ob_display, self->handle, + RrColorPixel(ob_rr_theme->b_color)); + XSetWindowBorder(ob_display, self->rgrip, + RrColorPixel(ob_rr_theme->b_color)); + XSetWindowBorder(ob_display, self->lgrip, + RrColorPixel(ob_rr_theme->b_color)); XResizeWindow(ob_display, self->max, ob_rr_theme->button_size, ob_rr_theme->button_size); @@ -125,16 +163,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); @@ -143,6 +174,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); @@ -152,24 +188,34 @@ static void frame_free(ObFrame *self) void frame_show(ObFrame *self) { if (!self->visible) { - self->visible = TRUE; - XMapWindow(ob_display, self->window); + self->visible = TRUE; + XMapWindow(ob_display, self->client->window); + XMapWindow(ob_display, self->window); } } void frame_hide(ObFrame *self) { if (self->visible) { - self->visible = FALSE; - self->client->ignore_unmaps++; - XUnmapWindow(ob_display, self->window); + self->visible = FALSE; + self->client->ignore_unmaps += 2; + /* we unmap the client itself so that we can get MapRequest + events, and because the ICCCM tells us to! */ + XUnmapWindow(ob_display, self->window); + XUnmapWindow(ob_display, self->client->window); } } +void frame_adjust_theme(ObFrame *self) +{ + free_theme_statics(self); + set_theme_statics(self); +} + void frame_adjust_shape(ObFrame *self) { #ifdef SHAPE - int num; + gint num; XRectangle xrect[2]; if (!self->client->shaped) { @@ -215,6 +261,10 @@ void frame_adjust_shape(ObFrame *self) void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized, gboolean fake) { + Strut oldsize; + + oldsize = self->size; + if (resized) { self->decorations = self->client->decorations; self->max_horz = self->client->max_horz; @@ -251,7 +301,8 @@ void frame_adjust_area(ObFrame *self, gboolean moved, if (self->decorations & OB_FRAME_DECOR_TITLEBAR) self->innersize.top += ob_rr_theme->title_height + self->rbwidth + (self->rbwidth - self->bwidth); - if (self->decorations & OB_FRAME_DECOR_HANDLE) + if (self->decorations & OB_FRAME_DECOR_HANDLE && + ob_rr_theme->show_handle) self->innersize.bottom += ob_rr_theme->handle_height + self->rbwidth + (self->rbwidth - self->bwidth); @@ -292,7 +343,9 @@ void frame_adjust_area(ObFrame *self, gboolean moved, layout_title(self); if (!fake) { - if (self->decorations & OB_FRAME_DECOR_HANDLE) { + if (self->decorations & OB_FRAME_DECOR_HANDLE && + ob_rr_theme->show_handle) + { XMoveResizeWindow(ob_display, self->handle, -self->bwidth, FRAME_HANDLE_Y(self), self->width, ob_rr_theme->handle_height); @@ -367,6 +420,21 @@ void frame_adjust_area(ObFrame *self, gboolean moved, frame_adjust_shape(self); } + + if (!STRUT_EQUAL(self->size, oldsize)) { + guint32 vals[4]; + vals[0] = self->size.left; + vals[1] = self->size.right; + vals[2] = self->size.top; + vals[3] = self->size.bottom; + PROP_SETA32(self->client->window, kde_net_wm_frame_strut, + cardinal, vals, 4); + } + + /* if this occurs while we are focus cycling, the indicator needs to + match the changes */ + if (focus_cycle_target == self->client) + focus_cycle_draw_indicator(); } } @@ -477,46 +545,46 @@ 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); + ob_main_loop_timeout_remove_data(ob_main_loop, flash_timeout, self); frame_free(self); } static void layout_title(ObFrame *self) { - char *lc; - int x; + gchar *lc; + gint x; gboolean n, d, i, l, m, c, s; n = d = i = l = m = c = s = FALSE; /* figure out whats being shown, and the width of the label */ - self->label_width = self->width - (ob_rr_theme->bevel + 1) * 2; + self->label_width = self->width - (ob_rr_theme->padding + 1) * 2; for (lc = config_title_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (n) { *lc = ' '; break; } /* rm duplicates */ n = TRUE; self->label_width -= (ob_rr_theme->button_size + 2 + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; case 'D': if (d) { *lc = ' '; break; } /* rm duplicates */ d = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; case 'S': if (s) { *lc = ' '; break; } /* rm duplicates */ s = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; case 'I': if (i) { *lc = ' '; break; } /* rm duplicates */ i = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; case 'L': if (l) { *lc = ' '; break; } /* rm duplicates */ @@ -526,13 +594,13 @@ static void layout_title(ObFrame *self) if (m) { *lc = ' '; break; } /* rm duplicates */ m = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; case 'C': if (c) { *lc = ' '; break; } /* rm duplicates */ c = TRUE; self->label_width -= (ob_rr_theme->button_size + - ob_rr_theme->bevel + 1); + ob_rr_theme->padding + 1); break; } } @@ -549,94 +617,96 @@ static void layout_title(ObFrame *self) if (!m) XUnmapWindow(ob_display, self->max); if (!c) XUnmapWindow(ob_display, self->close); - x = ob_rr_theme->bevel + 1; + x = ob_rr_theme->padding + 1; for (lc = config_title_layout; *lc != '\0'; ++lc) { switch (*lc) { case 'N': if (!n) break; self->icon_x = x; XMapWindow(ob_display, self->icon); - XMoveWindow(ob_display, self->icon, x, ob_rr_theme->bevel); - x += ob_rr_theme->button_size + 2 + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->icon, x, ob_rr_theme->padding); + x += ob_rr_theme->button_size + 2 + ob_rr_theme->padding + 1; break; case 'D': if (!d) break; self->desk_x = x; XMapWindow(ob_display, self->desk); - XMoveWindow(ob_display, self->desk, x, ob_rr_theme->bevel + 1); - x += ob_rr_theme->button_size + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->desk, x, ob_rr_theme->padding + 1); + x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; break; case 'S': if (!s) break; self->shade_x = x; XMapWindow(ob_display, self->shade); - XMoveWindow(ob_display, self->shade, x, ob_rr_theme->bevel + 1); - x += ob_rr_theme->button_size + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->shade, x, ob_rr_theme->padding + 1); + x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; break; case 'I': if (!i) break; self->iconify_x = x; XMapWindow(ob_display, self->iconify); - XMoveWindow(ob_display, self->iconify, x, ob_rr_theme->bevel + 1); - x += ob_rr_theme->button_size + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display,self->iconify, x, ob_rr_theme->padding + 1); + x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; break; case 'L': if (!l) break; self->label_x = x; XMapWindow(ob_display, self->label); - XMoveWindow(ob_display, self->label, x, ob_rr_theme->bevel); - x += self->label_width + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->label, x, ob_rr_theme->padding); + x += self->label_width + ob_rr_theme->padding + 1; break; case 'M': if (!m) break; self->max_x = x; XMapWindow(ob_display, self->max); - XMoveWindow(ob_display, self->max, x, ob_rr_theme->bevel + 1); - x += ob_rr_theme->button_size + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->max, x, ob_rr_theme->padding + 1); + x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; break; case 'C': if (!c) break; self->close_x = x; XMapWindow(ob_display, self->close); - XMoveWindow(ob_display, self->close, x, ob_rr_theme->bevel + 1); - x += ob_rr_theme->button_size + ob_rr_theme->bevel + 1; + XMoveWindow(ob_display, self->close, x, ob_rr_theme->padding + 1); + x += ob_rr_theme->button_size + ob_rr_theme->padding + 1; break; } } } -ObFrameContext frame_context_from_string(char *name) +ObFrameContext frame_context_from_string(const gchar *name) { - if (!g_ascii_strcasecmp("desktop", name)) + if (!g_ascii_strcasecmp("Desktop", name)) return OB_FRAME_CONTEXT_DESKTOP; - else if (!g_ascii_strcasecmp("client", name)) + else if (!g_ascii_strcasecmp("Client", name)) return OB_FRAME_CONTEXT_CLIENT; - else if (!g_ascii_strcasecmp("titlebar", name)) + else if (!g_ascii_strcasecmp("Titlebar", name)) return OB_FRAME_CONTEXT_TITLEBAR; - else if (!g_ascii_strcasecmp("handle", name)) + else if (!g_ascii_strcasecmp("Handle", name)) return OB_FRAME_CONTEXT_HANDLE; - else if (!g_ascii_strcasecmp("frame", name)) + else if (!g_ascii_strcasecmp("Frame", name)) return OB_FRAME_CONTEXT_FRAME; - else if (!g_ascii_strcasecmp("tlcorner", name)) + else if (!g_ascii_strcasecmp("TLCorner", name)) return OB_FRAME_CONTEXT_TLCORNER; - else if (!g_ascii_strcasecmp("trcorner", name)) + else if (!g_ascii_strcasecmp("TRCorner", name)) return OB_FRAME_CONTEXT_TRCORNER; - else if (!g_ascii_strcasecmp("blcorner", name)) + else if (!g_ascii_strcasecmp("BLCorner", name)) return OB_FRAME_CONTEXT_BLCORNER; - else if (!g_ascii_strcasecmp("brcorner", name)) + else if (!g_ascii_strcasecmp("BRCorner", name)) return OB_FRAME_CONTEXT_BRCORNER; - else if (!g_ascii_strcasecmp("maximize", name)) + else if (!g_ascii_strcasecmp("Maximize", name)) return OB_FRAME_CONTEXT_MAXIMIZE; - else if (!g_ascii_strcasecmp("alldesktops", name)) + else if (!g_ascii_strcasecmp("AllDesktops", name)) return OB_FRAME_CONTEXT_ALLDESKTOPS; - else if (!g_ascii_strcasecmp("shade", name)) + else if (!g_ascii_strcasecmp("Shade", name)) return OB_FRAME_CONTEXT_SHADE; - else if (!g_ascii_strcasecmp("iconify", name)) + else if (!g_ascii_strcasecmp("Iconify", name)) return OB_FRAME_CONTEXT_ICONIFY; - else if (!g_ascii_strcasecmp("icon", name)) + else if (!g_ascii_strcasecmp("Icon", name)) return OB_FRAME_CONTEXT_ICON; - else if (!g_ascii_strcasecmp("close", name)) + else if (!g_ascii_strcasecmp("Close", name)) return OB_FRAME_CONTEXT_CLOSE; + else if (!g_ascii_strcasecmp("MoveResize", name)) + return OB_FRAME_CONTEXT_MOVE_RESIZE; return OB_FRAME_CONTEXT_NONE; } @@ -644,6 +714,9 @@ ObFrameContext frame_context(ObClient *client, Window win) { ObFrame *self; + if (moveresize_in_progress) + return OB_FRAME_CONTEXT_MOVE_RESIZE; + if (win == RootWindow(ob_display, ob_screen)) return OB_FRAME_CONTEXT_DESKTOP; if (client == NULL) return OB_FRAME_CONTEXT_NONE; @@ -682,7 +755,7 @@ ObFrameContext frame_context(ObClient *client, Window win) return OB_FRAME_CONTEXT_NONE; } -void frame_client_gravity(ObFrame *self, int *x, int *y) +void frame_client_gravity(ObFrame *self, gint *x, gint *y) { /* horizontal */ switch (self->client->gravity) { @@ -737,7 +810,7 @@ void frame_client_gravity(ObFrame *self, int *x, int *y) } } -void frame_frame_gravity(ObFrame *self, int *x, int *y) +void frame_frame_gravity(ObFrame *self, gint *x, gint *y) { /* horizontal */ switch (self->client->gravity) { @@ -809,12 +882,9 @@ static gboolean flash_timeout(gpointer data) return FALSE; /* we are done */ self->flash_on = !self->flash_on; - { - gboolean focused; - - focused = self->focused; /* save the focused flag */ + if (!self->focused) { frame_adjust_focus(self, self->flash_on); - self->focused = focused; + self->focused = FALSE; } return TRUE; /* go again */ @@ -826,7 +896,7 @@ void frame_flash_start(ObFrame *self) if (!self->flashing) ob_main_loop_timeout_add(ob_main_loop, - G_USEC_PER_SEC * 0.75, + G_USEC_PER_SEC * 0.6, flash_timeout, self, flash_done);