diff --git a/docs/visuals/status-bar.md b/docs/visuals/status-bar.md index f2924e83..2be1cbae 100644 --- a/docs/visuals/status-bar.md +++ b/docs/visuals/status-bar.md @@ -17,7 +17,12 @@ Add the following to your Waybar configuration: { "modules-left": [ "ext/workspaces", - "dwl/window" + "mango/layout", + "mango/window" + ], + "modules-right": [ + "mango/language", + "mango/keymode", ], "ext/workspaces": { "format": "{icon}", @@ -26,13 +31,33 @@ Add the following to your Waybar configuration: "on-click-right": "deactivate", "sort-by-id": true }, - "dwl/window": { - "format": "[{layout}] {title}" - } + "mango/keymode": { + "format": "[{default}]", + "format-default": " Default", + "format-test": " Test", + }, + "mango/window": { + "format": "{}", + "icon": true, + "on-click":"bash ~/.config/mango/scripts/screenshot.sh", + "on-click-right":"bash ~/tool/shotTranslate.sh shot", + "icon": false, + "icon-size": 20 + }, + "mango/layout": { + "format": "{}", + // "format-S": "Scroller", + // "format-T": "Tile", + }, + "mango/language": { + "format": "{short}", + "format-us": "󰌌 US", + "format-ru": "󰌌 RU" + }, } ``` -## Styling +## Styling Example You can style the tags using standard CSS in `style.css`. @@ -40,27 +65,13 @@ You can style the tags using standard CSS in `style.css`. ```css #workspaces { - border-radius: 4px; - border-width: 2px; - border-style: solid; border-color: #c9b890; - margin-left: 4px; - padding-left: 10px; - padding-right: 6px; background: rgba(40, 40, 40, 0.76); } #workspaces button { - border: none; background: none; - box-shadow: inherit; - text-shadow: inherit; color: #ddca9e; - padding: 1px; - padding-left: 1px; - padding-right: 1px; - margin-right: 2px; - margin-left: 2px; } #workspaces button.hidden { @@ -79,61 +90,39 @@ You can style the tags using standard CSS in `style.css`. #workspaces button.active { background-color: #ddca9e; color: #282828; - margin-top: 5px; - margin-bottom: 5px; - padding-top: 1px; - padding-bottom: 0px; - border-radius: 3px; } #workspaces button.urgent { background-color: #ef5e5e; color: #282828; - margin-top: 5px; - margin-bottom: 5px; - padding-top: 1px; - padding-bottom: 0px; - border-radius: 3px; -} - -#tags { - background-color: transparent; -} - -#tags button { - background-color: #fff; - color: #a585cd; -} - -#tags button:not(.occupied):not(.focused) { - font-size: 0; - min-width: 0; - min-height: 0; - margin: -17px; - padding: 0; - color: transparent; - background-color: transparent; -} - -#tags button.occupied { - background-color: #fff; - color: #cdc885; -} - -#tags button.focused { - background-color: rgb(186, 142, 213); - color: #fff; -} - -#tags button.urgent { - background: rgb(171, 101, 101); - color: #fff; } #window { - background-color: rgb(237, 196, 147); - color: rgb(63, 37, 5); + background-color: #CA9297; + color: #282828; } + +window#waybar.empty #window { + background: none; + margin: 0px; + padding: 0px; +} + +#layout { + background-color: #CA9297; + color: #282828; +} + +#language { + background-color: #CA9297; + color: #282828; +} + +#keymode { + background-color: #CA9297; + color: #282828; +} + ``` ## Complete Configuration Example diff --git a/meson.build b/meson.build index 938371e5..5f0870f4 100644 --- a/meson.build +++ b/meson.build @@ -121,7 +121,6 @@ executable('mango', ) # build mmsg -dwl_ipc_protocol = 'protocols/dwl-ipc-unstable-v2.xml' wayland_scanner_client_header = generator( wayland_scanner, @@ -138,8 +137,6 @@ wayland_scanner_private_code = generator( # use generator in mmsg target executable('mmsg', 'mmsg/mmsg.c', - wayland_scanner_private_code.process(dwl_ipc_protocol), - wayland_scanner_client_header.process(dwl_ipc_protocol), dependencies: [ libwayland_client_dep ], diff --git a/protocols/dwl-ipc-unstable-v2.xml b/protocols/dwl-ipc-unstable-v2.xml deleted file mode 100644 index 5852107e..00000000 --- a/protocols/dwl-ipc-unstable-v2.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - - This protocol allows clients to update and get updates from dwl. - - Warning! The protocol described in this file is experimental and - backward incompatible changes may be made. Backward compatible - changes may be added together with the corresponding interface - version bump. - Backward incompatible changes are done by bumping the version - number in the protocol and interface names and resetting the - interface version. Once the protocol is to be declared stable, - the 'z' prefix and the version number in the protocol and - interface names are removed and the interface version number is - reset. - - - - - This interface is exposed as a global in wl_registry. - - Clients can use this interface to get a dwl_ipc_output. - After binding the client will recieve the dwl_ipc_manager.tags and dwl_ipc_manager.layout events. - The dwl_ipc_manager.tags and dwl_ipc_manager.layout events expose tags and layouts to the client. - - - - - Indicates that the client will not the dwl_ipc_manager object anymore. - Objects created through this instance are not affected. - - - - - - Get a dwl_ipc_outout for the specified wl_output. - - - - - - - - This event is sent after binding. - A roundtrip after binding guarantees the client recieved all tags. - - - - - - - This event is sent after binding. - A roundtrip after binding guarantees the client recieved all layouts. - - - - - - - - Observe and control a dwl output. - - Events are double-buffered: - Clients should cache events and redraw when a dwl_ipc_output.frame event is sent. - - Request are not double-buffered: - The compositor will update immediately upon request. - - - - - - - - - - - Indicates to that the client no longer needs this dwl_ipc_output. - - - - - - Indicates the client should hide or show themselves. - If the client is visible then hide, if hidden then show. - - - - - - Indicates if the output is active. Zero is invalid, nonzero is valid. - - - - - - - Indicates that a tag has been updated. - - - - - - - - - - Indicates a new layout is selected. - - - - - - - Indicates the title has changed. - - - - - - - Indicates the appid has changed. - - - - - - - Indicates the layout has changed. Since layout symbols are dynamic. - As opposed to the zdwl_ipc_manager.layout event, this should take precendence when displaying. - You can ignore the zdwl_ipc_output.layout event. - - - - - - - Indicates that a sequence of status updates have finished and the client should redraw. - - - - - - - - - - - - The tags are updated as follows: - new_tags = (current_tags AND and_tags) XOR xor_tags - - - - - - - - - - - - This request allows clients to instruct the compositor to quit mango. - - - - - - - - - - - - - - - - Indicates if the selected client on this output is fullscreen. - - - - - - - Indicates if the selected client on this output is floating. - - - - - - - Indicates if x coordinates of the selected client. - - - - - - - Indicates if y coordinates of the selected client. - - - - - - - Indicates if width of the selected client. - - - - - - - Indicates if height of the selected client. - - - - - - - last map layer. - - - - - - - current keyboard layout. - - - - - - - current keybind mode. - - - - - - - scale factor of monitor. - - - - - - - diff --git a/protocols/meson.build b/protocols/meson.build index 922a76ed..925bf42a 100644 --- a/protocols/meson.build +++ b/protocols/meson.build @@ -21,7 +21,6 @@ wayland_xmls = [ wl_protocol_dir + '/staging/ext-workspace/ext-workspace-v1.xml', wl_protocol_dir + '/staging/tearing-control/tearing-control-v1.xml', 'wlr-foreign-toplevel-management-unstable-v1.xml', - 'dwl-ipc-unstable-v2.xml', 'wlr-layer-shell-unstable-v1.xml', 'wlr-output-power-management-unstable-v1.xml', ] diff --git a/src/animation/client.h b/src/animation/client.h index 555922c4..2c39e511 100644 --- a/src/animation/client.h +++ b/src/animation/client.h @@ -519,8 +519,10 @@ void client_draw_shield(Client *c, struct wlr_box clip_box) { } if (active_capture_count > 0 && c->shield_when_capture) { - int32_t shield_x = clip_box.x - surface_relative_geom.x + (int32_t)c->bw; - int32_t shield_y = clip_box.y - surface_relative_geom.y + (int32_t)c->bw; + int32_t shield_x = + clip_box.x - surface_relative_geom.x + (int32_t)c->bw; + int32_t shield_y = + clip_box.y - surface_relative_geom.y + (int32_t)c->bw; wlr_scene_node_raise_to_top(&c->shield->node); wlr_scene_node_set_position(&c->shield->node, shield_x, shield_y); wlr_scene_rect_set_size(c->shield, clip_box.width, clip_box.height); @@ -558,8 +560,10 @@ void client_draw_blur(Client *c, struct wlr_box clip_box, struct ivec2 offset) { c->animation.current.height - 2 * (int32_t)c->bw; } - int32_t blur_x = clip_box.x - surface_relative_geom.x + (int32_t)c->bw; - int32_t blur_y = clip_box.y - surface_relative_geom.y + (int32_t)c->bw; + int32_t blur_x = + clip_box.x - surface_relative_geom.x + (int32_t)c->bw; + int32_t blur_y = + clip_box.y - surface_relative_geom.y + (int32_t)c->bw; wlr_scene_node_set_enabled(&c->blur->node, true); wlr_scene_node_set_position(&c->blur->node, blur_x, blur_y); wlr_scene_blur_set_size(c->blur, clip_box.width, clip_box.height); diff --git a/src/ext-protocol/all.h b/src/ext-protocol/all.h index e9923c35..f0282626 100644 --- a/src/ext-protocol/all.h +++ b/src/ext-protocol/all.h @@ -1,4 +1,3 @@ -#include "dwl-ipc.h" #include "ext-workspace.h" #include "foreign-toplevel.h" #include "hdr.h" diff --git a/src/ext-protocol/dwl-ipc.h b/src/ext-protocol/dwl-ipc.h deleted file mode 100644 index 53d96309..00000000 --- a/src/ext-protocol/dwl-ipc.h +++ /dev/null @@ -1,309 +0,0 @@ -#include "dwl-ipc-unstable-v2-protocol.h" - -static void dwl_ipc_manager_bind(struct wl_client *client, void *data, - uint32_t version, uint32_t id); -static void dwl_ipc_manager_destroy(struct wl_resource *resource); -static void dwl_ipc_manager_get_output(struct wl_client *client, - struct wl_resource *resource, - uint32_t id, struct wl_resource *output); -static void dwl_ipc_manager_release(struct wl_client *client, - struct wl_resource *resource); -static void dwl_ipc_output_destroy(struct wl_resource *resource); -static void dwl_ipc_output_printstatus(Monitor *monitor); -static void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output); -static void dwl_ipc_output_set_client_tags(struct wl_client *client, - struct wl_resource *resource, - uint32_t and_tags, - uint32_t xor_tags); -static void dwl_ipc_output_set_layout(struct wl_client *client, - struct wl_resource *resource, - uint32_t index); -static void dwl_ipc_output_set_tags(struct wl_client *client, - struct wl_resource *resource, - uint32_t tagmask, uint32_t toggle_tagset); -static void dwl_ipc_output_quit(struct wl_client *client, - struct wl_resource *resource); -static void dwl_ipc_output_dispatch(struct wl_client *client, - struct wl_resource *resource, - const char *dispatch, const char *arg1, - const char *arg2, const char *arg3, - const char *arg4, const char *arg5); -static void dwl_ipc_output_release(struct wl_client *client, - struct wl_resource *resource); - -/* global event handlers */ -static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = { - .release = dwl_ipc_manager_release, - .get_output = dwl_ipc_manager_get_output}; -static struct zdwl_ipc_output_v2_interface dwl_output_implementation = { - .release = dwl_ipc_output_release, - .set_tags = dwl_ipc_output_set_tags, - .quit = dwl_ipc_output_quit, - .dispatch = dwl_ipc_output_dispatch, - .set_layout = dwl_ipc_output_set_layout, - .set_client_tags = dwl_ipc_output_set_client_tags}; - -void dwl_ipc_manager_bind(struct wl_client *client, void *data, - uint32_t version, uint32_t id) { - struct wl_resource *manager_resource = - wl_resource_create(client, &zdwl_ipc_manager_v2_interface, version, id); - if (!manager_resource) { - wl_client_post_no_memory(client); - return; - } - wl_resource_set_implementation(manager_resource, - &dwl_manager_implementation, NULL, - dwl_ipc_manager_destroy); - - zdwl_ipc_manager_v2_send_tags(manager_resource, LENGTH(tags)); - - for (uint32_t i = 0; i < LENGTH(layouts); i++) - zdwl_ipc_manager_v2_send_layout(manager_resource, layouts[i].symbol); -} - -void dwl_ipc_manager_destroy(struct wl_resource *resource) { - /* No state to destroy */ -} - -void dwl_ipc_manager_get_output(struct wl_client *client, - struct wl_resource *resource, uint32_t id, - struct wl_resource *output) { - DwlIpcOutput *ipc_output; - struct wlr_output *op = wlr_output_from_resource(output); - if (!op) - return; - Monitor *monitor = op->data; - struct wl_resource *output_resource = - wl_resource_create(client, &zdwl_ipc_output_v2_interface, - wl_resource_get_version(resource), id); - if (!output_resource) - return; - - ipc_output = ecalloc(1, sizeof(*ipc_output)); - ipc_output->resource = output_resource; - ipc_output->mon = monitor; - wl_resource_set_implementation(output_resource, &dwl_output_implementation, - ipc_output, dwl_ipc_output_destroy); - wl_list_insert(&monitor->dwl_ipc_outputs, &ipc_output->link); - dwl_ipc_output_printstatus_to(ipc_output); -} - -void dwl_ipc_manager_release(struct wl_client *client, - struct wl_resource *resource) { - wl_resource_destroy(resource); -} - -static void dwl_ipc_output_destroy(struct wl_resource *resource) { - DwlIpcOutput *ipc_output = wl_resource_get_user_data(resource); - wl_list_remove(&ipc_output->link); - free(ipc_output); -} - -// 修改IPC输出函数,接受掩码参数 -void dwl_ipc_output_printstatus(Monitor *monitor) { - DwlIpcOutput *ipc_output; - wl_list_for_each(ipc_output, &monitor->dwl_ipc_outputs, link) - dwl_ipc_output_printstatus_to(ipc_output); -} - -// 修改主IPC输出函数,根据掩码发送相应事件 -void dwl_ipc_output_printstatus_to(DwlIpcOutput *ipc_output) { - Monitor *monitor = ipc_output->mon; - Client *c = NULL, *focused = NULL; - struct wlr_keyboard *keyboard; - xkb_layout_index_t current; - int32_t tagmask, state, numclients, focused_client, tag; - const char *title, *appid, *symbol; - char kb_layout[32]; - focused = focustop(monitor); - zdwl_ipc_output_v2_send_active(ipc_output->resource, monitor == selmon); - - for (tag = 0; tag < LENGTH(tags); tag++) { - numclients = state = focused_client = 0; - tagmask = 1 << tag; - if ((tagmask & monitor->tagset[monitor->seltags]) != 0) - state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_ACTIVE; - wl_list_for_each(c, &clients, link) { - if (c->mon != monitor) - continue; - if (!(c->tags & tagmask)) - continue; - if (c == focused) - focused_client = 1; - if (c->isurgent) - state |= ZDWL_IPC_OUTPUT_V2_TAG_STATE_URGENT; - numclients++; - } - zdwl_ipc_output_v2_send_tag(ipc_output->resource, tag, state, - numclients, focused_client); - } - - title = focused ? client_get_title(focused) : ""; - appid = focused ? client_get_appid(focused) : ""; - - if (monitor->isoverview) { - symbol = overviewlayout.symbol; - } else { - symbol = monitor->pertag->ltidxs[monitor->pertag->curtag]->symbol; - } - - keyboard = &kb_group->wlr_group->keyboard; - current = xkb_state_serialize_layout(keyboard->xkb_state, - XKB_STATE_LAYOUT_EFFECTIVE); - get_layout_abbr(kb_layout, - xkb_keymap_layout_get_name(keyboard->keymap, current)); - - zdwl_ipc_output_v2_send_layout( - ipc_output->resource, - monitor->pertag->ltidxs[monitor->pertag->curtag] - layouts); - zdwl_ipc_output_v2_send_title(ipc_output->resource, title ? title : broken); - zdwl_ipc_output_v2_send_appid(ipc_output->resource, appid ? appid : broken); - zdwl_ipc_output_v2_send_layout_symbol(ipc_output->resource, symbol); - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_FULLSCREEN_SINCE_VERSION) { - zdwl_ipc_output_v2_send_fullscreen(ipc_output->resource, - focused ? focused->isfullscreen : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_FLOATING_SINCE_VERSION) { - zdwl_ipc_output_v2_send_floating(ipc_output->resource, - focused ? focused->isfloating : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_X_SINCE_VERSION) { - zdwl_ipc_output_v2_send_x(ipc_output->resource, - focused ? focused->geom.x : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_Y_SINCE_VERSION) { - zdwl_ipc_output_v2_send_y(ipc_output->resource, - focused ? focused->geom.y : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_WIDTH_SINCE_VERSION) { - zdwl_ipc_output_v2_send_width(ipc_output->resource, - focused ? focused->geom.width : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_HEIGHT_SINCE_VERSION) { - zdwl_ipc_output_v2_send_height(ipc_output->resource, - focused ? focused->geom.height : 0); - } - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_LAST_LAYER_SINCE_VERSION) { - zdwl_ipc_output_v2_send_last_layer(ipc_output->resource, - monitor->last_open_surface); - } - - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_KB_LAYOUT_SINCE_VERSION) { - zdwl_ipc_output_v2_send_kb_layout(ipc_output->resource, kb_layout); - } - - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_KEYMODE_SINCE_VERSION) { - zdwl_ipc_output_v2_send_keymode(ipc_output->resource, keymode.mode); - } - - if (wl_resource_get_version(ipc_output->resource) >= - ZDWL_IPC_OUTPUT_V2_SCALEFACTOR_SINCE_VERSION) { - zdwl_ipc_output_v2_send_scalefactor(ipc_output->resource, - monitor->wlr_output->scale * 100); - } - - zdwl_ipc_output_v2_send_frame(ipc_output->resource); -} - -void dwl_ipc_output_set_client_tags(struct wl_client *client, - struct wl_resource *resource, - uint32_t and_tags, uint32_t xor_tags) { - DwlIpcOutput *ipc_output; - Monitor *monitor = NULL; - Client *selected_client = NULL; - uint32_t newtags = 0; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - - monitor = ipc_output->mon; - selected_client = focustop(monitor); - if (!selected_client) - return; - - newtags = (selected_client->tags & and_tags) ^ xor_tags; - if (!newtags) - return; - - selected_client->tags = newtags; - if (selmon == monitor) - focusclient(focustop(monitor), 1); - arrange(selmon, false, false); - printstatus(IPC_WATCH_ARRANGGE); -} - -void dwl_ipc_output_set_layout(struct wl_client *client, - struct wl_resource *resource, uint32_t index) { - DwlIpcOutput *ipc_output; - Monitor *monitor = NULL; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - - monitor = ipc_output->mon; - if (index >= LENGTH(layouts)) - index = 0; - - monitor->pertag->ltidxs[monitor->pertag->curtag] = &layouts[index]; - clear_fullscreen_and_maximized_state(monitor); - arrange(monitor, false, false); - printstatus(IPC_WATCH_ARRANGGE); -} - -void dwl_ipc_output_set_tags(struct wl_client *client, - struct wl_resource *resource, uint32_t tagmask, - uint32_t toggle_tagset) { - DwlIpcOutput *ipc_output; - Monitor *monitor = NULL; - uint32_t newtags = tagmask & TAGMASK; - - ipc_output = wl_resource_get_user_data(resource); - if (!ipc_output) - return; - monitor = ipc_output->mon; - - view_in_mon(&(Arg){.ui = newtags}, true, monitor, true); -} - -void dwl_ipc_output_quit(struct wl_client *client, - struct wl_resource *resource) { - quit(&(Arg){0}); -} - -void dwl_ipc_output_dispatch(struct wl_client *client, - struct wl_resource *resource, const char *dispatch, - const char *arg1, const char *arg2, - const char *arg3, const char *arg4, - const char *arg5) { - - int32_t (*func)(const Arg *); - Arg arg; - func = parse_func_name((char *)dispatch, &arg, (char *)arg1, (char *)arg2, - (char *)arg3, (char *)arg4, (char *)arg5); - if (func) { - func(&arg); - } - - if (arg.v) - free(arg.v); - if (arg.v2) - free(arg.v2); - if (arg.v3) - free(arg.v3); -} - -void dwl_ipc_output_release(struct wl_client *client, - struct wl_resource *resource) { - wl_resource_destroy(resource); -} diff --git a/src/mango.c b/src/mango.c index 2719c91b..a6d30c25 100644 --- a/src/mango.c +++ b/src/mango.c @@ -583,7 +583,6 @@ struct Monitor { uint32_t resizing_count_pending; uint32_t resizing_count_current; - struct wl_list dwl_ipc_outputs; int32_t gappih; /* horizontal gap between windows */ int32_t gappiv; /* vertical gap between windows */ int32_t gappoh; /* horizontal outer gaps */ @@ -3438,8 +3437,6 @@ void createmon(struct wl_listener *listener, void *data) { m->wlr_output = wlr_output; m->wlr_output->data = m; - wl_list_init(&m->dwl_ipc_outputs); - for (i = 0; i < LENGTH(m->layers); i++) wl_list_init(&m->layers[i]); @@ -6105,7 +6102,6 @@ void handle_print_status(struct wl_listener *listener, void *data) { } dwl_ext_workspace_printstatus(m); - dwl_ipc_output_printstatus(m); } } @@ -6470,9 +6466,6 @@ void setup(void) { wlr_log(WLR_INFO, "VR will not be available."); } - wl_global_create(dpy, &zdwl_ipc_manager_v2_interface, 2, NULL, - dwl_ipc_manager_bind); - // 创建顶层管理句柄 foreign_toplevel_manager = wlr_foreign_toplevel_manager_v1_create(dpy); struct wlr_xdg_foreign_registry *foreign_registry =