Skip to content

Commit

Permalink
Add comments (i3#3479)
Browse files Browse the repository at this point in the history
  • Loading branch information
buchankn committed Feb 23, 2023
1 parent f252e68 commit 6c973da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/sparse_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void sparse_surface_create_and_init(xcb_connection_t *conn, sparse_surface_t *sp
visual = visual_type;

if(top_height == 0 && bottom_height == 0 && left_width == 0 && right_width == 0) {
/* There is only one pixmap for the top of the window, of size width, height */
for(i = 0; i < SPARSE_SURFACE_SIDE_COUNT; i++) {
sparse_surface->x_offset[i] = 0;
sparse_surface->y_offset[i] = 0;
Expand All @@ -91,6 +92,7 @@ void sparse_surface_create_and_init(xcb_connection_t *conn, sparse_surface_t *sp
sparse_surface->x_offset[SPARSE_SURFACE_TOP] = 0;
sparse_surface->y_offset[SPARSE_SURFACE_TOP] = 0;
} else {
/* Calculate the size and position of each of the four side pixmaps */
sparse_surface->side_surface[SPARSE_SURFACE_TOP].width = width - (left_width + right_width);
sparse_surface->side_surface[SPARSE_SURFACE_TOP].height = top_height;
sparse_surface->x_offset[SPARSE_SURFACE_TOP] = left_width;
Expand All @@ -112,6 +114,7 @@ void sparse_surface_create_and_init(xcb_connection_t *conn, sparse_surface_t *sp
sparse_surface->y_offset[SPARSE_SURFACE_RIGHT] = 0;
}

/* Create each of the four pixmaps */
for(i = 0; i < SPARSE_SURFACE_SIDE_COUNT; i++) {
if(sparse_surface->side_surface[i].width == 0 || sparse_surface->side_surface[i].height == 0) {
if (sparse_surface->side_surface[i].id != XCB_NONE) {
Expand Down Expand Up @@ -150,6 +153,7 @@ void sparse_surface_create_and_init(xcb_connection_t *conn, sparse_surface_t *sp

sparse_surface->side_surface[i].cr = cairo_create(sparse_surface->side_surface[i].surface);

/* Position this pixmap */
cairo_translate(sparse_surface->side_surface[i].cr,
-(sparse_surface->x_offset[i]),
-(sparse_surface->y_offset[i]));
Expand Down
10 changes: 9 additions & 1 deletion src/x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,18 +1013,26 @@ void x_push_node(Con *con) {

if (con->window == NULL && (con->layout == L_STACKED || con->layout == L_TABBED)) {
/* No "holes" in this pixmap, it is just one pixmap (the stacked or tabbed top decoration) */
/* The pixmap size will be width, height */
top_height = 0;
bottom_height = 0;
left_width = 0;
right_width = 0;
} else {
/* Figure out the size of each side of the window pixmaps */
/* Height of the top window border pixmap */
top_height = con->window_rect.y;

/* Height of the bottom window border pixmap */
bottom_height = (con->rect.height - con->window_rect.height) - top_height;

/* Width of the left window border pixmap */
left_width = con->window_rect.x;

/* Width of the right window border pixmap */
right_width = (con->rect.width - con->window_rect.width) - left_width;
}

/* Create the pixmaps for the top, bottom, left, and right window borders */
sparse_surface_create_and_init(conn, &(con->frame_buffer),
con->frame.id,
win_depth,
Expand Down

0 comments on commit 6c973da

Please sign in to comment.