#include "floating.h"
#include "workspace.h"
#include "log.h"
+#include "container.h"
/* After mapping/unmapping windows, a notify event is generated. However, we don’t want it,
since it’d trigger an infinite loop of switching between the different windows when
if (client->dock)
return 1;
- if (client->container != NULL &&
- (client->container->mode == MODE_STACK ||
- client->container->mode == MODE_TABBED))
+ int mode = container_mode(client->container, true);
+ if (mode == MODE_STACK || mode == MODE_TABBED)
render_container(conn, client->container);
else decorate_window(conn, client, client->frame, client->titlegc, 0, 0);
xcb_flush(conn);
if (client->dock)
return 1;
- if (client->container == NULL ||
- (client->container->mode != MODE_STACK &&
- client->container->mode != MODE_TABBED))
+ if (container_mode(client->container, true) == MODE_DEFAULT)
decorate_window(conn, client, client->frame, client->titlegc, 0, 0);
else {
uint32_t background_color;
/* Draw a black background */
xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
- if (client->titlebar_position == TITLEBAR_OFF) {
+ if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) {
xcb_rectangle_t crect = {1, 0, client->rect.width - (1 + 1), client->rect.height - 1};
xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
} else {
#include "handlers.h"
#include "workspace.h"
#include "log.h"
+#include "container.h"
/*
* Updates *destination with new_value and returns true if it was changed or false
- Draw two lines in a lighter color
- Draw the window’s title
*/
+ int mode = container_mode(client->container, true);
/* Draw a rectangle in background color around the window */
- if (client->borderless && (client->container == NULL ||
- (client->container->mode != MODE_STACK &&
- client->container->mode != MODE_TABBED)))
+ if (client->borderless && mode == MODE_DEFAULT)
xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
else xcb_change_gc_single(conn, gc, XCB_GC_FOREGROUND, color->background);
/* In stacking mode, we only render the rect for this specific decoration */
- if (client->container != NULL && (client->container->mode == MODE_STACK || client->container->mode == MODE_TABBED)) {
+ if (mode == MODE_STACK || mode == MODE_TABBED) {
/* We need to use the container’s width because it is the more recent value - when
in stacking mode, clients get reconfigured only on demand (the not active client
is not reconfigured), so the client’s rect.width would be wrong */
/* Draw the inner background to have a black frame around clients (such as mplayer)
which cannot be resized exactly in our frames and therefore are centered */
xcb_change_gc_single(conn, client->titlegc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
- if (client->titlebar_position == TITLEBAR_OFF) {
+ if (client->titlebar_position == TITLEBAR_OFF && client->borderless) {
+ xcb_rectangle_t crect = {0, 0, client->rect.width, client->rect.height};
+ xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
+ } else if (client->titlebar_position == TITLEBAR_OFF && !client->borderless) {
xcb_rectangle_t crect = {1, 1, client->rect.width - (1 + 1), client->rect.height - (1 + 1)};
xcb_poly_fill_rectangle(conn, client->frame, client->titlegc, 1, &crect);
} else {
}
}
+ mode = container_mode(client->container, false);
+
if (client->titlebar_position != TITLEBAR_OFF) {
/* Draw the lines */
xcb_draw_line(conn, drawable, gc, color->border, offset_x, offset_y, offset_x + client->rect.width, offset_y);
- if ((client->container == NULL ||
- (client->container->mode != MODE_STACK &&
- client->container->mode != MODE_TABBED) ||
- CIRCLEQ_NEXT_OR_NULL(&(client->container->clients), client, clients) == NULL))
+ if (mode == MODE_DEFAULT ||
+ CIRCLEQ_NEXT_OR_NULL(&(client->container->clients), client, clients) == NULL)
xcb_draw_line(conn, drawable, gc, color->border,
offset_x + 2, /* x */
offset_y + font->height + 3, /* y */
/* If the client has a title, we draw it */
if (client->name != NULL &&
- ((client->container != NULL &&
- client->container->mode != MODE_DEFAULT) ||
- client->titlebar_position != TITLEBAR_OFF)) {
+ (mode != MODE_DEFAULT || client->titlebar_position != TITLEBAR_OFF)) {
/* Draw the font */
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT;
uint32_t values[] = { color->text, color->background, font->id };
XCB_CONFIG_WINDOW_WIDTH |
XCB_CONFIG_WINDOW_HEIGHT;
Rect *rect = &(client->child_rect);
- switch ((client->container != NULL ? client->container->mode : MODE_DEFAULT)) {
+ switch (container_mode(client->container, true)) {
case MODE_STACK:
case MODE_TABBED:
rect->x = 2;
/* Check if we need to remap our stack title window, it gets unmapped when the container
is empty in src/handlers.c:unmap_notify() */
- if (stack_win->rect.height == 0 && num_clients > 0) {
+ if (stack_win->rect.height == 0 && num_clients > 1) {
DLOG("remapping stack win\n");
xcb_map_window(conn, stack_win->window);
} else DLOG("not remapping stackwin, height = %d, num_clients = %d\n",
stack_lines = min(num_clients, container->stack_limit_value);
}
+ int height = decoration_height * stack_lines;
+ if (num_clients == 1) {
+ height = 0;
+ stack_win->rect.height = 0;
+ xcb_unmap_window(conn, stack_win->window);
+
+ DLOG("Just one client, setting height to %d\n", height);
+ }
+
/* Check if we need to reconfigure our stack title window */
- if (update_if_necessary(&(stack_win->rect.x), container->x) |
- update_if_necessary(&(stack_win->rect.y), container->y) |
- update_if_necessary(&(stack_win->rect.width), container->width) |
- update_if_necessary(&(stack_win->rect.height), decoration_height * stack_lines)) {
+ if (height > 0 && (
+ update_if_necessary(&(stack_win->rect.x), container->x) |
+ update_if_necessary(&(stack_win->rect.y), container->y) |
+ update_if_necessary(&(stack_win->rect.width), container->width) |
+ update_if_necessary(&(stack_win->rect.height), height))) {
/* Configuration can happen in two slightly different ways:
* Note the bitwise OR instead of logical OR to force evaluation of all statements */
if (client->force_reconfigure |
update_if_necessary(&(client->rect.x), container->x) |
- update_if_necessary(&(client->rect.y), container->y + (decoration_height * stack_lines)) |
+ update_if_necessary(&(client->rect.y), container->y + height) |
update_if_necessary(&(client->rect.width), container->width) |
- update_if_necessary(&(client->rect.height), container->height - (decoration_height * stack_lines)))
+ update_if_necessary(&(client->rect.height), container->height - height))
resize_client(conn, client);
client->force_reconfigure = false;