mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
workspaces: slight struct reordering
This commit is contained in:
parent
750d37b16c
commit
d9866aafa5
9 changed files with 40 additions and 38 deletions
|
|
@ -982,7 +982,7 @@ actions_run(struct view *activator, struct server *server,
|
|||
* a required argument for both SendToDesktop and GoToDesktop.
|
||||
*/
|
||||
struct workspace *target = workspaces_find(
|
||||
server->workspace_current, to, wrap);
|
||||
server->workspaces.current, to, wrap);
|
||||
if (!target) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ get_special(struct server *server, struct wlr_scene_node *node)
|
|||
}
|
||||
if (node->parent == server->view_tree) {
|
||||
struct workspace *workspace;
|
||||
wl_list_for_each(workspace, &server->workspaces, link) {
|
||||
wl_list_for_each(workspace, &server->workspaces.all, link) {
|
||||
if (&workspace->tree->node == node) {
|
||||
return workspace->name;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ desktop_topmost_focusable_view(struct server *server)
|
|||
struct view *view;
|
||||
struct wl_list *node_list;
|
||||
struct wlr_scene_node *node;
|
||||
node_list = &server->workspace_current->tree->children;
|
||||
node_list = &server->workspaces.current->tree->children;
|
||||
wl_list_for_each_reverse(node, node_list, link) {
|
||||
if (!node->data) {
|
||||
/* We found some non-view, most likely the region overlay */
|
||||
|
|
@ -185,7 +185,7 @@ desktop_focus_output(struct output *output)
|
|||
struct wlr_scene_node *node;
|
||||
struct wlr_output_layout *layout = output->server->output_layout;
|
||||
struct wl_list *list_head =
|
||||
&output->server->workspace_current->tree->children;
|
||||
&output->server->workspaces.current->tree->children;
|
||||
wl_list_for_each_reverse(node, list_head, link) {
|
||||
if (!node->data) {
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ display_osd(struct output *output, struct wl_array *views)
|
|||
struct server *server = output->server;
|
||||
struct theme *theme = server->theme;
|
||||
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
|
||||
const char *workspace_name = server->workspace_current->name;
|
||||
const char *workspace_name = server->workspaces.current->name;
|
||||
|
||||
float scale = output->wlr_output->scale;
|
||||
int w = theme->osd_window_switcher_width;
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ matches_criteria(struct view *view, enum lab_view_criteria criteria)
|
|||
* special in that they live in a different tree.
|
||||
*/
|
||||
struct server *server = view->server;
|
||||
if (view->scene_tree->node.parent != server->workspace_current->tree
|
||||
if (view->scene_tree->node.parent != server->workspaces.current->tree
|
||||
&& !view_is_always_on_top(view)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1451,7 +1451,7 @@ view_toggle_always_on_top(struct view *view)
|
|||
{
|
||||
assert(view);
|
||||
if (view_is_always_on_top(view)) {
|
||||
view->workspace = view->server->workspace_current;
|
||||
view->workspace = view->server->workspaces.current;
|
||||
wlr_scene_node_reparent(&view->scene_tree->node,
|
||||
view->workspace->tree);
|
||||
} else {
|
||||
|
|
@ -1473,7 +1473,7 @@ view_toggle_always_on_bottom(struct view *view)
|
|||
{
|
||||
assert(view);
|
||||
if (view_is_always_on_bottom(view)) {
|
||||
view->workspace = view->server->workspace_current;
|
||||
view->workspace = view->server->workspaces.current;
|
||||
wlr_scene_node_reparent(&view->scene_tree->node,
|
||||
view->workspace->tree);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ _osd_update(struct server *server)
|
|||
theme->osd_workspace_switcher_boxes_height == 0;
|
||||
|
||||
/* Dimensions */
|
||||
size_t workspace_count = wl_list_length(&server->workspaces);
|
||||
size_t workspace_count = wl_list_length(&server->workspaces.all);
|
||||
uint16_t marker_width = workspace_count * (rect_width + padding) - padding;
|
||||
uint16_t width = margin * 2 + (marker_width < 200 ? 200 : marker_width);
|
||||
uint16_t height = margin * (hide_boxes ? 2 : 3) + rect_height + font_height(&rc.font_osd);
|
||||
|
|
@ -106,8 +106,8 @@ _osd_update(struct server *server)
|
|||
uint16_t x;
|
||||
if (!hide_boxes) {
|
||||
x = (width - marker_width) / 2;
|
||||
wl_list_for_each(workspace, &server->workspaces, link) {
|
||||
bool active = workspace == server->workspace_current;
|
||||
wl_list_for_each(workspace, &server->workspaces.all, link) {
|
||||
bool active = workspace == server->workspaces.current;
|
||||
set_cairo_color(cairo, server->theme->osd_label_text_color);
|
||||
cairo_rectangle(cairo, x, margin,
|
||||
rect_width - padding, rect_height);
|
||||
|
|
@ -128,7 +128,7 @@ _osd_update(struct server *server)
|
|||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
|
||||
/* Center workspace indicator on the x axis */
|
||||
int req_width = font_width(&rc.font_osd, server->workspace_current->name);
|
||||
int req_width = font_width(&rc.font_osd, server->workspaces.current->name);
|
||||
req_width = MIN(req_width, width - 2 * margin);
|
||||
x = (width - req_width) / 2;
|
||||
if (!hide_boxes) {
|
||||
|
|
@ -141,7 +141,7 @@ _osd_update(struct server *server)
|
|||
pango_layout_set_font_description(layout, desc);
|
||||
pango_layout_set_width(layout, req_width * PANGO_SCALE);
|
||||
pango_font_description_free(desc);
|
||||
pango_layout_set_text(layout, server->workspace_current->name, -1);
|
||||
pango_layout_set_text(layout, server->workspaces.current->name, -1);
|
||||
pango_cairo_show_layout(cairo, layout);
|
||||
|
||||
g_object_unref(layout);
|
||||
|
|
@ -180,9 +180,9 @@ add_workspace(struct server *server, const char *name)
|
|||
workspace->server = server;
|
||||
workspace->name = xstrdup(name);
|
||||
workspace->tree = wlr_scene_tree_create(server->view_tree);
|
||||
wl_list_append(&server->workspaces, &workspace->link);
|
||||
if (!server->workspace_current) {
|
||||
server->workspace_current = workspace;
|
||||
wl_list_append(&server->workspaces.all, &workspace->link);
|
||||
if (!server->workspaces.current) {
|
||||
server->workspaces.current = workspace;
|
||||
} else {
|
||||
wlr_scene_node_set_enabled(&workspace->tree->node, false);
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ _osd_show(struct server *server)
|
|||
void
|
||||
workspaces_init(struct server *server)
|
||||
{
|
||||
wl_list_init(&server->workspaces);
|
||||
wl_list_init(&server->workspaces.all);
|
||||
|
||||
struct workspace *conf;
|
||||
wl_list_for_each(conf, &rc.workspace_config.workspaces, link) {
|
||||
|
|
@ -278,13 +278,13 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
|||
{
|
||||
assert(target);
|
||||
struct server *server = target->server;
|
||||
if (target == server->workspace_current) {
|
||||
if (target == server->workspaces.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disable the old workspace */
|
||||
wlr_scene_node_set_enabled(
|
||||
&server->workspace_current->tree->node, false);
|
||||
&server->workspaces.current->tree->node, false);
|
||||
|
||||
/* Move Omnipresent views to new workspace */
|
||||
struct view *view;
|
||||
|
|
@ -300,10 +300,10 @@ workspaces_switch_to(struct workspace *target, bool update_focus)
|
|||
wlr_scene_node_set_enabled(&target->tree->node, true);
|
||||
|
||||
/* Save the last visited workspace */
|
||||
server->workspace_last = server->workspace_current;
|
||||
server->workspaces.last = server->workspaces.current;
|
||||
|
||||
/* Make sure new views will spawn on the new workspace */
|
||||
server->workspace_current = target;
|
||||
server->workspaces.current = target;
|
||||
|
||||
/*
|
||||
* Make sure we are focusing what the user sees.
|
||||
|
|
@ -362,7 +362,7 @@ workspaces_find(struct workspace *anchor, const char *name, bool wrap)
|
|||
size_t index = 0;
|
||||
struct workspace *target;
|
||||
size_t wants_index = parse_workspace_index(name);
|
||||
struct wl_list *workspaces = &anchor->server->workspaces;
|
||||
struct wl_list *workspaces = &anchor->server->workspaces.all;
|
||||
|
||||
if (wants_index) {
|
||||
wl_list_for_each(target, workspaces, link) {
|
||||
|
|
@ -373,7 +373,7 @@ workspaces_find(struct workspace *anchor, const char *name, bool wrap)
|
|||
} else if (!strcasecmp(name, "current")) {
|
||||
return anchor;
|
||||
} else if (!strcasecmp(name, "last")) {
|
||||
return anchor->server->workspace_last;
|
||||
return anchor->server->workspaces.last;
|
||||
} else if (!strcasecmp(name, "left")) {
|
||||
return get_prev(anchor, workspaces, wrap);
|
||||
} else if (!strcasecmp(name, "right")) {
|
||||
|
|
@ -408,7 +408,7 @@ workspaces_reconfigure(struct server *server)
|
|||
* - Destroy workspaces if fewer workspace are desired
|
||||
*/
|
||||
|
||||
struct wl_list *actual_workspace_link = server->workspaces.next;
|
||||
struct wl_list *actual_workspace_link = server->workspaces.all.next;
|
||||
|
||||
struct workspace *configured_workspace;
|
||||
wl_list_for_each(configured_workspace,
|
||||
|
|
@ -416,7 +416,7 @@ workspaces_reconfigure(struct server *server)
|
|||
struct workspace *actual_workspace = wl_container_of(
|
||||
actual_workspace_link, actual_workspace, link);
|
||||
|
||||
if (actual_workspace_link == &server->workspaces) {
|
||||
if (actual_workspace_link == &server->workspaces.all) {
|
||||
/* # of configured workspaces increased */
|
||||
wlr_log(WLR_DEBUG, "Adding workspace \"%s\"",
|
||||
configured_workspace->name);
|
||||
|
|
@ -433,16 +433,16 @@ workspaces_reconfigure(struct server *server)
|
|||
actual_workspace_link = actual_workspace_link->next;
|
||||
}
|
||||
|
||||
if (actual_workspace_link == &server->workspaces) {
|
||||
if (actual_workspace_link == &server->workspaces.all) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* # of configured workspaces decreased */
|
||||
overlay_hide(&server->seat);
|
||||
struct workspace *first_workspace =
|
||||
wl_container_of(server->workspaces.next, first_workspace, link);
|
||||
wl_container_of(server->workspaces.all.next, first_workspace, link);
|
||||
|
||||
while (actual_workspace_link != &server->workspaces) {
|
||||
while (actual_workspace_link != &server->workspaces.all) {
|
||||
struct workspace *actual_workspace = wl_container_of(
|
||||
actual_workspace_link, actual_workspace, link);
|
||||
|
||||
|
|
@ -456,12 +456,12 @@ workspaces_reconfigure(struct server *server)
|
|||
}
|
||||
}
|
||||
|
||||
if (server->workspace_current == actual_workspace) {
|
||||
if (server->workspaces.current == actual_workspace) {
|
||||
workspaces_switch_to(first_workspace,
|
||||
/* update_focus */ true);
|
||||
}
|
||||
if (server->workspace_last == actual_workspace) {
|
||||
server->workspace_last = first_workspace;
|
||||
if (server->workspaces.last == actual_workspace) {
|
||||
server->workspaces.last = first_workspace;
|
||||
}
|
||||
|
||||
actual_workspace_link = actual_workspace_link->next;
|
||||
|
|
@ -473,8 +473,8 @@ void
|
|||
workspaces_destroy(struct server *server)
|
||||
{
|
||||
struct workspace *workspace, *tmp;
|
||||
wl_list_for_each_safe(workspace, tmp, &server->workspaces, link) {
|
||||
wl_list_for_each_safe(workspace, tmp, &server->workspaces.all, link) {
|
||||
destroy_workspace(workspace);
|
||||
}
|
||||
assert(wl_list_empty(&server->workspaces));
|
||||
assert(wl_list_empty(&server->workspaces.all));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -840,7 +840,7 @@ xdg_toplevel_new(struct wl_listener *listener, void *data)
|
|||
view->output->wlr_output->scale);
|
||||
}
|
||||
|
||||
view->workspace = server->workspace_current;
|
||||
view->workspace = server->workspaces.current;
|
||||
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
||||
wlr_scene_node_set_enabled(&view->scene_tree->node, false);
|
||||
|
||||
|
|
|
|||
|
|
@ -985,7 +985,7 @@ xwayland_view_create(struct server *server,
|
|||
xwayland_view->xwayland_surface = xsurface;
|
||||
xsurface->data = view;
|
||||
|
||||
view->workspace = server->workspace_current;
|
||||
view->workspace = server->workspaces.current;
|
||||
view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
|
||||
node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue