mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-06 06:46:54 -04:00
feat: support corner radius
This commit is contained in:
parent
aa0e1e1fe9
commit
fc9f33a7c3
5 changed files with 242 additions and 139 deletions
|
|
@ -37,6 +37,7 @@ wlroots_dep = dependency('wlroots-0.19')
|
||||||
xkbcommon_dep = dependency('xkbcommon')
|
xkbcommon_dep = dependency('xkbcommon')
|
||||||
libinput_dep = dependency('libinput')
|
libinput_dep = dependency('libinput')
|
||||||
libwayland_client_dep = dependency('wayland-client')
|
libwayland_client_dep = dependency('wayland-client')
|
||||||
|
libscenefx_dep = dependency('scenefx-0.2')
|
||||||
|
|
||||||
# 获取 Git Commit Hash 和最新的 tag
|
# 获取 Git Commit Hash 和最新的 tag
|
||||||
git = find_program('git', required : false)
|
git = find_program('git', required : false)
|
||||||
|
|
@ -75,6 +76,7 @@ executable('maomao',
|
||||||
xcb,
|
xcb,
|
||||||
xlibs,
|
xlibs,
|
||||||
wayland_server_dep,
|
wayland_server_dep,
|
||||||
|
libscenefx_dep,
|
||||||
wlroots_dep,
|
wlroots_dep,
|
||||||
xkbcommon_dep,
|
xkbcommon_dep,
|
||||||
libinput_dep,
|
libinput_dep,
|
||||||
|
|
|
||||||
|
|
@ -302,9 +302,7 @@ static inline void client_send_close(Client *c) {
|
||||||
|
|
||||||
static inline void client_set_border_color(Client *c,
|
static inline void client_set_border_color(Client *c,
|
||||||
const float color[static 4]) {
|
const float color[static 4]) {
|
||||||
int i;
|
wlr_scene_rect_set_color(c->border, color);
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
wlr_scene_rect_set_color(c->border[i], color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,8 @@ typedef struct {
|
||||||
float *scroller_proportion_preset;
|
float *scroller_proportion_preset;
|
||||||
int scroller_proportion_preset_count;
|
int scroller_proportion_preset_count;
|
||||||
|
|
||||||
|
int border_radius;
|
||||||
|
|
||||||
char **circle_layout;
|
char **circle_layout;
|
||||||
int circle_layout_count;
|
int circle_layout_count;
|
||||||
|
|
||||||
|
|
@ -758,6 +760,8 @@ void parse_config_line(Config *config, const char *line) {
|
||||||
config->focus_cross_monitor = atoi(value);
|
config->focus_cross_monitor = atoi(value);
|
||||||
} else if (strcmp(key, "focus_cross_tag") == 0) {
|
} else if (strcmp(key, "focus_cross_tag") == 0) {
|
||||||
config->focus_cross_tag = atoi(value);
|
config->focus_cross_tag = atoi(value);
|
||||||
|
} else if (strcmp(key, "border_radius") == 0) {
|
||||||
|
config->border_radius = atoi(value);
|
||||||
} else if (strcmp(key, "single_scratchpad") == 0) {
|
} else if (strcmp(key, "single_scratchpad") == 0) {
|
||||||
config->single_scratchpad = atoi(value);
|
config->single_scratchpad = atoi(value);
|
||||||
} else if (strcmp(key, "no_border_when_single") == 0) {
|
} else if (strcmp(key, "no_border_when_single") == 0) {
|
||||||
|
|
@ -1763,6 +1767,7 @@ void override_config(void) {
|
||||||
scroller_focus_center = config.scroller_focus_center;
|
scroller_focus_center = config.scroller_focus_center;
|
||||||
focus_cross_monitor = config.focus_cross_monitor;
|
focus_cross_monitor = config.focus_cross_monitor;
|
||||||
focus_cross_tag = config.focus_cross_tag;
|
focus_cross_tag = config.focus_cross_tag;
|
||||||
|
border_radius = config.border_radius;
|
||||||
single_scratchpad = config.single_scratchpad;
|
single_scratchpad = config.single_scratchpad;
|
||||||
no_border_when_single = config.no_border_when_single;
|
no_border_when_single = config.no_border_when_single;
|
||||||
snap_distance = config.snap_distance;
|
snap_distance = config.snap_distance;
|
||||||
|
|
@ -1865,6 +1870,7 @@ void set_value_default() {
|
||||||
config.scroller_prefer_center = scroller_prefer_center;
|
config.scroller_prefer_center = scroller_prefer_center;
|
||||||
config.focus_cross_monitor = focus_cross_monitor;
|
config.focus_cross_monitor = focus_cross_monitor;
|
||||||
config.focus_cross_tag = focus_cross_tag;
|
config.focus_cross_tag = focus_cross_tag;
|
||||||
|
config.border_radius = border_radius;
|
||||||
config.single_scratchpad = single_scratchpad;
|
config.single_scratchpad = single_scratchpad;
|
||||||
config.no_border_when_single = no_border_when_single;
|
config.no_border_when_single = no_border_when_single;
|
||||||
config.snap_distance = snap_distance;
|
config.snap_distance = snap_distance;
|
||||||
|
|
@ -2016,7 +2022,6 @@ void reload_config(const Arg *arg) {
|
||||||
init_baked_points();
|
init_baked_points();
|
||||||
handlecursoractivity();
|
handlecursoractivity();
|
||||||
run_exec();
|
run_exec();
|
||||||
|
|
||||||
// reset border width when config change
|
// reset border width when config change
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (c && !c->iskilling) {
|
if (c && !c->iskilling) {
|
||||||
|
|
|
||||||
|
|
@ -164,3 +164,10 @@ enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||||
static const char *tags[] = {
|
static const char *tags[] = {
|
||||||
"1", "2", "3", "4", "5", "6", "7", "8", "9",
|
"1", "2", "3", "4", "5", "6", "7", "8", "9",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int border_radius = 10;
|
||||||
|
int border_radius_location_default = CORNER_LOCATION_ALL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
361
src/maomao.c
361
src/maomao.c
|
|
@ -13,6 +13,11 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <scenefx/render/fx_renderer/fx_renderer.h>
|
||||||
|
#include <scenefx/types/fx/blur_data.h>
|
||||||
|
#include <scenefx/types/fx/clipped_region.h>
|
||||||
|
#include <scenefx/types/fx/corner_location.h>
|
||||||
|
#include <scenefx/types/wlr_scene.h>
|
||||||
#include <wayland-server-core.h>
|
#include <wayland-server-core.h>
|
||||||
#include <wlr/backend.h>
|
#include <wlr/backend.h>
|
||||||
#include <wlr/backend/headless.h>
|
#include <wlr/backend/headless.h>
|
||||||
|
|
@ -51,7 +56,6 @@
|
||||||
#include <wlr/types/wlr_primary_selection.h>
|
#include <wlr/types/wlr_primary_selection.h>
|
||||||
#include <wlr/types/wlr_primary_selection_v1.h>
|
#include <wlr/types/wlr_primary_selection_v1.h>
|
||||||
#include <wlr/types/wlr_relative_pointer_v1.h>
|
#include <wlr/types/wlr_relative_pointer_v1.h>
|
||||||
#include <wlr/types/wlr_scene.h>
|
|
||||||
#include <wlr/types/wlr_screencopy_v1.h>
|
#include <wlr/types/wlr_screencopy_v1.h>
|
||||||
#include <wlr/types/wlr_seat.h>
|
#include <wlr/types/wlr_seat.h>
|
||||||
#include <wlr/types/wlr_server_decoration.h>
|
#include <wlr/types/wlr_server_decoration.h>
|
||||||
|
|
@ -198,6 +202,7 @@ typedef struct {
|
||||||
float height_scale;
|
float height_scale;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
enum corner_location corner_location;
|
||||||
bool should_scale;
|
bool should_scale;
|
||||||
} animationScale;
|
} animationScale;
|
||||||
|
|
||||||
|
|
@ -209,7 +214,7 @@ struct Client {
|
||||||
overview_backup_geom, current; /* layout-relative, includes border */
|
overview_backup_geom, current; /* layout-relative, includes border */
|
||||||
Monitor *mon;
|
Monitor *mon;
|
||||||
struct wlr_scene_tree *scene;
|
struct wlr_scene_tree *scene;
|
||||||
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
struct wlr_scene_rect *border; /* top, bottom, left, right */
|
||||||
struct wlr_scene_tree *scene_surface;
|
struct wlr_scene_tree *scene_surface;
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list flink;
|
struct wl_list flink;
|
||||||
|
|
@ -621,7 +626,7 @@ static unsigned int get_tags_first_tag(unsigned int tags);
|
||||||
|
|
||||||
static void client_commit(Client *c);
|
static void client_commit(Client *c);
|
||||||
static void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
static void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
int offsety);
|
int offsety, enum corner_location current_corner_location);
|
||||||
static void client_set_opacity(Client *c, double opacity);
|
static void client_set_opacity(Client *c, double opacity);
|
||||||
static void init_baked_points(void);
|
static void init_baked_points(void);
|
||||||
static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx,
|
static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx,
|
||||||
|
|
@ -966,7 +971,7 @@ void fadeout_client_animation_next_tick(Client *c) {
|
||||||
scale_data.width_scale = animation_passed;
|
scale_data.width_scale = animation_passed;
|
||||||
scale_data.height_scale = animation_passed;
|
scale_data.height_scale = animation_passed;
|
||||||
|
|
||||||
wlr_scene_node_for_each_buffer(&c->scene->node,
|
wlr_scene_node_for_each_buffer(&c->scene_surface->node,
|
||||||
snap_scene_buffer_apply_effect, &scale_data);
|
snap_scene_buffer_apply_effect, &scale_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1063,7 +1068,7 @@ void set_rect_size(struct wlr_scene_rect *rect, int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
int offsety) {
|
int offsety, enum corner_location border_radius_location) {
|
||||||
int i;
|
int i;
|
||||||
bool hit_no_border = false;
|
bool hit_no_border = false;
|
||||||
|
|
||||||
|
|
@ -1097,10 +1102,7 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
c->bw = 0;
|
c->bw = 0;
|
||||||
c->fake_no_border = true;
|
c->fake_no_border = true;
|
||||||
} else if (hit_no_border && !smartgaps) {
|
} else if (hit_no_border && !smartgaps) {
|
||||||
set_rect_size(c->border[0], 0, 0);
|
wlr_scene_rect_set_size(c->border, 0, 0);
|
||||||
set_rect_size(c->border[1], 0, 0);
|
|
||||||
set_rect_size(c->border[2], 0, 0);
|
|
||||||
set_rect_size(c->border[3], 0, 0);
|
|
||||||
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||||
c->fake_no_border = true;
|
c->fake_no_border = true;
|
||||||
return;
|
return;
|
||||||
|
|
@ -1109,59 +1111,59 @@ void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
|
||||||
c->fake_no_border = false;
|
c->fake_no_border = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
int clip_box_width = clip_box.width - 2 * c->bw;
|
||||||
set_rect_size(c->border[0], clip_box.width, c->bw);
|
int clip_box_height = clip_box.height - 2 * c->bw;
|
||||||
set_rect_size(c->border[1], clip_box.width, c->bw);
|
|
||||||
set_rect_size(c->border[2], c->bw, clip_box.height - 2 * c->bw);
|
|
||||||
set_rect_size(c->border[3], c->bw, clip_box.height - 2 * c->bw);
|
|
||||||
wlr_scene_node_set_position(&c->border[0]->node, 0, 0);
|
|
||||||
wlr_scene_node_set_position(&c->border[2]->node, 0, c->bw);
|
|
||||||
wlr_scene_node_set_position(&c->border[1]->node, 0, clip_box.height - c->bw);
|
|
||||||
wlr_scene_node_set_position(&c->border[3]->node, clip_box.width - c->bw,
|
|
||||||
c->bw);
|
|
||||||
|
|
||||||
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
|
if(clip_box_width < 0) {
|
||||||
c->animation.tagouting) {
|
clip_box_width = 0;
|
||||||
if (c->animation.current.x < c->mon->m.x) {
|
|
||||||
set_rect_size(c->border[2], GEZERO(c->bw - offsetx),
|
|
||||||
clip_box.height - 2 * c->bw);
|
|
||||||
} else if (c->animation.current.x + c->animation.current.width >
|
|
||||||
c->mon->m.x + c->mon->m.width) {
|
|
||||||
set_rect_size(c->border[3],
|
|
||||||
GEZERO(c->bw - GEZERO(c->animation.current.x +
|
|
||||||
c->animation.current.width -
|
|
||||||
c->mon->m.x - c->mon->m.width)),
|
|
||||||
clip_box.height - 2 * c->bw);
|
|
||||||
set_rect_size(c->border[0], clip_box.width + c->bw,
|
|
||||||
GEZERO(c->bw - offsety));
|
|
||||||
set_rect_size(c->border[1], clip_box.width + c->bw,
|
|
||||||
GEZERO(c->bw - GEZERO(c->animation.current.y +
|
|
||||||
c->animation.current.height -
|
|
||||||
c->mon->m.y - c->mon->m.height)));
|
|
||||||
} else if (c->animation.current.y < c->mon->m.y) {
|
|
||||||
set_rect_size(c->border[0], clip_box.width, GEZERO(c->bw - offsety));
|
|
||||||
} else if (c->animation.current.y + c->animation.current.height >
|
|
||||||
c->mon->m.y + c->mon->m.height) {
|
|
||||||
set_rect_size(c->border[1], clip_box.width,
|
|
||||||
GEZERO(c->bw - GEZERO(c->animation.current.y +
|
|
||||||
c->animation.current.height -
|
|
||||||
c->mon->m.y - c->mon->m.height)));
|
|
||||||
set_rect_size(c->border[2], GEZERO(c->bw - offsetx),
|
|
||||||
clip_box.height - c->bw);
|
|
||||||
set_rect_size(c->border[3],
|
|
||||||
GEZERO(c->bw - GEZERO(c->animation.current.x +
|
|
||||||
c->animation.current.width -
|
|
||||||
c->mon->m.x - c->mon->m.width)),
|
|
||||||
clip_box.height - c->bw);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_scene_node_set_position(&c->border[0]->node, offsetx, offsety);
|
if(clip_box_height < 0) {
|
||||||
wlr_scene_node_set_position(&c->border[2]->node, offsetx, c->bw + offsety);
|
clip_box_height = 0;
|
||||||
wlr_scene_node_set_position(&c->border[1]->node, offsetx,
|
}
|
||||||
clip_box.height - c->bw + offsety);
|
|
||||||
wlr_scene_node_set_position(
|
int clip_x = c->bw - offsetx;
|
||||||
&c->border[3]->node, clip_box.width - c->bw + offsetx, c->bw + offsety);
|
int clip_y = c->bw - offsety;
|
||||||
|
|
||||||
|
clip_x = clip_x < 0 ? 0 : clip_x;
|
||||||
|
clip_y = clip_y < 0 ? 0 : clip_y;
|
||||||
|
|
||||||
|
struct clipped_region clipped_region = {
|
||||||
|
.area = { clip_x, clip_y, clip_box_width, clip_box_height },
|
||||||
|
.corner_radius = border_radius,
|
||||||
|
.corners = border_radius_location,
|
||||||
|
};
|
||||||
|
|
||||||
|
int right_offset = GEZERO(c->animation.current.x + c->animation.current.width - c->mon->m.x - c->mon->m.width);
|
||||||
|
int bottom_offset = GEZERO(c->animation.current.y + c->animation.current.height - c->mon->m.y - c->mon->m.height);
|
||||||
|
int rect_width = clip_box.width;
|
||||||
|
int rect_height = clip_box.height;
|
||||||
|
|
||||||
|
|
||||||
|
if(right_offset > 0) {
|
||||||
|
clipped_region.area.width = MIN(clip_box.width,clipped_region.area.width + right_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bottom_offset > 0) {
|
||||||
|
clipped_region.area.height = MIN(clip_box.height,clipped_region.area.height + bottom_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rect_width < 0) {
|
||||||
|
rect_width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(rect_height < 0) {
|
||||||
|
rect_height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int node_x = offsetx;
|
||||||
|
int node_y = offsety;
|
||||||
|
|
||||||
|
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
|
||||||
|
wlr_scene_rect_set_size(c->border, rect_width, rect_height);
|
||||||
|
wlr_scene_node_set_position(&c->border->node, node_x, node_y);
|
||||||
|
wlr_scene_rect_set_corner_radius(c->border, border_radius, border_radius_location);
|
||||||
|
wlr_scene_rect_set_clipped_region(c->border, clipped_region);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
||||||
|
|
@ -1226,6 +1228,24 @@ struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum corner_location set_client_corner_location(Client *c) {
|
||||||
|
enum corner_location current_corner_location = CORNER_LOCATION_ALL;
|
||||||
|
struct wlr_box target_geom = animations ? c->animation.current : c->geom;
|
||||||
|
if(target_geom.x + border_radius <= c->mon->m.x) {
|
||||||
|
current_corner_location &= ~CORNER_LOCATION_LEFT; // 清除左标志位
|
||||||
|
}
|
||||||
|
if(target_geom.x + target_geom.width - border_radius >= c->mon->m.x + c->mon->m.width) {
|
||||||
|
current_corner_location &= ~CORNER_LOCATION_RIGHT; // 清除右标志位
|
||||||
|
}
|
||||||
|
if(target_geom.y + border_radius <= c->mon->m.y) {
|
||||||
|
current_corner_location &= ~CORNER_LOCATION_TOP; // 清除上标志位
|
||||||
|
}
|
||||||
|
if(target_geom.y + target_geom.height - border_radius >= c->mon->m.y + c->mon->m.height) {
|
||||||
|
current_corner_location &= ~CORNER_LOCATION_BOTTOM; // 清除下标志位
|
||||||
|
}
|
||||||
|
return current_corner_location;
|
||||||
|
}
|
||||||
|
|
||||||
void client_apply_clip(Client *c) {
|
void client_apply_clip(Client *c) {
|
||||||
|
|
||||||
if (c->iskilling || !client_surface(c)->mapped)
|
if (c->iskilling || !client_surface(c)->mapped)
|
||||||
|
|
@ -1233,6 +1253,7 @@ void client_apply_clip(Client *c) {
|
||||||
struct wlr_box clip_box;
|
struct wlr_box clip_box;
|
||||||
struct uvec2 offset;
|
struct uvec2 offset;
|
||||||
animationScale scale_data;
|
animationScale scale_data;
|
||||||
|
enum corner_location current_corner_location = set_client_corner_location(c);
|
||||||
|
|
||||||
if (!animations) {
|
if (!animations) {
|
||||||
c->animation.running = false;
|
c->animation.running = false;
|
||||||
|
|
@ -1241,9 +1262,13 @@ void client_apply_clip(Client *c) {
|
||||||
c->geom;
|
c->geom;
|
||||||
client_get_clip(c, &clip_box);
|
client_get_clip(c, &clip_box);
|
||||||
offset = clip_to_hide(c, &clip_box);
|
offset = clip_to_hide(c, &clip_box);
|
||||||
apply_border(c, clip_box, offset.x, offset.y);
|
if(c->is_clip_to_hide) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
apply_border(c, clip_box, offset.x, offset.y, current_corner_location);
|
||||||
|
|
||||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
||||||
buffer_set_effect(c, (animationScale){0, 0, 0, 0, false});
|
buffer_set_effect(c, (animationScale){0, 0, 0, 0, current_corner_location,false});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1265,15 +1290,24 @@ void client_apply_clip(Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = clip_to_hide(c, &clip_box);
|
offset = clip_to_hide(c, &clip_box);
|
||||||
|
apply_border(c, clip_box, offset.x, offset.y, current_corner_location);
|
||||||
|
|
||||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
|
struct wlr_box surface_clip;
|
||||||
apply_border(c, clip_box, offset.x, offset.y);
|
surface_clip = clip_box;
|
||||||
|
surface_clip.width = surface_clip.width - 2 * c->bw;
|
||||||
|
surface_clip.height = surface_clip.height - 2 * c->bw;
|
||||||
|
|
||||||
|
if(surface_clip.width <= 0 || surface_clip.height <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &surface_clip);
|
||||||
|
|
||||||
scale_data.should_scale = true;
|
scale_data.should_scale = true;
|
||||||
scale_data.width = clip_box.width - 2 * c->bw;
|
scale_data.width = clip_box.width - 2 * c->bw;
|
||||||
scale_data.height = clip_box.height - 2 * c->bw;
|
scale_data.height = clip_box.height - 2 * c->bw;
|
||||||
scale_data.width_scale = (float)scale_data.width / geometry.width;
|
scale_data.width_scale = (float)scale_data.width / geometry.width;
|
||||||
scale_data.height_scale = (float)scale_data.height / geometry.height;
|
scale_data.height_scale = (float)scale_data.height / geometry.height;
|
||||||
|
scale_data.corner_location = current_corner_location;
|
||||||
buffer_set_effect(c, scale_data);
|
buffer_set_effect(c, scale_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1289,7 +1323,8 @@ bool client_draw_frame(Client *c) {
|
||||||
client_animation_next_tick(c);
|
client_animation_next_tick(c);
|
||||||
client_apply_clip(c);
|
client_apply_clip(c);
|
||||||
} else {
|
} else {
|
||||||
wlr_scene_node_set_position(&c->scene->node, c->pending.x, c->pending.y);
|
if(!c->is_clip_to_hide)
|
||||||
|
wlr_scene_node_set_position(&c->scene->node, c->pending.x, c->pending.y);
|
||||||
c->animainit_geom = c->animation.initial = c->pending = c->current =
|
c->animainit_geom = c->animation.initial = c->pending = c->current =
|
||||||
c->geom;
|
c->geom;
|
||||||
client_apply_clip(c);
|
client_apply_clip(c);
|
||||||
|
|
@ -1661,7 +1696,7 @@ void gpureset(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "gpu reset");
|
wlr_log(WLR_DEBUG, "gpu reset");
|
||||||
|
|
||||||
if (!(drw = wlr_renderer_autocreate(backend)))
|
if (!(drw = fx_renderer_create(backend)))
|
||||||
die("couldn't recreate renderer");
|
die("couldn't recreate renderer");
|
||||||
|
|
||||||
if (!(alloc = wlr_allocator_autocreate(backend, drw)))
|
if (!(alloc = wlr_allocator_autocreate(backend, drw)))
|
||||||
|
|
@ -2080,7 +2115,7 @@ void apply_window_snap(Client *c) {
|
||||||
snap_right_screen = 0;
|
snap_right_screen = 0;
|
||||||
int snap_up_mon = 0, snap_down_mon = 0, snap_left_mon = 0, snap_right_mon = 0;
|
int snap_up_mon = 0, snap_down_mon = 0, snap_left_mon = 0, snap_right_mon = 0;
|
||||||
|
|
||||||
unsigned int cbw = !render_border || c->fake_no_border ? borderpx : 0;
|
unsigned int cbw = !render_border || c->fake_no_border ? c->bw : 0;
|
||||||
unsigned int tcbw;
|
unsigned int tcbw;
|
||||||
unsigned int cx, cy, cw, ch, tcx, tcy, tcw, tch;
|
unsigned int cx, cy, cw, ch, tcx, tcy, tcw, tch;
|
||||||
cx = c->geom.x + cbw;
|
cx = c->geom.x + cbw;
|
||||||
|
|
@ -2099,7 +2134,7 @@ void apply_window_snap(Client *c) {
|
||||||
if (tc && tc->isfloating && !tc->iskilling && client_surface(tc)->mapped &&
|
if (tc && tc->isfloating && !tc->iskilling && client_surface(tc)->mapped &&
|
||||||
VISIBLEON(tc, c->mon)) {
|
VISIBLEON(tc, c->mon)) {
|
||||||
|
|
||||||
tcbw = !render_border || tc->fake_no_border ? borderpx : 0;
|
tcbw = !render_border || tc->fake_no_border ? c->bw : 0;
|
||||||
tcx = tc->geom.x + tcbw;
|
tcx = tc->geom.x + tcbw;
|
||||||
tcy = tc->geom.y + tcbw;
|
tcy = tc->geom.y + tcbw;
|
||||||
tcw = tc->geom.width - 2 * tcbw;
|
tcw = tc->geom.width - 2 * tcbw;
|
||||||
|
|
@ -3180,6 +3215,7 @@ void createlayersurface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wl_list_insert(&l->mon->layers[layer_surface->pending.layer], &l->link);
|
wl_list_insert(&l->mon->layers[layer_surface->pending.layer], &l->link);
|
||||||
wlr_surface_send_enter(surface, layer_surface->output);
|
wlr_surface_send_enter(surface, layer_surface->output);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void createlocksurface(struct wl_listener *listener, void *data) {
|
void createlocksurface(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -3324,6 +3360,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||||
else
|
else
|
||||||
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void // fix for 0.5
|
void // fix for 0.5
|
||||||
|
|
@ -4248,78 +4285,126 @@ void keypressmod(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
|
static bool scene_node_snapshot(struct wlr_scene_node *node, int lx, int ly,
|
||||||
struct wlr_scene_tree *snapshot_tree) {
|
struct wlr_scene_tree *snapshot_tree) {
|
||||||
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
|
if (!node->enabled && node->type != WLR_SCENE_NODE_TREE) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lx += node->x;
|
lx += node->x;
|
||||||
ly += node->y;
|
ly += node->y;
|
||||||
|
|
||||||
struct wlr_scene_node *snapshot_node = NULL;
|
struct wlr_scene_node *snapshot_node = NULL;
|
||||||
switch (node->type) {
|
switch (node->type) {
|
||||||
case WLR_SCENE_NODE_TREE:;
|
case WLR_SCENE_NODE_TREE: {
|
||||||
struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node);
|
struct wlr_scene_tree *scene_tree = wlr_scene_tree_from_node(node);
|
||||||
struct wlr_scene_node *child;
|
|
||||||
wl_list_for_each(child, &scene_tree->children, link) {
|
|
||||||
scene_node_snapshot(child, lx, ly, snapshot_tree);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WLR_SCENE_NODE_RECT:;
|
|
||||||
|
|
||||||
struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
|
struct wlr_scene_node *child;
|
||||||
|
wl_list_for_each(child, &scene_tree->children, link) {
|
||||||
|
scene_node_snapshot(child, lx, ly, snapshot_tree);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WLR_SCENE_NODE_RECT: {
|
||||||
|
struct wlr_scene_rect *scene_rect = wlr_scene_rect_from_node(node);
|
||||||
|
|
||||||
struct wlr_scene_rect *snapshot_rect =
|
struct wlr_scene_rect *snapshot_rect =
|
||||||
wlr_scene_rect_create(snapshot_tree, scene_rect->width,
|
wlr_scene_rect_create(snapshot_tree, scene_rect->width,
|
||||||
scene_rect->height, scene_rect->color);
|
scene_rect->height, scene_rect->color);
|
||||||
snapshot_rect->node.data = scene_rect->node.data;
|
snapshot_rect->node.data = scene_rect->node.data;
|
||||||
if (snapshot_rect == NULL) {
|
if (snapshot_rect == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
snapshot_node = &snapshot_rect->node;
|
|
||||||
break;
|
|
||||||
case WLR_SCENE_NODE_BUFFER:;
|
|
||||||
|
|
||||||
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
|
wlr_scene_rect_set_clipped_region(scene_rect,
|
||||||
|
snapshot_rect->clipped_region);
|
||||||
|
wlr_scene_rect_set_backdrop_blur(scene_rect,
|
||||||
|
snapshot_rect->backdrop_blur);
|
||||||
|
wlr_scene_rect_set_backdrop_blur_optimized(
|
||||||
|
scene_rect, snapshot_rect->backdrop_blur_optimized);
|
||||||
|
wlr_scene_rect_set_corner_radius(
|
||||||
|
scene_rect, snapshot_rect->corner_radius, snapshot_rect->corners);
|
||||||
|
wlr_scene_rect_set_color(scene_rect, snapshot_rect->color);
|
||||||
|
|
||||||
struct wlr_scene_buffer *snapshot_buffer =
|
snapshot_node = &snapshot_rect->node;
|
||||||
wlr_scene_buffer_create(snapshot_tree, NULL);
|
break;
|
||||||
if (snapshot_buffer == NULL) {
|
}
|
||||||
return false;
|
case WLR_SCENE_NODE_BUFFER: {
|
||||||
}
|
struct wlr_scene_buffer *scene_buffer =
|
||||||
snapshot_node = &snapshot_buffer->node;
|
wlr_scene_buffer_from_node(node);
|
||||||
snapshot_buffer->node.data = scene_buffer->node.data;
|
|
||||||
|
|
||||||
wlr_scene_buffer_set_dest_size(snapshot_buffer, scene_buffer->dst_width,
|
struct wlr_scene_buffer *snapshot_buffer =
|
||||||
scene_buffer->dst_height);
|
wlr_scene_buffer_create(snapshot_tree, NULL);
|
||||||
wlr_scene_buffer_set_opaque_region(snapshot_buffer,
|
if (snapshot_buffer == NULL) {
|
||||||
&scene_buffer->opaque_region);
|
return false;
|
||||||
wlr_scene_buffer_set_source_box(snapshot_buffer, &scene_buffer->src_box);
|
}
|
||||||
wlr_scene_buffer_set_transform(snapshot_buffer, scene_buffer->transform);
|
snapshot_node = &snapshot_buffer->node;
|
||||||
wlr_scene_buffer_set_filter_mode(snapshot_buffer,
|
snapshot_buffer->node.data = scene_buffer->node.data;
|
||||||
scene_buffer->filter_mode);
|
|
||||||
|
|
||||||
// Effects
|
wlr_scene_buffer_set_dest_size(snapshot_buffer, scene_buffer->dst_width,
|
||||||
wlr_scene_buffer_set_opacity(snapshot_buffer, scene_buffer->opacity);
|
scene_buffer->dst_height);
|
||||||
|
wlr_scene_buffer_set_opaque_region(snapshot_buffer,
|
||||||
|
&scene_buffer->opaque_region);
|
||||||
|
wlr_scene_buffer_set_source_box(snapshot_buffer,
|
||||||
|
&scene_buffer->src_box);
|
||||||
|
wlr_scene_buffer_set_transform(snapshot_buffer,
|
||||||
|
scene_buffer->transform);
|
||||||
|
wlr_scene_buffer_set_filter_mode(snapshot_buffer,
|
||||||
|
scene_buffer->filter_mode);
|
||||||
|
|
||||||
snapshot_buffer->node.data = scene_buffer->node.data;
|
// Effects
|
||||||
|
wlr_scene_buffer_set_opacity(snapshot_buffer, scene_buffer->opacity);
|
||||||
|
wlr_scene_buffer_set_corner_radius(snapshot_buffer,
|
||||||
|
scene_buffer->corner_radius,
|
||||||
|
scene_buffer->corners);
|
||||||
|
|
||||||
struct wlr_scene_surface *scene_surface =
|
wlr_scene_buffer_set_backdrop_blur_optimized(
|
||||||
wlr_scene_surface_try_from_buffer(scene_buffer);
|
snapshot_buffer, scene_buffer->backdrop_blur_optimized);
|
||||||
if (scene_surface != NULL && scene_surface->surface->buffer != NULL) {
|
wlr_scene_buffer_set_backdrop_blur_ignore_transparent(
|
||||||
wlr_scene_buffer_set_buffer(snapshot_buffer,
|
snapshot_buffer, scene_buffer->backdrop_blur_ignore_transparent);
|
||||||
&scene_surface->surface->buffer->base);
|
wlr_scene_buffer_set_backdrop_blur(snapshot_buffer,
|
||||||
} else {
|
scene_buffer->backdrop_blur);
|
||||||
wlr_scene_buffer_set_buffer(snapshot_buffer, scene_buffer->buffer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (snapshot_node != NULL) {
|
snapshot_buffer->node.data = scene_buffer->node.data;
|
||||||
wlr_scene_node_set_position(snapshot_node, lx, ly);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
struct wlr_scene_surface *scene_surface =
|
||||||
|
wlr_scene_surface_try_from_buffer(scene_buffer);
|
||||||
|
if (scene_surface != NULL && scene_surface->surface->buffer != NULL) {
|
||||||
|
wlr_scene_buffer_set_buffer(snapshot_buffer,
|
||||||
|
&scene_surface->surface->buffer->base);
|
||||||
|
} else {
|
||||||
|
wlr_scene_buffer_set_buffer(snapshot_buffer, scene_buffer->buffer);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WLR_SCENE_NODE_SHADOW: {
|
||||||
|
struct wlr_scene_shadow *scene_shadow =
|
||||||
|
wlr_scene_shadow_from_node(node);
|
||||||
|
|
||||||
|
struct wlr_scene_shadow *snapshot_shadow = wlr_scene_shadow_create(
|
||||||
|
snapshot_tree, scene_shadow->width, scene_shadow->height,
|
||||||
|
scene_shadow->corner_radius, scene_shadow->blur_sigma,
|
||||||
|
scene_shadow->color);
|
||||||
|
if (snapshot_shadow == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
snapshot_node = &snapshot_shadow->node;
|
||||||
|
|
||||||
|
wlr_scene_shadow_set_clipped_region(snapshot_shadow,
|
||||||
|
scene_shadow->clipped_region);
|
||||||
|
|
||||||
|
snapshot_shadow->node.data = scene_shadow->node.data;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WLR_SCENE_NODE_OPTIMIZED_BLUR:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snapshot_node != NULL) {
|
||||||
|
wlr_scene_node_set_position(snapshot_node, lx, ly);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_scene_tree *wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
struct wlr_scene_tree *wlr_scene_tree_snapshot(struct wlr_scene_node *node,
|
||||||
|
|
@ -4384,7 +4469,6 @@ mapnotify(struct wl_listener *listener, void *data) {
|
||||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||||
Client *p = NULL;
|
Client *p = NULL;
|
||||||
Client *c = wl_container_of(listener, c, map);
|
Client *c = wl_container_of(listener, c, map);
|
||||||
int i;
|
|
||||||
/* Create scene tree for this client and its border */
|
/* Create scene tree for this client and its border */
|
||||||
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
|
c->scene = client_surface(c)->data = wlr_scene_tree_create(layers[LyrTile]);
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, c->type != XDGShell);
|
wlr_scene_node_set_enabled(&c->scene->node, c->type != XDGShell);
|
||||||
|
|
@ -4416,11 +4500,12 @@ mapnotify(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
c->border = wlr_scene_rect_create(c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor);
|
||||||
c->border[i] = wlr_scene_rect_create(
|
wlr_scene_node_lower_to_bottom(&c->border->node);
|
||||||
c->scene, 0, 0, c->isurgent ? urgentcolor : bordercolor);
|
wlr_scene_node_set_position(&c->border->node, 0, 0);
|
||||||
c->border[i]->node.data = c;
|
wlr_scene_rect_set_corner_radius(c->border, border_radius, border_radius_location_default);
|
||||||
}
|
wlr_scene_node_set_enabled(&c->border->node, true);
|
||||||
|
|
||||||
|
|
||||||
/* Initialize client geometry with room for border */
|
/* Initialize client geometry with room for border */
|
||||||
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
client_set_tiled(c, WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT |
|
||||||
|
|
@ -4920,6 +5005,11 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: blur set, opacity set
|
// TODO: blur set, opacity set
|
||||||
|
|
||||||
|
/* we dont round or blur popups */
|
||||||
|
if(wlr_xdg_popup_try_from_wlr_surface(surface) != NULL) return;
|
||||||
|
|
||||||
|
wlr_scene_buffer_set_corner_radius(buffer, border_radius, scale_data->corner_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
|
void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
|
||||||
|
|
@ -5258,7 +5348,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
|
||||||
c->animainit_geom = c->current = c->pending = c->animation.current =
|
c->animainit_geom = c->current = c->pending = c->animation.current =
|
||||||
c->geom;
|
c->geom;
|
||||||
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||||
apply_border(c, c->geom, 0, 0);
|
apply_border(c, c->geom, 0, 0, CORNER_LOCATION_ALL);
|
||||||
client_get_clip(c, &clip);
|
client_get_clip(c, &clip);
|
||||||
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip);
|
||||||
return;
|
return;
|
||||||
|
|
@ -5898,6 +5988,7 @@ void setup(void) {
|
||||||
|
|
||||||
/* Initialize the scene graph used to lay out windows */
|
/* Initialize the scene graph used to lay out windows */
|
||||||
scene = wlr_scene_create();
|
scene = wlr_scene_create();
|
||||||
|
|
||||||
root_bg = wlr_scene_rect_create(&scene->tree, 0, 0, rootcolor);
|
root_bg = wlr_scene_rect_create(&scene->tree, 0, 0, rootcolor);
|
||||||
for (i = 0; i < NUM_LAYERS; i++)
|
for (i = 0; i < NUM_LAYERS; i++)
|
||||||
layers[i] = wlr_scene_tree_create(&scene->tree);
|
layers[i] = wlr_scene_tree_create(&scene->tree);
|
||||||
|
|
@ -5905,7 +5996,7 @@ void setup(void) {
|
||||||
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
wlr_scene_node_place_below(&drag_icon->node, &layers[LyrBlock]->node);
|
||||||
|
|
||||||
/* Create a renderer with the default implementation */
|
/* Create a renderer with the default implementation */
|
||||||
if (!(drw = wlr_renderer_autocreate(backend)))
|
if (!(drw = fx_renderer_create(backend)))
|
||||||
die("couldn't create renderer");
|
die("couldn't create renderer");
|
||||||
|
|
||||||
wl_signal_add(&drw->events.lost, &gpu_reset);
|
wl_signal_add(&drw->events.lost, &gpu_reset);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue