diff options
-rw-r--r-- | include/sway/config.h | 1 | ||||
-rw-r--r-- | include/swaybar/bar.h | 1 | ||||
-rw-r--r-- | meson.build | 27 | ||||
-rw-r--r-- | sway/commands.c | 3 | ||||
-rw-r--r-- | sway/commands/bar/mode.c | 2 | ||||
-rw-r--r-- | sway/commands/hide_edge_borders.c | 10 | ||||
-rw-r--r-- | sway/commands/output/transform.c | 3 | ||||
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/config/output.c | 2 | ||||
-rw-r--r-- | sway/desktop/render.c | 8 | ||||
-rw-r--r-- | sway/input/cursor.c | 6 | ||||
-rw-r--r-- | sway/sway-bar.5.scd | 6 | ||||
-rw-r--r-- | sway/sway.5.scd | 12 | ||||
-rw-r--r-- | sway/tree/view.c | 19 | ||||
-rw-r--r-- | swaybar/bar.c | 16 |
15 files changed, 86 insertions, 31 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index ab494e78..46ca7cee 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -465,6 +465,7 @@ struct sway_config { int floating_border_thickness; enum edge_border_types hide_edge_borders; enum edge_border_types saved_edge_borders; + bool hide_lone_tab; // border colors struct { diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h index dfadc200..031993b5 100644 --- a/include/swaybar/bar.h +++ b/include/swaybar/bar.h @@ -58,6 +58,7 @@ struct swaybar_output { struct zxdg_output_v1 *xdg_output; struct wl_surface *surface; struct zwlr_layer_surface_v1 *layer_surface; + struct wl_region *input_region; uint32_t wl_name; struct wl_list workspaces; // swaybar_workspace::link diff --git a/meson.build b/meson.build index 45df8799..53454cdd 100644 --- a/meson.build +++ b/meson.build @@ -60,17 +60,19 @@ rt = cc.find_library('rt') git = find_program('git', required: false) # Try first to find wlroots as a subproject, then as a system dependency +wlroots_version = '>=0.4.1' wlroots_proj = subproject( 'wlroots', default_options: ['rootston=false', 'examples=false'], required: false, + version: wlroots_version, ) if wlroots_proj.found() wlroots = wlroots_proj.get_variable('wlroots') wlroots_conf = wlroots_proj.get_variable('conf_data') wlroots_has_xwayland = wlroots_conf.get('WLR_HAS_XWAYLAND') == 1 else - wlroots = dependency('wlroots') + wlroots = dependency('wlroots', version: wlroots_version) wlroots_has_xwayland = cc.get_define('WLR_HAS_XWAYLAND', prefix: '#include <wlr/config.h>', dependencies: wlroots) == '1' endif @@ -93,11 +95,6 @@ conf_data.set10('HAVE_SYSTEMD', systemd.found()) conf_data.set10('HAVE_ELOGIND', elogind.found()) conf_data.set10('HAVE_TRAY', have_tray) -if not systemd.found() and not elogind.found() - warning('The sway binary must be setuid when compiled without (e)logind') - warning('You must do this manually post-install: chmod a+s /path/to/sway') -endif - scdoc = find_program('scdoc', required: get_option('man-pages')) if scdoc.found() sh = find_program('sh') @@ -236,3 +233,21 @@ if get_option('fish-completions') install_data(fish_files, install_dir: fish_install_dir) endif + +status = [ + '', + 'Features:', + 'xwayland: @0@'.format(have_xwayland), + 'gdk-pixbuf: @0@'.format(gdk_pixbuf.found()), + 'systemd: @0@'.format(systemd.found()), + 'elogind: @0@'.format(elogind.found()), + 'tray: @0@'.format(have_tray), + 'man-pages: @0@'.format(scdoc.found()), + '', +] +message('\n'.join(status)) + +if not systemd.found() and not elogind.found() + warning('The sway binary must be setuid when compiled without (e)logind') + warning('You must do this manually post-install: chmod a+s /path/to/sway') +endif diff --git a/sway/commands.c b/sway/commands.c index 3fc4f86e..522a5fd4 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -255,7 +255,8 @@ list_t *execute_command(char *_exec, struct sway_seat *seat, int argc; char **argv = split_args(cmd, &argc); if (strcmp(argv[0], "exec") != 0 && - strcmp(argv[0], "exec_always") != 0) { + strcmp(argv[0], "exec_always") != 0 && + strcmp(argv[0], "mode") != 0) { int i; for (i = 1; i < argc; ++i) { if (*argv[i] == '\"' || *argv[i] == '\'') { diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 68a80abf..1081ad4b 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -20,6 +20,8 @@ static struct cmd_results *bar_set_mode(struct bar_config *bar, const char *mode bar->mode = strdup("hide"); } else if (strcasecmp("invisible", mode) == 0) { bar->mode = strdup("invisible"); + } else if (strcasecmp("overlay", mode) == 0) { + bar->mode = strdup("overlay"); } else { return cmd_results_new(CMD_INVALID, "Invalid value %s", mode); } diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c index 84a217b8..6120a17f 100644 --- a/sway/commands/hide_edge_borders.c +++ b/sway/commands/hide_edge_borders.c @@ -5,10 +5,16 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { struct cmd_results *error = NULL; - if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_EQUAL_TO, 1))) { + if ((error = checkarg(argc, "hide_edge_borders", EXPECTED_AT_LEAST, 1))) { return error; } + if (strcmp(*argv, "--i3") == 0) { + config->hide_lone_tab = true; + ++argv; + --argc; + } + if (strcmp(argv[0], "none") == 0) { config->hide_edge_borders = E_NONE; } else if (strcmp(argv[0], "vertical") == 0) { @@ -23,7 +29,7 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { config->hide_edge_borders = E_SMART_NO_GAPS; } else { return cmd_results_new(CMD_INVALID, "Expected 'hide_edge_borders " - "<none|vertical|horizontal|both|smart|smart_no_gaps>'"); + "[--i3] <none|vertical|horizontal|both|smart|smart_no_gaps>'"); } config->saved_edge_borders = config->hide_edge_borders; diff --git a/sway/commands/output/transform.c b/sway/commands/output/transform.c index 8613a8e7..8e5324ad 100644 --- a/sway/commands/output/transform.c +++ b/sway/commands/output/transform.c @@ -12,7 +12,8 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Missing transform argument."); } enum wl_output_transform transform; - if (strcmp(*argv, "normal") == 0) { + if (strcmp(*argv, "normal") == 0 || + strcmp(*argv, "0") == 0) { transform = WL_OUTPUT_TRANSFORM_NORMAL; } else if (strcmp(*argv, "90") == 0) { transform = WL_OUTPUT_TRANSFORM_90; diff --git a/sway/config.c b/sway/config.c index 4cd21bbc..48bbd1ea 100644 --- a/sway/config.c +++ b/sway/config.c @@ -261,6 +261,7 @@ static void config_defaults(struct sway_config *config) { config->floating_border_thickness = 2; config->hide_edge_borders = E_NONE; config->saved_edge_borders = E_NONE; + config->hide_lone_tab = false; // border colors set_color(config->border_colors.focused.border, 0x4C7899); diff --git a/sway/config/output.c b/sway/config/output.c index e7fbad83..cb889b3e 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -378,7 +378,7 @@ static struct output_config *get_output_config(char *identifier, oc_id = config->output_configs->items[i]; } - struct output_config *result = result = new_output_config("temp"); + struct output_config *result = new_output_config("temp"); if (config->reloading) { default_output_config(result, sway_output->wlr_output); } diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 92e623ef..5df16075 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -841,6 +841,14 @@ static void render_containers_stacked(struct sway_output *output, static void render_containers(struct sway_output *output, pixman_region32_t *damage, struct parent_data *parent) { + if (config->hide_lone_tab && parent->children->length == 1) { + struct sway_container *child = parent->children->items[0]; + if (child->view) { + render_containers_linear(output,damage, parent); + return; + } + } + switch (parent->layout) { case L_NONE: case L_HORIZ: diff --git a/sway/input/cursor.c b/sway/input/cursor.c index fb4728b4..87811550 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -280,7 +280,7 @@ static void cursor_do_rebase(struct sway_cursor *cursor, uint32_t time_msec, void cursor_rebase(struct sway_cursor *cursor) { uint32_t time_msec = get_current_time_msec(); struct wlr_surface *surface = NULL; - double sx, sy; + double sx = 0.0, sy = 0.0; cursor->previous.node = node_at_coords(cursor->seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); cursor_do_rebase(cursor, time_msec, cursor->previous.node, surface, sx, sy); @@ -431,7 +431,7 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) { struct sway_node *node = NULL; double sx, sy; if (cursor->active_constraint) { - node = node_at_coords(cursor->seat, + node_at_coords(cursor->seat, cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); if (cursor->active_constraint->surface != surface) { @@ -476,7 +476,7 @@ static void cursor_motion_absolute(struct sway_cursor *cursor, dx, dy, dx, dy); struct wlr_surface *surface = NULL; - double sx, sy; + double sx = 0.0, sy = 0.0; struct sway_node *node = node_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd index 13827e5e..1f4ceaf2 100644 --- a/sway/sway-bar.5.scd +++ b/sway/sway-bar.5.scd @@ -84,11 +84,13 @@ Sway allows configuring swaybar in the sway configuration file. debug-events`. To disable the default behavior for a button, use the command _nop_. -*mode* dock|hide|invisible +*mode* dock|hide|invisible|overlay Specifies the visibility of the bar. In _dock_ mode, it is permanently visible at one edge of the screen. In _hide_ mode, it is hidden unless the modifier key is pressed, though this behaviour depends on the hidden state. - In _invisible_ mode, it is permanently hidden. Default is _dock_. + In _invisible_ mode, it is permanently hidden. In _overlay_ mode, it is + permanently visible on top of other windows. (In _overlay_ mode the bar is + transparent to input events.) Default is _dock_. *hidden_state* hide|show Specifies the behaviour of the bar when it is in _hide_ mode. When the diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 1b85a75b..8f8b7e3d 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -493,8 +493,10 @@ The default colors are: This affects new workspaces only, and is used when the workspace doesn't have its own gaps settings (see: workspace <ws> gaps ...). -*hide_edge_borders* none|vertical|horizontal|both|smart|smart_no_gaps - Hides window borders adjacent to the screen edges. Default is _none_. +*hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps + Hides window borders adjacent to the screen edges. Default is _none_. The + _--i3_ option enables i3-compatible behavior to hide the title bar on tabbed + and stacked containers with one child. *input* <input_device> <input-subcommands...> For details on input subcommands, see *sway-input*(5). @@ -511,9 +513,9 @@ The default colors are: *smart_borders* on|no_gaps|off If smart_borders are _on_, borders will only be enabled if the workspace - only has one visible child (identical to _hide_edge_borders_ smart). If - smart_borders is set to _no_gaps_, borders will only be enabled if the - workspace only has one visible child and gaps greater than zero. + has more than one visible child (identical to _hide_edge_borders_ smart). + If smart_borders is set to _no_gaps_, borders will only be enabled if the + workspace has more than one visible child and gaps equal to zero. *smart_gaps* on|off If smart_gaps are _on_ gaps will only be enabled if a workspace has more diff --git a/sway/tree/view.c b/sway/tree/view.c index ca13def7..14cc07d9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -246,14 +246,17 @@ void view_autoconfigure(struct sway_view *view) { // In a tabbed or stacked container, the container's y is the top of the // title area. We have to offset the surface y by the height of the title, // bar, and disable any top border because we'll always have the title bar. - enum sway_container_layout layout = container_parent_layout(con); - if (layout == L_TABBED && !container_is_floating(con)) { - y_offset = container_titlebar_height(); - con->border_top = false; - } else if (layout == L_STACKED && !container_is_floating(con)) { - list_t *siblings = container_get_siblings(con); - y_offset = container_titlebar_height() * siblings->length; - con->border_top = false; + list_t *siblings = container_get_siblings(con); + bool show_titlebar = siblings->length > 1 || !config->hide_lone_tab; + if (show_titlebar && !container_is_floating(con)) { + enum sway_container_layout layout = container_parent_layout(con); + if (layout == L_TABBED) { + y_offset = container_titlebar_height(); + con->border_top = false; + } else if (layout == L_STACKED) { + y_offset = container_titlebar_height() * siblings->length; + con->border_top = false; + } } double x, y, width, height; diff --git a/swaybar/bar.c b/swaybar/bar.c index db1c1222..ca7cd88c 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -51,6 +51,9 @@ static void swaybar_output_free(struct swaybar_output *output) { if (output->surface != NULL) { wl_surface_destroy(output->surface); } + if (output->input_region != NULL) { + wl_region_destroy(output->input_region); + } zxdg_output_v1_destroy(output->xdg_output); wl_output_destroy(output->output); destroy_buffer(&output->buffers[0]); @@ -100,16 +103,25 @@ static void add_layer_surface(struct swaybar_output *output) { struct swaybar_config *config = bar->config; bool hidden = strcmp(config->mode, "hide") == 0; + bool overlay = !hidden && strcmp(config->mode, "overlay") == 0; output->layer_surface = zwlr_layer_shell_v1_get_layer_surface( bar->layer_shell, output->surface, output->output, - hidden ? ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY : + hidden || overlay ? ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY : ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel"); assert(output->layer_surface); zwlr_layer_surface_v1_add_listener(output->layer_surface, &layer_surface_listener, output); + if (overlay) { + // Empty input region + output->input_region = wl_compositor_create_region(bar->compositor); + assert(output->input_region); + + wl_surface_set_input_region(output->surface, output->input_region); + } + zwlr_layer_surface_v1_set_anchor(output->layer_surface, config->position); - if (hidden) { + if (hidden || overlay) { zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, -1); } } |