Skip to content

Commit 75672bf

Browse files
committed
feat: layout use tiled_swap from vtable
1 parent b042c50 commit 75672bf

8 files changed

Lines changed: 50 additions & 81 deletions

File tree

src/cursor.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "config.h"
2-
#include "effects.h"
32
#include "cursor.h"
3+
#include "effects.h"
44
#include "idle_power.h"
55
#include "input_method.h"
66
#include "layer.h"
@@ -206,8 +206,8 @@ static void apply_leaf_positions(desktop_t *d) {
206206
int new_fh = r.height + 2 * (int)bw;
207207
if (new_fw > 0 && new_fh > 0) {
208208
float scale = n->client->toplevel && n->client->toplevel->node &&
209-
n->client->toplevel->node->output ?
210-
n->client->toplevel->node->output->wlr_output->scale : 1.0f;
209+
n->client->toplevel->node->output ? n->client->toplevel->node->output->wlr_output->scale :
210+
1.0f;
211211
int pfw = (int)((double)new_fw * scale + 0.5);
212212
int pfh = (int)((double)new_fh * scale + 0.5);
213213
if (rounded->border_shader_buf_w != pfw || rounded->border_shader_buf_h != pfh) {
@@ -496,8 +496,8 @@ static void process_cursor_resize(void) {
496496
int new_fw = new_width + 2 * (int)bw;
497497
int new_fh = new_height + 2 * (int)bw;
498498
if (new_fw > 0 && new_fh > 0) {
499-
float scale = toplevel->node && toplevel->node->output ?
500-
toplevel->node->output->wlr_output->scale : 1.0f;
499+
float scale = toplevel->node &&
500+
toplevel->node->output ? toplevel->node->output->wlr_output->scale : 1.0f;
501501
int pfw = (int)((double)new_fw * scale + 0.5);
502502
int pfh = (int)((double)new_fh * scale + 0.5);
503503
if (toplevel->rounded->border_shader_buf_w != pfw ||

src/effects.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ void effects_fini(void) {
277277
}
278278

279279
static void blur_output_sizes(int width, int height, int *bw, int *bh) {
280-
int ds = (blur_full_res && blur_algorithm == BLUR_ALGORITHM_KAWASE) ? 1
281-
: (blur_downsample > 0 ? blur_downsample : 1);
280+
int ds = (blur_full_res &&
281+
blur_algorithm == BLUR_ALGORITHM_KAWASE) ? 1 : (blur_downsample > 0 ? blur_downsample : 1);
282282
*bw = (width / ds) > 0 ? (width / ds) : 1;
283283
*bh = (height / ds) > 0 ? (height / ds) : 1;
284284
}
@@ -1043,8 +1043,7 @@ static bool rebuild_live_blur_layers(output_t *output, uint64_t bg_tex, pixman_r
10431043
if (!bg_tex)
10441044
return false;
10451045

1046-
if (ctx->layer_blur_buf && ctx->layer_blur_native[0] &&
1047-
ctx->layer_blur_gen == ctx->backdrop_gen)
1046+
if (ctx->layer_blur_buf && ctx->layer_blur_native[0] && ctx->layer_blur_gen == ctx->backdrop_gen)
10481047
return true;
10491048

10501049
if (!ensure_sized_buf(&ctx->layer_blur_buf, ctx->layer_blur_native, &ctx->layer_blur_buf_w,
@@ -1442,8 +1441,8 @@ static bool damage_reaches_visible_surface(output_t *output, effects_output_t *c
14421441
if (!tl->scene_tree || !tl->scene_tree->node.enabled)
14431442
continue;
14441443
// surfaces hidden during the capture cannot change it
1445-
if (!include_blur_toplevels && tl->blur &&
1446-
(tl->blur->blur_node || tl->blur->mica_node || tl->blur->acrylic_node))
1444+
if (!include_blur_toplevels && tl->blur && (tl->blur->blur_node || tl->blur->mica_node ||
1445+
tl->blur->acrylic_node))
14471446
continue;
14481447
struct wlr_box r = get_animated_client_rect(tl);
14491448
pixman_region32_clear(&ctx->scratch_region_a);
@@ -1658,8 +1657,8 @@ void effects_dirty_corner_masks(output_t *output) {
16581657
toplevel_t *tl;
16591658
wl_list_for_each(tl, &server.toplevels, link)
16601659
if (tl->rounded && tl->rounded->corner_mask_node && tl->node && tl->node->client &&
1661-
tl->node->client->border_radius > 0.0f && tl->node->client->state != STATE_FULLSCREEN &&
1662-
tl->node->output && tl->node->output == output)
1660+
tl->node->client->border_radius > 0.0f && tl->node->client->state != STATE_FULLSCREEN &&
1661+
tl->node->output && tl->node->output == output)
16631662
tl->rounded->corner_mask_dirty = true;
16641663
}
16651664

@@ -1767,8 +1766,7 @@ static bool rebuild_corner_masks(output_t *output, uint64_t bg_tex) {
17671766
}
17681767

17691768
effects_backend->capture_readback(cap_state.buffer, &ctx->be_state,
1770-
ctx->be_state.pong.native_handle[0], 0, 0, ctx->blur_w, ctx->blur_h, 0, 0, cw, ch,
1771-
&src);
1769+
ctx->be_state.pong.native_handle[0], 0, 0, ctx->blur_w, ctx->blur_h, 0, 0, cw, ch, &src);
17721770
wlr_output_state_finish(&cap_state);
17731771
if (!src)
17741772
continue;
@@ -2225,7 +2223,7 @@ void effects_output_frame(output_t *output, struct wlr_scene_output *scene_outpu
22252223
int want_bw, want_bh;
22262224
blur_output_sizes(output->width, output->height, &want_bw, &want_bh);
22272225
if (ctx->width != output->width || ctx->height != output->height || ctx->blur_w != want_bw ||
2228-
ctx->blur_h != want_bh)
2226+
ctx->blur_h != want_bh)
22292227
effects_output_resize(ctx, output->width, output->height, output);
22302228

22312229
bool bg_damaged = workspace_warmup || effect_regions_damaged(output,
@@ -2436,7 +2434,7 @@ void effects_output_frame(output_t *output, struct wlr_scene_output *scene_outpu
24362434
int want_bw, want_bh;
24372435
blur_output_sizes(output->width, output->height, &want_bw, &want_bh);
24382436
if (ctx->width != output->width || ctx->height != output->height || ctx->blur_w != want_bw ||
2439-
ctx->blur_h != want_bh)
2437+
ctx->blur_h != want_bh)
24402438
effects_output_resize(ctx, output->width, output->height, output);
24412439
}
24422440

src/effects_gles2.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ static bool gles2_init(struct wlr_renderer *r, struct wlr_allocator *a) {
468468
g->prog_corner_mask = link_program(gl_border_corner_mask_frag_src);
469469
g->prog_shadow = link_program(gl_shadow_frag_src);
470470

471-
if (!g->prog_kawase || !g->prog_blur_down || !g->prog_blur_up || !g->prog_gauss_h || !g->prog_gauss_v ||
472-
!g->prog_box_h || !g->prog_box_v || !g->prog_blit || !g->prog_mica_tint || !g->prog_acrylic_tint ||
473-
!g->prog_refraction) {
471+
if (!g->prog_kawase || !g->prog_blur_down || !g->prog_blur_up || !g->prog_gauss_h ||
472+
!g->prog_gauss_v || !g->prog_box_h || !g->prog_box_v || !g->prog_blit || !g->prog_mica_tint ||
473+
!g->prog_acrylic_tint || !g->prog_refraction) {
474474
wlr_log(WLR_ERROR, "gles2: one or more required shaders failed to compile");
475475
egl_unset_current();
476476
free(g);
@@ -835,8 +835,7 @@ static bool gles2_blur(be_output_state_t *state, uint64_t src_handle, int src_w,
835835
bool final = (i == 0);
836836
int uw = final ? src_w : lw[i - 1];
837837
int uh = final ? src_h : lh[i - 1];
838-
GLuint target = final ? (dst ? dst : (GLuint)state->ping.native_handle[0])
839-
: level_fbo[i - 1];
838+
GLuint target = final ? (dst ? dst : (GLuint)state->ping.native_handle[0]) : level_fbo[i - 1];
840839

841840
glBindFramebuffer(GL_FRAMEBUFFER, target);
842841
glViewport(0, 0, uw, uh);

src/effects_vk.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,8 +1846,8 @@ static bool vk_blur(be_output_state_t *state, uint64_t src_handle, int src_w, in
18461846
}
18471847

18481848
VkRect2D sc[64];
1849-
int n_sc = (scissor && n_scissor > 0) ? vk_scissor_boxes(scissor, n_scissor, src_w, src_h, sc, 64)
1850-
: 0;
1849+
int n_sc = (scissor && n_scissor > 0) ? vk_scissor_boxes(scissor, n_scissor, src_w, src_h, sc,
1850+
64) : 0;
18511851
VkRect2D *scp = n_sc ? sc : NULL;
18521852

18531853
for (int i = 0; i < p->passes; i++) {
@@ -1948,8 +1948,8 @@ static bool vk_blur(be_output_state_t *state, uint64_t src_handle, int src_w, in
19481948
pc.refraction.rf = fringing;
19491949
pc.refraction.rm = p->refraction_texture_repeat_mode;
19501950
pc.refraction.mode = mode;
1951-
vk_draw_full(vk->pipe_refraction, current, dfbo->fb, src_w, src_h, dfbo->img.image, &pc, 128,
1952-
scp, n_sc);
1951+
vk_draw_full(vk->pipe_refraction, current, dfbo->fb, src_w, src_h, dfbo->img.image, &pc, 128, scp,
1952+
n_sc);
19531953
current = dimg;
19541954
} else {
19551955
struct vk_fbo *dfbo = (i & 1) ? fbo1 : fbo0;

src/keyboard.c

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -476,68 +476,28 @@ void swap_west(void) {
476476
if (mon == NULL || mon->desk == NULL || mon->desk->focus == NULL)
477477
return;
478478

479-
desktop_t *d = mon->desk;
480-
481-
if (layout_swap_direction(mon, d, DIR_WEST))
482-
return;
483-
484-
node_t *n = find_fence(d->focus, DIR_WEST);
485-
if (n != NULL) {
486-
n = second_extrema(n);
487-
if (n != NULL)
488-
swap_nodes(mon, d, d->focus, mon, d, n);
489-
}
479+
layout_swap_direction(mon, mon->desk, DIR_WEST);
490480
}
491481

492482
void swap_east(void) {
493483
if (mon == NULL || mon->desk == NULL || mon->desk->focus == NULL)
494484
return;
495485

496-
desktop_t *d = mon->desk;
497-
498-
if (layout_swap_direction(mon, d, DIR_EAST))
499-
return;
500-
501-
node_t *n = find_fence(d->focus, DIR_EAST);
502-
if (n != NULL) {
503-
n = first_extrema(n);
504-
if (n != NULL)
505-
swap_nodes(mon, d, d->focus, mon, d, n);
506-
}
486+
layout_swap_direction(mon, mon->desk, DIR_EAST);
507487
}
508488

509489
void swap_north(void) {
510490
if (mon == NULL || mon->desk == NULL || mon->desk->focus == NULL)
511491
return;
512492

513-
desktop_t *d = mon->desk;
514-
515-
if (layout_swap_direction(mon, d, DIR_NORTH))
516-
return;
517-
518-
node_t *n = find_fence(d->focus, DIR_NORTH);
519-
if (n != NULL) {
520-
n = second_extrema(n);
521-
if (n != NULL)
522-
swap_nodes(mon, d, d->focus, mon, d, n);
523-
}
493+
layout_swap_direction(mon, mon->desk, DIR_NORTH);
524494
}
525495

526496
void swap_south(void) {
527497
if (mon == NULL || mon->desk == NULL || mon->desk->focus == NULL)
528498
return;
529499

530-
desktop_t *d = mon->desk;
531-
532-
if (layout_swap_direction(mon, d, DIR_SOUTH))
533-
return;
534-
535-
node_t *n = find_fence(d->focus, DIR_SOUTH);
536-
if (n != NULL) {
537-
n = first_extrema(n);
538-
if (n != NULL)
539-
swap_nodes(mon, d, d->focus, mon, d, n);
540-
}
500+
layout_swap_direction(mon, mon->desk, DIR_SOUTH);
541501
}
542502

543503
void close_focused(void) {

src/layout.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,25 @@ static bool master_stack_swap(output_t *m, desktop_t *d, direction_t dir) {
154154
return false;
155155
}
156156

157+
static bool tiled_swap(output_t *m, desktop_t *d, direction_t dir) {
158+
(void)m;
159+
node_t *n = find_fence(d->focus, dir);
160+
if (n != NULL) {
161+
n = first_extrema(n);
162+
if (n != NULL) {
163+
swap_nodes(mon, d, d->focus, mon, d, n);
164+
return true;
165+
}
166+
}
167+
return false;
168+
}
169+
157170
static const layout_impl_t tiled_impl = {
158171
.name = "tiled",
159172
.arrange = tiled_arrange,
160173
.on_focus = NULL,
161174
.focus = NULL,
162-
.swap = NULL,
175+
.swap = tiled_swap,
163176
.init_client = NULL,
164177
.collect = tiled_collect,
165178
.single_visible = false,

src/toplevel.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ void toplevel_center_and_clip_surface(toplevel_t *toplevel) {
334334
int new_fw = border_w + 2 * (int)bw;
335335
int new_fh = border_h + 2 * (int)bw;
336336
if (new_fw > 0 && new_fh > 0) {
337-
float scale = toplevel->node && toplevel->node->output ?
338-
toplevel->node->output->wlr_output->scale : 1.0f;
337+
float scale = toplevel->node &&
338+
toplevel->node->output ? toplevel->node->output->wlr_output->scale : 1.0f;
339339
int pfw = (int)((double)new_fw * scale + 0.5);
340340
int pfh = (int)((double)new_fh * scale + 0.5);
341341
if (toplevel->rounded->border_shader_buf_w != pfw ||
@@ -360,8 +360,8 @@ void toplevel_center_and_clip_surface(toplevel_t *toplevel) {
360360
int new_fw = container_rect->width + 2 * (int)bw;
361361
int new_fh = container_rect->height + 2 * (int)bw;
362362
if (new_fw > 0 && new_fh > 0) {
363-
float scale = toplevel->node && toplevel->node->output ?
364-
toplevel->node->output->wlr_output->scale : 1.0f;
363+
float scale = toplevel->node &&
364+
toplevel->node->output ? toplevel->node->output->wlr_output->scale : 1.0f;
365365
int pfw = (int)((double)new_fw * scale + 0.5);
366366
int pfh = (int)((double)new_fh * scale + 0.5);
367367
if (toplevel->rounded->border_shader_buf_w != pfw ||

src/transaction.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,10 @@ static void arrange_node_geometry(node_t *node, transaction_inst_t *instruction)
237237
return;
238238
}
239239

240-
if (node->output && scene_tree &&
241-
(scene_tree->node.x != rect->x || scene_tree->node.y != rect->y ||
242-
(instruction->previous_tiled_rectangle.width > 0 &&
243-
(instruction->previous_tiled_rectangle.width != rect->width ||
244-
instruction->previous_tiled_rectangle.height != rect->height))))
240+
if (node->output && scene_tree && (scene_tree->node.x != rect->x || scene_tree->node.y != rect->y ||
241+
(instruction->previous_tiled_rectangle.width > 0 &&
242+
(instruction->previous_tiled_rectangle.width != rect->width ||
243+
instruction->previous_tiled_rectangle.height != rect->height))))
245244
effects_dirty_corner_masks(node->output);
246245

247246
// attempt resize animation for size changes
@@ -319,7 +318,7 @@ static void arrange_node_geometry(node_t *node, transaction_inst_t *instruction)
319318
int new_fh = geo.height + 2 * (int)bw;
320319
if (new_fw > 0 && new_fh > 0) {
321320
float scale = node->client->toplevel && node->client->toplevel->node &&
322-
node->client->toplevel->node->output ?
321+
node->client->toplevel->node->output ?
323322
node->client->toplevel->node->output->wlr_output->scale : 1.0f;
324323
int pfw = (int)((double)new_fw * scale + 0.5);
325324
int pfh = (int)((double)new_fh * scale + 0.5);

0 commit comments

Comments
 (0)