X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fframe.c;h=f6304f5d1340651006fe202dc3e453c715519ce1;hb=d179d6428ae585a3b8a13479bfe4586e41de2ff9;hp=25c470489596c8b12a42d3e3d91cfd9c9c0b87df;hpb=37705f444eecabb2e5bd31e92bc8b82ae9b8b596;p=chaz%2Fopenbox diff --git a/openbox/frame.c b/openbox/frame.c index 25c47048..f6304f5d 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -21,13 +21,14 @@ #include "client.h" #include "openbox.h" #include "grab.h" +#include "debug.h" #include "config.h" #include "framerender.h" #include "focus_cycle.h" #include "focus_cycle_indicator.h" #include "moveresize.h" #include "screen.h" -#include "render/theme.h" +#include "obrender/theme.h" #include "obt/display.h" #include "obt/prop.h" @@ -88,7 +89,7 @@ ObFrame *frame_new(ObClient *client) ObFrame *self; Visual *visual; - self = g_new0(ObFrame, 1); + self = g_slice_new0(ObFrame); self->client = client; visual = check_32bit_client(client); @@ -228,7 +229,7 @@ void frame_free(ObFrame *self) if (self->colormap) XFreeColormap(obt_display, self->colormap); - g_free(self); + g_slice_free(ObFrame, self); } void frame_show(ObFrame *self) @@ -265,25 +266,26 @@ void frame_adjust_theme(ObFrame *self) set_theme_statics(self); } -void frame_adjust_shape(ObFrame *self) -{ #ifdef SHAPE +void frame_adjust_shape_kind(ObFrame *self, int kind) +{ gint num; XRectangle xrect[2]; - if (!self->client->shaped) { + if (!((kind == ShapeBounding && self->client->shaped) || + (kind == ShapeInput && self->client->shaped_input))) { /* clear the shape on the frame window */ - XShapeCombineMask(obt_display, self->window, ShapeBounding, + XShapeCombineMask(obt_display, self->window, kind, self->size.left, self->size.top, None, ShapeSet); } else { /* make the frame's shape match the clients */ - XShapeCombineShape(obt_display, self->window, ShapeBounding, + XShapeCombineShape(obt_display, self->window, kind, self->size.left, self->size.top, self->client->window, - ShapeBounding, ShapeSet); + kind, ShapeSet); num = 0; if (self->decorations & OB_FRAME_DECOR_TITLEBAR) { @@ -309,6 +311,14 @@ void frame_adjust_shape(ObFrame *self) ShapeBounding, 0, 0, xrect, num, ShapeUnion, Unsorted); } +} +#endif + +void frame_adjust_shape(ObFrame *self) +{ +#ifdef SHAPE + frame_adjust_shape_kind(self, ShapeBounding); + frame_adjust_shape_kind(self, ShapeInput); #endif } @@ -329,13 +339,14 @@ void frame_adjust_area(ObFrame *self, gboolean moved, self->max_vert = self->client->max_vert; self->shaded = self->client->shaded; - if (self->decorations & OB_FRAME_DECOR_BORDER || - (self->client->undecorated && config_theme_keepborder)) + if (self->decorations & OB_FRAME_DECOR_BORDER) self->bwidth = ob_rr_theme->fbwidth; else self->bwidth = 0; - if (self->decorations & OB_FRAME_DECOR_BORDER) { + if (self->decorations & OB_FRAME_DECOR_BORDER && + !self->client->undecorated) + { self->cbwidth_l = self->cbwidth_r = ob_rr_theme->cbwidthx; self->cbwidth_t = self->cbwidth_b = ob_rr_theme->cbwidthy; } else @@ -358,9 +369,7 @@ void frame_adjust_area(ObFrame *self, gboolean moved, STRUT_SET(self->size, self->cbwidth_l + (!self->max_horz ? self->bwidth : 0), - self->cbwidth_t + - (!self->max_horz || !self->max_vert || - !self->client->undecorated ? self->bwidth : 0), + self->cbwidth_t + self->bwidth, self->cbwidth_r + (!self->max_horz ? self->bwidth : 0), self->cbwidth_b + (!self->max_horz || !self->max_vert ? self->bwidth : 0)); @@ -850,12 +859,14 @@ void frame_adjust_area(ObFrame *self, gboolean moved, /* 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(self->client); + focus_cycle_update_indicator(self->client); } - if (resized && (self->decorations & OB_FRAME_DECOR_TITLEBAR)) + if (resized && (self->decorations & OB_FRAME_DECOR_TITLEBAR) && + self->label_width) + { XResizeWindow(obt_display, self->label, self->label_width, ob_rr_theme->label_height); - + } } static void frame_adjust_cursors(ObFrame *self) @@ -939,6 +950,9 @@ void frame_adjust_state(ObFrame *self) void frame_adjust_focus(ObFrame *self, gboolean hilite) { + ob_debug_type(OB_DEBUG_FOCUS, + "Frame for 0x%x has focus: %d\n", + self->client->window, hilite); self->focused = hilite; self->need_render = TRUE; framerender_frame(self); @@ -1133,15 +1147,37 @@ static gboolean is_button_present(ObFrame *self, const gchar *lc, gint dir) { return FALSE; } +static void place_button(ObFrame *self, const char *lc, gint bwidth, + gint left, gint i, + gint *x, gint *button_on, gint *button_x) +{ + if (!(*button_on = is_button_present(self, lc, i))) + return; + + self->label_width -= bwidth; + if (i > 0) + *button_x = *x; + *x += i * bwidth; + if (i < 0) { + if (self->label_x <= left || *x > self->label_x) { + *button_x = *x; + } else { + /* the button would have been drawn on top of another button */ + *button_on = FALSE; + self->label_width += bwidth; + } + } +} + static void layout_title(ObFrame *self) { gchar *lc; gint i; const gint bwidth = ob_rr_theme->button_size + ob_rr_theme->paddingx + 1; - /* position of the left most button */ + /* position of the leftmost button */ const gint left = ob_rr_theme->paddingx + 1; - /* position of the right most button */ + /* position of the rightmost button */ const gint right = self->width; /* turn them all off */ @@ -1180,53 +1216,23 @@ static void layout_title(ObFrame *self) break; /* break the for loop, do other side of label */ } else if (*lc == 'N') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ICON; - if ((self->icon_on = is_button_present(self, lc, i))) { - /* icon is bigger than buttons */ - self->label_width -= bwidth + 2; - if (i > 0) self->icon_x = x; - x += i * (bwidth + 2); - if (i < 0) self->icon_x = x; - } + /* icon is bigger than buttons */ + place_button(self, lc, bwidth + 2, left, i, &x, &self->icon_on, &self->icon_x); } else if (*lc == 'D') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ALLDESKTOPS; - if ((self->desk_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->desk_x = x; - x += i * bwidth; - if (i < 0) self->desk_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->desk_on, &self->desk_x); } else if (*lc == 'S') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_SHADE; - if ((self->shade_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->shade_x = x; - x += i * bwidth; - if (i < 0) self->shade_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->shade_on, &self->shade_x); } else if (*lc == 'I') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_ICONIFY; - if ((self->iconify_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->iconify_x = x; - x += i * bwidth; - if (i < 0) self->iconify_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->iconify_on, &self->iconify_x); } else if (*lc == 'M') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_MAXIMIZE; - if ((self->max_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->max_x = x; - x += i * bwidth; - if (i < 0) self->max_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->max_on, &self->max_x); } else if (*lc == 'C') { if (firstcon) *firstcon = OB_FRAME_CONTEXT_CLOSE; - if ((self->close_on = is_button_present(self, lc, i))) { - self->label_width -= bwidth; - if (i > 0) self->close_x = x; - x += i * bwidth; - if (i < 0) self->close_x = x; - } + place_button(self, lc, bwidth, left, i, &x, &self->close_on, &self->close_x); } else continue; /* don't set firstcon */ firstcon = NULL; @@ -1276,8 +1282,7 @@ static void layout_title(ObFrame *self) } else XUnmapWindow(obt_display, self->close); - if (self->label_on) { - self->label_width = MAX(1, self->label_width); /* no lower than 1 */ + if (self->label_on && self->label_width > 0) { XMapWindow(obt_display, self->label); XMoveWindow(obt_display, self->label, self->label_x, ob_rr_theme->paddingy); @@ -1672,12 +1677,10 @@ static gboolean frame_animate_iconify(gpointer p) if (self->client->icon_geometry.width == 0) { /* there is no icon geometry set so just go straight down */ - Rect *a = screen_physical_area_monitor - (screen_find_monitor(&self->area)); + Rect const *a = screen_physical_area_monitor(screen_find_monitor(&self->area)); iconx = self->area.x + self->area.width / 2 + 32; icony = a->y + a->width; iconw = 64; - g_free(a); } else { iconx = self->client->icon_geometry.x; icony = self->client->icon_geometry.y;