mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 16:01:27 +00:00
Store scratchpad list in sway_root instead of server
This commit is contained in:
parent
81e8f31cc6
commit
12e90fa600
|
@ -48,8 +48,6 @@ struct sway_server {
|
||||||
|
|
||||||
list_t *transactions;
|
list_t *transactions;
|
||||||
list_t *dirty_containers;
|
list_t *dirty_containers;
|
||||||
|
|
||||||
list_t *scratchpad; // struct sway_container
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sway_server server;
|
struct sway_server server;
|
||||||
|
|
|
@ -35,6 +35,8 @@ struct sway_root {
|
||||||
|
|
||||||
struct wl_list outputs; // sway_output::link
|
struct wl_list outputs; // sway_output::link
|
||||||
|
|
||||||
|
list_t *scratchpad; // struct sway_container
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal new_container;
|
struct wl_signal new_container;
|
||||||
} events;
|
} events;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
#include "sway/scratchpad.h"
|
#include "sway/scratchpad.h"
|
||||||
#include "sway/server.h"
|
|
||||||
#include "sway/tree/container.h"
|
#include "sway/tree/container.h"
|
||||||
|
|
||||||
struct cmd_results *cmd_scratchpad(int argc, char **argv) {
|
struct cmd_results *cmd_scratchpad(int argc, char **argv) {
|
||||||
|
@ -14,7 +13,7 @@ struct cmd_results *cmd_scratchpad(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_INVALID, "scratchpad",
|
return cmd_results_new(CMD_INVALID, "scratchpad",
|
||||||
"Expected 'scratchpad show'");
|
"Expected 'scratchpad show'");
|
||||||
}
|
}
|
||||||
if (!server.scratchpad->length) {
|
if (!root_container.sway_root->scratchpad->length) {
|
||||||
return cmd_results_new(CMD_INVALID, "scratchpad",
|
return cmd_results_new(CMD_INVALID, "scratchpad",
|
||||||
"Scratchpad is empty");
|
"Scratchpad is empty");
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,8 +227,9 @@ list_t *criteria_get_views(struct criteria *criteria) {
|
||||||
criteria_get_views_iterator, &data);
|
criteria_get_views_iterator, &data);
|
||||||
|
|
||||||
// Scratchpad items which are hidden are not in the tree.
|
// Scratchpad items which are hidden are not in the tree.
|
||||||
for (int i = 0; i < server.scratchpad->length; ++i) {
|
for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) {
|
||||||
struct sway_container *con = server.scratchpad->items[i];
|
struct sway_container *con =
|
||||||
|
root_container.sway_root->scratchpad->items[i];
|
||||||
if (!con->parent) {
|
if (!con->parent) {
|
||||||
criteria_get_views_iterator(con, &data);
|
criteria_get_views_iterator(con, &data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ void scratchpad_add_container(struct sway_container *con) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
con->scratchpad = true;
|
con->scratchpad = true;
|
||||||
list_add(server.scratchpad, con);
|
list_add(root_container.sway_root->scratchpad, con);
|
||||||
|
|
||||||
struct sway_container *parent = con->parent;
|
struct sway_container *parent = con->parent;
|
||||||
container_set_floating(con, true);
|
container_set_floating(con, true);
|
||||||
|
@ -32,9 +32,9 @@ void scratchpad_remove_container(struct sway_container *con) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
con->scratchpad = false;
|
con->scratchpad = false;
|
||||||
for (int i = 0; i < server.scratchpad->length; ++i) {
|
for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) {
|
||||||
if (server.scratchpad->items[i] == con) {
|
if (root_container.sway_root->scratchpad->items[i] == con) {
|
||||||
list_del(server.scratchpad, i);
|
list_del(root_container.sway_root->scratchpad, i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ static void scratchpad_hide(struct sway_container *con) {
|
||||||
if (con == focus) {
|
if (con == focus) {
|
||||||
seat_set_focus(seat, seat_get_focus_inactive(seat, ws));
|
seat_set_focus(seat, seat_get_focus_inactive(seat, ws));
|
||||||
}
|
}
|
||||||
list_move_to_end(server.scratchpad, con);
|
list_move_to_end(root_container.sway_root->scratchpad, con);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scratchpad_toggle_auto(void) {
|
void scratchpad_toggle_auto(void) {
|
||||||
|
@ -138,8 +138,9 @@ void scratchpad_toggle_auto(void) {
|
||||||
|
|
||||||
// Check if there is a visible scratchpad window on another workspace.
|
// Check if there is a visible scratchpad window on another workspace.
|
||||||
// In this case we move it to the current workspace.
|
// In this case we move it to the current workspace.
|
||||||
for (int i = 0; i < server.scratchpad->length; ++i) {
|
for (int i = 0; i < root_container.sway_root->scratchpad->length; ++i) {
|
||||||
struct sway_container *con = server.scratchpad->items[i];
|
struct sway_container *con =
|
||||||
|
root_container.sway_root->scratchpad->items[i];
|
||||||
if (con->parent) {
|
if (con->parent) {
|
||||||
wlr_log(WLR_DEBUG,
|
wlr_log(WLR_DEBUG,
|
||||||
"Moving a visible scratchpad window (%s) to this workspace",
|
"Moving a visible scratchpad window (%s) to this workspace",
|
||||||
|
@ -150,10 +151,11 @@ void scratchpad_toggle_auto(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take the container at the bottom of the scratchpad list
|
// Take the container at the bottom of the scratchpad list
|
||||||
if (!sway_assert(server.scratchpad->length, "Scratchpad is empty")) {
|
if (!sway_assert(root_container.sway_root->scratchpad->length,
|
||||||
|
"Scratchpad is empty")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct sway_container *con = server.scratchpad->items[0];
|
struct sway_container *con = root_container.sway_root->scratchpad->items[0];
|
||||||
wlr_log(WLR_DEBUG, "Showing %s from list", con->name);
|
wlr_log(WLR_DEBUG, "Showing %s from list", con->name);
|
||||||
scratchpad_show(con);
|
scratchpad_show(con);
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,8 +126,6 @@ bool server_init(struct sway_server *server) {
|
||||||
server->dirty_containers = create_list();
|
server->dirty_containers = create_list();
|
||||||
server->transactions = create_list();
|
server->transactions = create_list();
|
||||||
|
|
||||||
server->scratchpad = create_list();
|
|
||||||
|
|
||||||
input_manager = input_manager_create(server);
|
input_manager = input_manager_create(server);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -137,7 +135,6 @@ void server_fini(struct sway_server *server) {
|
||||||
wl_display_destroy(server->wl_display);
|
wl_display_destroy(server->wl_display);
|
||||||
list_free(server->dirty_containers);
|
list_free(server->dirty_containers);
|
||||||
list_free(server->transactions);
|
list_free(server->transactions);
|
||||||
list_free(server->scratchpad);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool server_start_backend(struct sway_server *server) {
|
bool server_start_backend(struct sway_server *server) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ void layout_init(void) {
|
||||||
wl_list_init(&root_container.sway_root->xwayland_unmanaged);
|
wl_list_init(&root_container.sway_root->xwayland_unmanaged);
|
||||||
wl_list_init(&root_container.sway_root->drag_icons);
|
wl_list_init(&root_container.sway_root->drag_icons);
|
||||||
wl_signal_init(&root_container.sway_root->events.new_container);
|
wl_signal_init(&root_container.sway_root->events.new_container);
|
||||||
|
root_container.sway_root->scratchpad = create_list();
|
||||||
|
|
||||||
root_container.sway_root->output_layout_change.notify =
|
root_container.sway_root->output_layout_change.notify =
|
||||||
output_layout_handle_change;
|
output_layout_handle_change;
|
||||||
|
|
Loading…
Reference in a new issue