mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: support toggleview action in ext-workspace
This commit is contained in:
parent
960a8ecb41
commit
7c7bc6c910
2 changed files with 31 additions and 2 deletions
|
|
@ -1,5 +1,9 @@
|
|||
#include "wlr_ext_workspace_v1.h"
|
||||
|
||||
#define EXT_WORKSPACE_ENABLE_CAPS \
|
||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ACTIVATE | \
|
||||
WLR_EXT_WORKSPACE_HANDLE_V1_CAP_DEACTIVATE
|
||||
|
||||
typedef struct Monitor Monitor;
|
||||
|
||||
struct workspace {
|
||||
|
|
@ -28,6 +32,17 @@ void goto_workspace(struct workspace *target) {
|
|||
}
|
||||
}
|
||||
|
||||
void toggle_workspace(struct workspace *target) {
|
||||
unsigned int tag;
|
||||
tag = 1 << (target->tag - 1);
|
||||
if (target->tag == 0) {
|
||||
toggleview(&(Arg){.i = -1});
|
||||
return;
|
||||
} else {
|
||||
toggleview(&(Arg){.ui = tag});
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_ext_workspace_activate(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct workspace *workspace =
|
||||
|
|
@ -36,6 +51,14 @@ static void handle_ext_workspace_activate(struct wl_listener *listener,
|
|||
wlr_log(WLR_INFO, "ext activating workspace %d", workspace->tag);
|
||||
}
|
||||
|
||||
static void handle_ext_workspace_deactivate(struct wl_listener *listener,
|
||||
void *data) {
|
||||
struct workspace *workspace =
|
||||
wl_container_of(listener, workspace, deactivate);
|
||||
toggle_workspace(workspace);
|
||||
wlr_log(WLR_INFO, "ext deactivating workspace %d", workspace->tag);
|
||||
}
|
||||
|
||||
static const char *get_name_from_tag(unsigned int tag) {
|
||||
static const char *names[] = {"overview", "1", "2", "3", "4",
|
||||
"5", "6", "7", "8", "9"};
|
||||
|
|
@ -44,6 +67,7 @@ static const char *get_name_from_tag(unsigned int tag) {
|
|||
|
||||
void destroy_workspace(struct workspace *workspace) {
|
||||
wl_list_remove(&workspace->activate.link);
|
||||
wl_list_remove(&workspace->deactivate.link);
|
||||
wlr_ext_workspace_handle_v1_destroy(workspace->ext_workspace);
|
||||
wl_list_remove(&workspace->link);
|
||||
free(workspace);
|
||||
|
|
@ -77,13 +101,18 @@ static void add_workspace_by_tag(int tag, Monitor *m) {
|
|||
workspace->tag = tag;
|
||||
workspace->m = m;
|
||||
workspace->ext_workspace = wlr_ext_workspace_handle_v1_create(
|
||||
ext_manager, name, WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ACTIVATE);
|
||||
ext_manager, name, EXT_WORKSPACE_ENABLE_CAPS);
|
||||
wlr_ext_workspace_handle_v1_set_group(workspace->ext_workspace,
|
||||
m->ext_group);
|
||||
wlr_ext_workspace_handle_v1_set_name(workspace->ext_workspace, name);
|
||||
|
||||
workspace->activate.notify = handle_ext_workspace_activate;
|
||||
wl_signal_add(&workspace->ext_workspace->events.activate,
|
||||
&workspace->activate);
|
||||
|
||||
workspace->deactivate.notify = handle_ext_workspace_deactivate;
|
||||
wl_signal_add(&workspace->ext_workspace->events.deactivate,
|
||||
&workspace->deactivate);
|
||||
}
|
||||
|
||||
void dwl_ext_workspace_printstatus(Monitor *m) {
|
||||
|
|
|
|||
|
|
@ -2656,7 +2656,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
// wlr_scene_node_set_enabled(&m->blur->node, 1);
|
||||
}
|
||||
m->ext_group = wlr_ext_workspace_group_handle_v1_create(
|
||||
ext_manager, WLR_EXT_WORKSPACE_HANDLE_V1_CAP_ACTIVATE);
|
||||
ext_manager, EXT_WORKSPACE_ENABLE_CAPS);
|
||||
wlr_ext_workspace_group_handle_v1_output_enter(m->ext_group, m->wlr_output);
|
||||
|
||||
for (i = 1; i <= LENGTH(tags); i++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue