X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=engines%2Fopenbox%2Fopenbox.c;h=69888b42c6e12cd3b68885758943792344d6f16d;hb=1b20f591af578f0b9dea7c13b4de8f15ab1074af;hp=eab6dfb772d535bee5b6f18aba90c2cd5b2ee739;hpb=797d54d933baf252316d3f79e0f5378f3cbebe7e;p=chaz%2Fopenbox diff --git a/engines/openbox/openbox.c b/engines/openbox/openbox.c index eab6dfb7..69888b42 100644 --- a/engines/openbox/openbox.c +++ b/engines/openbox/openbox.c @@ -176,7 +176,7 @@ gboolean startup() a_unfocused_title = appearance_new(Surface_Planar, 0); a_focused_label = appearance_new(Surface_Planar, 1); a_unfocused_label = appearance_new(Surface_Planar, 1); - a_icon = appearance_new(Surface_Planar, 0);/*1);*/ + a_icon = appearance_new(Surface_Planar, 1); a_focused_handle = appearance_new(Surface_Planar, 0); a_unfocused_handle = appearance_new(Surface_Planar, 0); @@ -406,106 +406,118 @@ void frame_adjust_shape(ObFrame *self) #endif } -void frame_adjust_area(ObFrame *self) +void frame_adjust_area(ObFrame *self, gboolean moved, gboolean resized) { - if (self->frame.client->decorations & Decor_Border) { - self->bwidth = s_bwidth; - self->cbwidth = s_cbwidth; - } else { - self->bwidth = self->cbwidth = 0; - } - STRUT_SET(self->innersize, self->cbwidth, self->cbwidth, - self->cbwidth, self->cbwidth); - self->width = self->frame.client->area.width + self->cbwidth * 2; - g_assert(self->width > 0); - - /* set border widths */ - XSetWindowBorderWidth(ob_display, self->frame.plate, self->cbwidth); - XSetWindowBorderWidth(ob_display, self->frame.window, self->bwidth); - XSetWindowBorderWidth(ob_display, self->title, self->bwidth); - XSetWindowBorderWidth(ob_display, self->handle, self->bwidth); - XSetWindowBorderWidth(ob_display, self->lgrip, self->bwidth); - XSetWindowBorderWidth(ob_display, self->rgrip, self->bwidth); + if (resized) { + if (self->frame.client->decorations & Decor_Border) { + self->bwidth = s_bwidth; + self->cbwidth = s_cbwidth; + } else { + self->bwidth = self->cbwidth = 0; + } + STRUT_SET(self->innersize, self->cbwidth, self->cbwidth, + self->cbwidth, self->cbwidth); + self->width = self->frame.client->area.width + self->cbwidth * 2; + g_assert(self->width > 0); + + /* set border widths */ + XSetWindowBorderWidth(ob_display, self->frame.plate, self->cbwidth); + XSetWindowBorderWidth(ob_display, self->frame.window, self->bwidth); + XSetWindowBorderWidth(ob_display, self->title, self->bwidth); + XSetWindowBorderWidth(ob_display, self->handle, self->bwidth); + XSetWindowBorderWidth(ob_display, self->lgrip, self->bwidth); + XSetWindowBorderWidth(ob_display, self->rgrip, self->bwidth); - /* position/size and map/unmap all the windows */ - - /* they all default off, they're turned on in layout_title */ - self->icon_x = -1; - self->desk_x = -1; - self->icon_x = -1; - self->label_x = -1; - self->max_x = -1; - self->close_x = -1; - - if (self->frame.client->decorations & Decor_Titlebar) { - XMoveResizeWindow(ob_display, self->title, - -self->bwidth, -self->bwidth, - self->width, TITLE_HEIGHT); - self->innersize.top += TITLE_HEIGHT + self->bwidth; - XMapWindow(ob_display, self->title); - - /* layout the title bar elements */ - layout_title(self); - } else { - XUnmapWindow(ob_display, self->title); - /* make all the titlebar stuff not render */ - self->frame.client->decorations &= ~(Decor_Icon | Decor_Iconify | - Decor_Maximize | Decor_Close | - Decor_AllDesktops); + /* position/size and map/unmap all the windows */ + + /* they all default off, they're turned on in layout_title */ + self->icon_x = -1; + self->desk_x = -1; + self->icon_x = -1; + self->label_x = -1; + self->max_x = -1; + self->close_x = -1; + + if (self->frame.client->decorations & Decor_Titlebar) { + XMoveResizeWindow(ob_display, self->title, + -self->bwidth, -self->bwidth, + self->width, TITLE_HEIGHT); + self->innersize.top += TITLE_HEIGHT + self->bwidth; + XMapWindow(ob_display, self->title); + + /* layout the title bar elements */ + layout_title(self); + } else { + XUnmapWindow(ob_display, self->title); + /* make all the titlebar stuff not render */ + self->frame.client->decorations &= ~(Decor_Icon | Decor_Iconify | + Decor_Maximize | Decor_Close | + Decor_AllDesktops); + } + + if (self->frame.client->decorations & Decor_Handle) { + XMoveResizeWindow(ob_display, self->handle, + -self->bwidth, HANDLE_Y(self), + self->width, s_handle_height); + XMoveWindow(ob_display, self->lgrip, + -self->bwidth, -self->bwidth); + XMoveWindow(ob_display, self->rgrip, + -self->bwidth + self->width - + GRIP_WIDTH, -self->bwidth); + self->innersize.bottom += s_handle_height + + self->bwidth; + XMapWindow(ob_display, self->handle); + } else + XUnmapWindow(ob_display, self->handle); } - if (self->frame.client->decorations & Decor_Handle) { - XMoveResizeWindow(ob_display, self->handle, - -self->bwidth, HANDLE_Y(self), - self->width, s_handle_height); - XMoveWindow(ob_display, self->lgrip, - -self->bwidth, -self->bwidth); - XMoveWindow(ob_display, self->rgrip, - -self->bwidth + self->width - - GRIP_WIDTH, -self->bwidth); - self->innersize.bottom += s_handle_height + - self->bwidth; - XMapWindow(ob_display, self->handle); - } else - XUnmapWindow(ob_display, self->handle); - - /* find the new coordinates */ - self->frame.area.x = self->frame.client->area.x; - self->frame.area.y = self->frame.client->area.y; - frame_client_gravity((Frame*)self, - &self->frame.area.x, &self->frame.area.y); - /* move and resize the top level frame */ - XMoveResizeWindow(ob_display, self->frame.window, - self->frame.area.x, self->frame.area.y, - self->width, - (self->frame.client->shaded ? TITLE_HEIGHT : - self->innersize.top + self->innersize.bottom + - self->frame.client->area.height)); - - /* move and resize the plate */ - XMoveResizeWindow(ob_display, self->frame.plate, - self->innersize.left - self->cbwidth, - self->innersize.top - self->cbwidth, - self->frame.client->area.width, - self->frame.client->area.height); - /* when the client has StaticGravity, it likes to move around. */ - XMoveWindow(ob_display, self->frame.client->window, 0, 0); - - STRUT_SET(self->frame.size, - self->innersize.left + self->bwidth, - self->innersize.top + self->bwidth, - self->innersize.right + self->bwidth, - self->innersize.bottom + self->bwidth); + if (resized) { + /* move and resize the plate */ + XMoveResizeWindow(ob_display, self->frame.plate, + self->innersize.left - self->cbwidth, + self->innersize.top - self->cbwidth, + self->frame.client->area.width, + self->frame.client->area.height); + /* when the client has StaticGravity, it likes to move around. */ + XMoveWindow(ob_display, self->frame.client->window, 0, 0); + } + + if (resized) { + STRUT_SET(self->frame.size, + self->innersize.left + self->bwidth, + self->innersize.top + self->bwidth, + self->innersize.right + self->bwidth, + self->innersize.bottom + self->bwidth); + } + /* shading can change without being moved or resized */ RECT_SET_SIZE(self->frame.area, self->frame.client->area.width + self->frame.size.left + self->frame.size.right, - self->frame.client->area.height + - self->frame.size.top + self->frame.size.bottom); + (self->frame.client->shaded ? TITLE_HEIGHT + self->bwidth*2: + self->frame.client->area.height + + self->frame.size.top + self->frame.size.bottom)); + + if (moved) { + /* find the new coordinates, done after setting the frame.size, for + frame_client_gravity. */ + self->frame.area.x = self->frame.client->area.x; + self->frame.area.y = self->frame.client->area.y; + frame_client_gravity((Frame*)self, + &self->frame.area.x, &self->frame.area.y); + } - render(self); + /* move and resize the top level frame. + shading can change without being moved or resized */ + XMoveResizeWindow(ob_display, self->frame.window, + self->frame.area.x, self->frame.area.y, + self->width, self->frame.area.height - self->bwidth * 2); - frame_adjust_shape(self); + if (resized) { + render(self); + + frame_adjust_shape(self); + } } void frame_adjust_state(ObFrame *self) @@ -553,21 +565,21 @@ void frame_grab_client(ObFrame *self, Client *client) /* map the client so it maps when the frame does */ XMapWindow(ob_display, client->window); - frame_adjust_area(self); + frame_adjust_area(self, TRUE, TRUE); /* set all the windows for the frame in the client_map */ - g_hash_table_insert(client_map, (gpointer)self->frame.window, client); - g_hash_table_insert(client_map, (gpointer)self->frame.plate, client); - g_hash_table_insert(client_map, (gpointer)self->title, client); - g_hash_table_insert(client_map, (gpointer)self->label, client); - g_hash_table_insert(client_map, (gpointer)self->max, client); - g_hash_table_insert(client_map, (gpointer)self->close, client); - g_hash_table_insert(client_map, (gpointer)self->desk, client); - g_hash_table_insert(client_map, (gpointer)self->icon, client); - g_hash_table_insert(client_map, (gpointer)self->iconify, client); - g_hash_table_insert(client_map, (gpointer)self->handle, client); - g_hash_table_insert(client_map, (gpointer)self->lgrip, client); - g_hash_table_insert(client_map, (gpointer)self->rgrip, client); + g_hash_table_insert(client_map, &self->frame.window, client); + g_hash_table_insert(client_map, &self->frame.plate, client); + g_hash_table_insert(client_map, &self->title, client); + g_hash_table_insert(client_map, &self->label, client); + g_hash_table_insert(client_map, &self->max, client); + g_hash_table_insert(client_map, &self->close, client); + g_hash_table_insert(client_map, &self->desk, client); + g_hash_table_insert(client_map, &self->icon, client); + g_hash_table_insert(client_map, &self->iconify, client); + g_hash_table_insert(client_map, &self->handle, client); + g_hash_table_insert(client_map, &self->lgrip, client); + g_hash_table_insert(client_map, &self->rgrip, client); } void frame_release_client(ObFrame *self, Client *client) @@ -591,18 +603,18 @@ void frame_release_client(ObFrame *self, Client *client) } /* remove all the windows for the frame from the client_map */ - g_hash_table_remove(client_map, (gpointer)self->frame.window); - g_hash_table_remove(client_map, (gpointer)self->frame.plate); - g_hash_table_remove(client_map, (gpointer)self->title); - g_hash_table_remove(client_map, (gpointer)self->label); - g_hash_table_remove(client_map, (gpointer)self->max); - g_hash_table_remove(client_map, (gpointer)self->close); - g_hash_table_remove(client_map, (gpointer)self->desk); - g_hash_table_remove(client_map, (gpointer)self->icon); - g_hash_table_remove(client_map, (gpointer)self->iconify); - g_hash_table_remove(client_map, (gpointer)self->handle); - g_hash_table_remove(client_map, (gpointer)self->lgrip); - g_hash_table_remove(client_map, (gpointer)self->rgrip); + g_hash_table_remove(client_map, &self->frame.window); + g_hash_table_remove(client_map, &self->frame.plate); + g_hash_table_remove(client_map, &self->title); + g_hash_table_remove(client_map, &self->label); + g_hash_table_remove(client_map, &self->max); + g_hash_table_remove(client_map, &self->close); + g_hash_table_remove(client_map, &self->desk); + g_hash_table_remove(client_map, &self->icon); + g_hash_table_remove(client_map, &self->iconify); + g_hash_table_remove(client_map, &self->handle); + g_hash_table_remove(client_map, &self->lgrip); + g_hash_table_remove(client_map, &self->rgrip); frame_free(self); } @@ -767,6 +779,7 @@ static void render_label(ObFrame *self) /* set the texture's text! */ a->texture[0].data.text.string = self->frame.client->title; + RECT_SET(a->texture[0].position, 0, 0, self->label_width, LABEL_HEIGHT); paint(self->label, a, 0, 0, self->label_width, LABEL_HEIGHT); } @@ -775,70 +788,80 @@ static void render_icon(ObFrame *self) { if (self->icon_x < 0) return; - /* XXX set the texture's icon picture! */ + if (self->frame.client->nicons) { + Icon *icon = client_icon(self->frame.client, BUTTON_SIZE, BUTTON_SIZE); + self->a_icon->texture[0].type = RGBA; + self->a_icon->texture[0].data.rgba.width = icon->width; + self->a_icon->texture[0].data.rgba.height = icon->height; + self->a_icon->texture[0].data.rgba.data = icon->data; + RECT_SET(self->a_icon->texture[0].position, 0, 0, + BUTTON_SIZE,BUTTON_SIZE); + } else + self->a_icon->texture[0].type = NoTexture; + paint(self->icon, self->a_icon, 0, 0, BUTTON_SIZE, BUTTON_SIZE); } static void render_max(ObFrame *self) { + Appearance *a; + gboolean press = self->max_press || self->frame.client->max_vert || self->frame.client->max_horz; if (self->max_x < 0) return; - paint(self->max, (client_focused(self->frame.client) ? - (press ? - a_focused_pressed_max : - a_focused_unpressed_max) : - (press ? - a_unfocused_pressed_max : - a_unfocused_unpressed_max)), - 0, 0, BUTTON_SIZE, BUTTON_SIZE); + a = (client_focused(self->frame.client) ? + (press ? a_focused_pressed_max : a_focused_unpressed_max) : + (press ? a_unfocused_pressed_max : a_unfocused_unpressed_max)); + RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); + paint(self->max, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); } static void render_iconify(ObFrame *self) { + Appearance *a; + if (self->iconify_x < 0) return; - paint(self->iconify, (client_focused(self->frame.client) ? - (self->iconify_press ? - a_focused_pressed_iconify : - a_focused_unpressed_iconify) : - (self->iconify_press ? - a_unfocused_pressed_iconify : - a_unfocused_unpressed_iconify)), - 0, 0, BUTTON_SIZE, BUTTON_SIZE); + a = (client_focused(self->frame.client) ? + (self->iconify_press ? + a_focused_pressed_iconify : a_focused_unpressed_iconify) : + (self->iconify_press ? + a_unfocused_pressed_iconify : a_unfocused_unpressed_iconify)); + RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); + paint(self->iconify, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); } static void render_desk(ObFrame *self) { + Appearance *a; + gboolean press = self->desk_press || self->frame.client->desktop == DESKTOP_ALL; if (self->desk_x < 0) return; - paint(self->desk, (client_focused(self->frame.client) ? - (press ? - a_focused_pressed_desk : - a_focused_unpressed_desk) : - (press ? - a_unfocused_pressed_desk : - a_unfocused_unpressed_desk)), - 0, 0, BUTTON_SIZE, BUTTON_SIZE); + a = (client_focused(self->frame.client) ? + (press ? a_focused_pressed_desk : a_focused_unpressed_desk) : + (press ? a_unfocused_pressed_desk : a_unfocused_unpressed_desk)); + RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); + paint(self->desk, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); } static void render_close(ObFrame *self) { + Appearance *a; + if (self->close_x < 0) return; - paint(self->close, (client_focused(self->frame.client) ? - (self->close_press ? - a_focused_pressed_close : - a_focused_unpressed_close) : - (self->close_press ? - a_unfocused_pressed_close : - a_unfocused_unpressed_close)), - 0, 0, BUTTON_SIZE, BUTTON_SIZE); + a = (client_focused(self->frame.client) ? + (self->close_press ? + a_focused_pressed_close : a_focused_unpressed_close) : + (self->close_press ? + a_unfocused_pressed_close : a_unfocused_unpressed_close)); + RECT_SET(a->texture[0].position, 0, 0, BUTTON_SIZE,BUTTON_SIZE); + paint(self->close, a, 0, 0, BUTTON_SIZE, BUTTON_SIZE); } GQuark get_context(Client *client, Window win)