mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
ssd: Allocate struct ssd and struct ssd_hover_state separately
- Store a pointer to the `struct view` in `struct ssd` - Pass `struct ssd *` instead of `struct view *` to ssd functions - Add `ssd_get_margin()` convenience function
This commit is contained in:
parent
cfa51ab628
commit
1e8b0414fe
15 changed files with 112 additions and 65 deletions
44
src/view.c
44
src/view.c
|
|
@ -88,7 +88,7 @@ view_get_edge_snap_box(struct view *view, struct output *output,
|
|||
break;
|
||||
}
|
||||
|
||||
struct border margin = view->ssd.margin;
|
||||
struct border margin = ssd_get_margin(view->ssd);
|
||||
struct wlr_box dst = {
|
||||
.x = x_offset + usable.x + margin.left,
|
||||
.y = y_offset + usable.y + margin.top,
|
||||
|
|
@ -102,9 +102,7 @@ view_get_edge_snap_box(struct view *view, struct output *output,
|
|||
static void
|
||||
_view_set_activated(struct view *view, bool activated)
|
||||
{
|
||||
if (view->ssd.tree) {
|
||||
ssd_set_active(view, activated);
|
||||
}
|
||||
ssd_set_active(view->ssd, activated);
|
||||
if (view->impl->set_activated) {
|
||||
view->impl->set_activated(view, activated);
|
||||
}
|
||||
|
|
@ -153,7 +151,7 @@ view_moved(struct view *view)
|
|||
assert(view);
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->x, view->y);
|
||||
view_discover_output(view);
|
||||
ssd_update_geometry(view);
|
||||
ssd_update_geometry(view->ssd);
|
||||
cursor_update_focus(view->server);
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +276,7 @@ view_compute_centered_position(struct view *view, int w, int h, int *x, int *y)
|
|||
return false;
|
||||
}
|
||||
|
||||
struct border margin = view->ssd.margin;
|
||||
struct border margin = ssd_get_margin(view->ssd);
|
||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||
int width = w + margin.left + margin.right;
|
||||
int height = h + margin.top + margin.bottom;
|
||||
|
|
@ -554,6 +552,22 @@ view_move_to_workspace(struct view *view, struct workspace *workspace)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
decorate(struct view *view)
|
||||
{
|
||||
if (!view->ssd) {
|
||||
view->ssd = ssd_create(view,
|
||||
view == view->server->focused_view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
undecorate(struct view *view)
|
||||
{
|
||||
ssd_destroy(view->ssd);
|
||||
view->ssd = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
view_set_decorations(struct view *view, bool decorations)
|
||||
{
|
||||
|
|
@ -565,9 +579,9 @@ view_set_decorations(struct view *view, bool decorations)
|
|||
*/
|
||||
view->ssd_enabled = decorations;
|
||||
if (decorations) {
|
||||
ssd_create(view, view == view->server->focused_view);
|
||||
decorate(view);
|
||||
} else {
|
||||
ssd_destroy(view);
|
||||
undecorate(view);
|
||||
}
|
||||
if (view->maximized) {
|
||||
view_apply_maximized_geometry(view);
|
||||
|
|
@ -614,7 +628,7 @@ view_set_fullscreen(struct view *view, bool fullscreen,
|
|||
}
|
||||
/* Hide decorations when going fullscreen */
|
||||
if (view->ssd_enabled) {
|
||||
ssd_destroy(view);
|
||||
undecorate(view);
|
||||
}
|
||||
view->fullscreen = wlr_output;
|
||||
view_apply_fullscreen_geometry(view, view->fullscreen);
|
||||
|
|
@ -630,7 +644,7 @@ view_set_fullscreen(struct view *view, bool fullscreen,
|
|||
}
|
||||
/* Re-show decorations when no longer fullscreen */
|
||||
if (view->ssd_enabled) {
|
||||
ssd_create(view, view == view->server->focused_view);
|
||||
decorate(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +748,7 @@ view_move_to_edge(struct view *view, const char *direction)
|
|||
return;
|
||||
}
|
||||
|
||||
struct border margin = view->ssd.margin;
|
||||
struct border margin = ssd_get_margin(view->ssd);
|
||||
struct wlr_box usable = output_usable_area_in_layout_coords(output);
|
||||
if (usable.height == output->wlr_output->height
|
||||
&& output->wlr_output->scale != 1) {
|
||||
|
|
@ -872,7 +886,7 @@ view_update_title(struct view *view)
|
|||
if (!view->toplevel_handle || !title) {
|
||||
return;
|
||||
}
|
||||
ssd_update_title(view);
|
||||
ssd_update_title(view->ssd);
|
||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, title);
|
||||
}
|
||||
|
||||
|
|
@ -893,8 +907,8 @@ view_reload_ssd(struct view *view)
|
|||
{
|
||||
assert(view);
|
||||
if (view->ssd_enabled && !view->fullscreen) {
|
||||
ssd_destroy(view);
|
||||
ssd_create(view, view == view->server->focused_view);
|
||||
undecorate(view);
|
||||
decorate(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -926,9 +940,9 @@ view_destroy(struct view *view)
|
|||
}
|
||||
|
||||
osd_on_view_destroy(view);
|
||||
undecorate(view);
|
||||
|
||||
if (view->scene_tree) {
|
||||
ssd_destroy(view);
|
||||
wlr_scene_node_destroy(&view->scene_tree->node);
|
||||
view->scene_tree = NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue