mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-07 13:29:59 -05:00
feat: support toggleview action in ext-workspace
This commit is contained in:
parent
4708c10b89
commit
bcc6fb7454
2 changed files with 31 additions and 2 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
#include "wlr_ext_workspace_v1.h"
|
#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;
|
typedef struct Monitor Monitor;
|
||||||
|
|
||||||
struct workspace {
|
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,
|
static void handle_ext_workspace_activate(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct workspace *workspace =
|
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);
|
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 *get_name_from_tag(unsigned int tag) {
|
||||||
static const char *names[] = {"overview", "1", "2", "3", "4",
|
static const char *names[] = {"overview", "1", "2", "3", "4",
|
||||||
"5", "6", "7", "8", "9"};
|
"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) {
|
void destroy_workspace(struct workspace *workspace) {
|
||||||
wl_list_remove(&workspace->activate.link);
|
wl_list_remove(&workspace->activate.link);
|
||||||
|
wl_list_remove(&workspace->deactivate.link);
|
||||||
wlr_ext_workspace_handle_v1_destroy(workspace->ext_workspace);
|
wlr_ext_workspace_handle_v1_destroy(workspace->ext_workspace);
|
||||||
wl_list_remove(&workspace->link);
|
wl_list_remove(&workspace->link);
|
||||||
free(workspace);
|
free(workspace);
|
||||||
|
|
@ -77,13 +101,18 @@ static void add_workspace_by_tag(int tag, Monitor *m) {
|
||||||
workspace->tag = tag;
|
workspace->tag = tag;
|
||||||
workspace->m = m;
|
workspace->m = m;
|
||||||
workspace->ext_workspace = wlr_ext_workspace_handle_v1_create(
|
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,
|
wlr_ext_workspace_handle_v1_set_group(workspace->ext_workspace,
|
||||||
m->ext_group);
|
m->ext_group);
|
||||||
wlr_ext_workspace_handle_v1_set_name(workspace->ext_workspace, name);
|
wlr_ext_workspace_handle_v1_set_name(workspace->ext_workspace, name);
|
||||||
|
|
||||||
workspace->activate.notify = handle_ext_workspace_activate;
|
workspace->activate.notify = handle_ext_workspace_activate;
|
||||||
wl_signal_add(&workspace->ext_workspace->events.activate,
|
wl_signal_add(&workspace->ext_workspace->events.activate,
|
||||||
&workspace->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) {
|
void dwl_ext_workspace_printstatus(Monitor *m) {
|
||||||
|
|
|
||||||
|
|
@ -2605,7 +2605,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
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);
|
||||||
|
|
||||||
m->ext_group = wlr_ext_workspace_group_handle_v1_create(
|
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);
|
wlr_ext_workspace_group_handle_v1_output_enter(m->ext_group, m->wlr_output);
|
||||||
|
|
||||||
for (i = 1; i <= LENGTH(tags); i++) {
|
for (i = 1; i <= LENGTH(tags); i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue