X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fframe.c;h=e4a64bd37ab2bc726d60e142b881a02fd8324313;hb=ba1ac214dfdbc0539c922e84c2318c1bf2566c0c;hp=a47c2f06a9f1e2d46dcfbfa7b9c3b8b99b8f30af;hpb=2b5d4b69974aba63f0c22cd5e4b91c456cd70f68;p=chaz%2Fopenbox diff --git a/openbox/frame.c b/openbox/frame.c index a47c2f06..e4a64bd3 100644 --- a/openbox/frame.c +++ b/openbox/frame.c @@ -99,7 +99,7 @@ ObFrame *frame_new(ObClient *client) mask = 0; if (visual) { /* client has a 32-bit visual */ - mask |= CWColormap | CWBackPixel | CWBorderPixel; + mask = CWColormap | CWBackPixel | CWBorderPixel; /* create a colormap with the visual */ self->colormap = attrib.colormap = XCreateColormap(ob_display, @@ -116,7 +116,7 @@ ObFrame *frame_new(ObClient *client) mask = 0; if (visual) { /* client has a 32-bit visual */ - mask |= CWColormap | CWBackPixel | CWBorderPixel; + mask = CWColormap | CWBackPixel | CWBorderPixel; attrib.colormap = RrColormap(ob_rr_inst); } @@ -190,7 +190,7 @@ ObFrame *frame_new(ObClient *client) set_theme_statics(self); - return (ObFrame*)self; + return self; } static void set_theme_statics(ObFrame *self) @@ -216,27 +216,10 @@ static void set_theme_statics(ObFrame *self) ob_rr_theme->paddingx + 1, ob_rr_theme->title_height); XResizeWindow(ob_display, self->trrresize, ob_rr_theme->paddingx + 1, ob_rr_theme->title_height); - - /* set up the dynamic appearances */ - self->a_unfocused_title = RrAppearanceCopy(ob_rr_theme->a_unfocused_title); - self->a_focused_title = RrAppearanceCopy(ob_rr_theme->a_focused_title); - self->a_unfocused_label = RrAppearanceCopy(ob_rr_theme->a_unfocused_label); - self->a_focused_label = RrAppearanceCopy(ob_rr_theme->a_focused_label); - self->a_unfocused_handle = - 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); } static void free_theme_statics(ObFrame *self) { - RrAppearanceFree(self->a_unfocused_title); - RrAppearanceFree(self->a_focused_title); - RrAppearanceFree(self->a_unfocused_label); - RrAppearanceFree(self->a_focused_label); - RrAppearanceFree(self->a_unfocused_handle); - RrAppearanceFree(self->a_focused_handle); - RrAppearanceFree(self->a_icon); } void frame_free(ObFrame *self) @@ -284,25 +267,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(ob_display, self->window, ShapeBounding, + XShapeCombineMask(ob_display, self->window, kind, self->size.left, self->size.top, None, ShapeSet); } else { /* make the frame's shape match the clients */ - XShapeCombineShape(ob_display, self->window, ShapeBounding, + XShapeCombineShape(ob_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) { @@ -325,9 +309,17 @@ void frame_adjust_shape(ObFrame *self) } XShapeCombineRectangles(ob_display, self->window, - ShapeBounding, 0, 0, xrect, num, + kind, 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 } @@ -349,7 +341,8 @@ void frame_adjust_area(ObFrame *self, gboolean moved, self->shaded = self->client->shaded; if (self->decorations & OB_FRAME_DECOR_BORDER || - (self->client->undecorated && config_theme_keepborder)) + (self->client->undecorated && config_theme_keepborder + && !self->client->fullscreen)) self->bwidth = ob_rr_theme->fbwidth; else self->bwidth = 0; @@ -607,7 +600,6 @@ void frame_adjust_area(ObFrame *self, gboolean moved, sidebwidth) * 2, self->bwidth); - if (sidebwidth) { XMoveResizeWindow(ob_display, self->lgripleft, 0, @@ -869,7 +861,7 @@ 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)) XResizeWindow(ob_display, self->label, self->label_width, @@ -1154,15 +1146,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 */ @@ -1171,7 +1185,7 @@ static void layout_title(ObFrame *self) self->label_width = self->width - (ob_rr_theme->paddingx + 1) * 2; self->leftmost = self->rightmost = OB_FRAME_CONTEXT_NONE; - /* figure out what's being show, find each element's position, and the + /* figure out what's being shown, find each element's position, and the width of the label do the ones before the label, then after the label, @@ -1201,53 +1215,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; @@ -1297,8 +1281,7 @@ static void layout_title(ObFrame *self) } else XUnmapWindow(ob_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(ob_display, self->label); XMoveWindow(ob_display, self->label, self->label_x, ob_rr_theme->paddingy); @@ -1711,7 +1694,7 @@ static gboolean frame_animate_iconify(gpointer p) g_get_current_time(&now); time = frame_animate_iconify_time_left(self, &now); - if (time == 0 || iconifying) { + if ((time > 0 && iconifying) || (time == 0 && !iconifying)) { /* start where the frame is supposed to be */ x = self->area.x; y = self->area.y; @@ -1742,12 +1725,11 @@ static gboolean frame_animate_iconify(gpointer p) h = self->size.top; /* just the titlebar */ } + XMoveResizeWindow(ob_display, self->window, x, y, w, h); + XFlush(ob_display); + if (time == 0) frame_end_iconify_animation(self); - else { - XMoveResizeWindow(ob_display, self->window, x, y, w, h); - XFlush(ob_display); - } return time > 0; /* repeat until we're out of time */ }