Compare commits

...

10 Commits

Author SHA1 Message Date
Ronan Pigott
dd224b36f3
Merge d06ae06c12 into 4cfcb3643b 2024-11-05 17:20:09 +01:00
Alexander Orzechowski
4cfcb3643b container: Properly constrain title bar padding
Important for centered titles
2024-11-04 19:02:16 +01:00
Simon Ser
d417a8fcd0 release.sh: read meson-rewrite output from stdout
Since version 1.6, Meson now uses stdout:
3f4957c713
2024-10-31 10:31:38 +01:00
Kenny Levinsen
f38719f575 desktop/output: Add missing output config allocation checks 2024-10-30 19:56:07 -04:00
Kenny Levinsen
1e53007bc3 desktop/output: Store output config on request_state
An output backend might request any change to an output state at any
time, although currently only this is currently only used for changing
window size on the wayland and x11 backend.

Applying the configuration directly means that the current output state
becomes inconsistent with the configured state, which can cause the new
state to be reverted later if apply_stored_output_configs is called.

Before 4f9ce4675c. the output geometry would be updated by
arrange_outputs, but this is only done by the modeset logic now,
resulting in the stored geometry never being updated on wayland backend
window resize. This was not discovered as the stored geometry is not
used particularly often.

Solve both by storing a new output configuration and relying on the
modeset logic to apply a new state.

Fixes: 4f9ce4675c ("tree/arrange: Remove redundant output geometry update")
2024-10-30 19:56:07 -04:00
AsciiWolf
e7c972b04a Remove language bars from remaining non-English README files 2024-10-28 14:06:01 +01:00
llyyr
839434abc0 sway/server: bind to presentation-time-v2
Depends on: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4858
2024-10-27 19:20:20 -04:00
Kirill Primak
015e357fce desktop/output: chase wlroots private fields update
This will be replaced with a proper solution later.
2024-10-25 17:42:35 +02:00
Ronan Pigott
d06ae06c12 Document get_binding_modes with payload 2022-09-19 22:11:50 -07:00
Ronan Pigott
c98ef97eed ipc: add query for mode bindings 2022-09-19 22:11:50 -07:00
10 changed files with 576 additions and 99 deletions

View File

@ -1,7 +1,5 @@
# sway # sway
[English][en] - [عربي][ar] - **[Česky][cs]** - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - [ქართული][ge] - [Ελληνικά][gr] - [हिन्दी][hi] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Norsk][no] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Svenska][sv] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
sway je s [i3] kompatibilní [Wayland] kompozitor. Přečtěte si [FAQ]. Připojte se na sway je s [i3] kompatibilní [Wayland] kompozitor. Přečtěte si [FAQ]. Připojte se na
[IRC kanál][IRC channel] \(#sway na irc.libera.chat). [IRC kanál][IRC channel] \(#sway na irc.libera.chat).

View File

@ -1,7 +1,5 @@
# sway # sway
[English][en] - [Deutsch][de] - [Dansk][dk] - [Español][es] - [Français][fr] - **[Svenska][sv]** - [Ελληνικά][gr] - [Magyar][hu] - [فارسی][ir] - [Italiano][it] - [日本語][ja] - [한국어][ko] - [Nederlands][nl] - [Polski][pl] - [Português][pt] - [Română][ro] - [Русский][ru] - [Türkçe][tr] - [Українська][uk] - [中文-简体][zh-CN] - [中文-繁體][zh-TW]
sway är en [i3]-kompatibel [Wayland] compositor. Läs våran [FAQ]-sida. Gå med i vår sway är en [i3]-kompatibel [Wayland] compositor. Läs våran [FAQ]-sida. Gå med i vår
[IRC-kanal] \(#sway på irc.libera.chat). [IRC-kanal] \(#sway på irc.libera.chat).

View File

@ -8,6 +8,8 @@
json_object *ipc_json_get_version(void); json_object *ipc_json_get_version(void);
json_object *ipc_json_get_binding_mode(void); json_object *ipc_json_get_binding_mode(void);
json_object *ipc_json_describe_binding(struct sway_binding *binding);
json_object *ipc_json_describe_binding_mode(struct sway_mode *mode);
json_object *ipc_json_describe_disabled_output(struct sway_output *o); json_object *ipc_json_describe_disabled_output(struct sway_output *o);
json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o); json_object *ipc_json_describe_non_desktop_output(struct sway_output_non_desktop *o);

View File

@ -1,7 +1,7 @@
#!/bin/sh -eu #!/bin/sh -eu
prev=$(git describe --tags --abbrev=0) prev=$(git describe --tags --abbrev=0)
next=$(meson rewrite kwargs info project / 2>&1 >/dev/null | jq -r '.kwargs["project#/"].version') next=$(meson rewrite kwargs info project / | jq -r '.kwargs["project#/"].version')
case "$next" in case "$next" in
*-dev) *-dev)

View File

@ -188,8 +188,8 @@ static enum wlr_scale_filter_mode get_scale_filter(struct sway_output *output,
struct wlr_scene_buffer *buffer) { struct wlr_scene_buffer *buffer) {
// if we are scaling down, we should always choose linear // if we are scaling down, we should always choose linear
if (buffer->dst_width > 0 && buffer->dst_height > 0 && ( if (buffer->dst_width > 0 && buffer->dst_height > 0 && (
buffer->dst_width < buffer->buffer_width || buffer->dst_width < buffer->WLR_PRIVATE.buffer_width ||
buffer->dst_height < buffer->buffer_height)) { buffer->dst_height < buffer->WLR_PRIVATE.buffer_height)) {
return WLR_SCALE_FILTER_BILINEAR; return WLR_SCALE_FILTER_BILINEAR;
} }
@ -457,19 +457,47 @@ static void handle_request_state(struct wl_listener *listener, void *data) {
struct sway_output *output = struct sway_output *output =
wl_container_of(listener, output, request_state); wl_container_of(listener, output, request_state);
const struct wlr_output_event_request_state *event = data; const struct wlr_output_event_request_state *event = data;
const struct wlr_output_state *state = event->state;
uint32_t committed = event->state->committed; // Store the requested changes so that the active configuration is
wlr_output_commit_state(output->wlr_output, event->state); // consistent with the current state, and to avoid duplicate logic to apply
// the changes.
struct output_config *oc = new_output_config(output->wlr_output->name);
if (!oc) {
sway_log(SWAY_ERROR, "Allocation failed");
return;
}
if (committed & ( int committed = state->committed;
WLR_OUTPUT_STATE_MODE | if (committed & WLR_OUTPUT_STATE_MODE) {
WLR_OUTPUT_STATE_TRANSFORM | if (state->mode != NULL) {
WLR_OUTPUT_STATE_SCALE)) { oc->width = state->mode->width;
arrange_layers(output); oc->height = state->mode->height;
arrange_output(output); oc->refresh_rate = state->mode->refresh / 1000.f;
transaction_commit_dirty(); } else {
oc->width = state->custom_mode.width;
oc->height = state->custom_mode.height;
oc->refresh_rate = state->custom_mode.refresh / 1000.f;
}
committed &= ~WLR_OUTPUT_STATE_MODE;
}
if (committed & WLR_OUTPUT_STATE_SCALE) {
oc->scale = state->scale;
committed &= ~WLR_OUTPUT_STATE_SCALE;
}
if (committed & WLR_OUTPUT_STATE_TRANSFORM) {
oc->transform = state->transform;
committed &= ~WLR_OUTPUT_STATE_TRANSFORM;
}
update_output_manager_config(output->server); // We do not expect or support any other changes here
assert(committed == 0);
store_output_config(oc);
apply_stored_output_configs();
if (server.delayed_modeset != NULL) {
wl_event_source_remove(server.delayed_modeset);
server.delayed_modeset = NULL;
} }
} }
@ -554,6 +582,10 @@ void handle_new_output(struct wl_listener *listener, void *data) {
static struct output_config *output_config_for_config_head( static struct output_config *output_config_for_config_head(
struct wlr_output_configuration_head_v1 *config_head) { struct wlr_output_configuration_head_v1 *config_head) {
struct output_config *oc = new_output_config(config_head->state.output->name); struct output_config *oc = new_output_config(config_head->state.output->name);
if (!oc) {
return NULL;
}
oc->enabled = config_head->state.enabled; oc->enabled = config_head->state.enabled;
if (!oc->enabled) { if (!oc->enabled) {
return oc; return oc;
@ -584,7 +616,8 @@ static void output_manager_apply(struct sway_server *server,
size_t configs_len = config->output_configs->length + wl_list_length(&cfg->heads); size_t configs_len = config->output_configs->length + wl_list_length(&cfg->heads);
struct output_config **configs = calloc(configs_len, sizeof(*configs)); struct output_config **configs = calloc(configs_len, sizeof(*configs));
if (!configs) { if (!configs) {
goto done; sway_log(SWAY_ERROR, "Allocation failed");
goto error;
} }
size_t start_new_configs = config->output_configs->length; size_t start_new_configs = config->output_configs->length;
for (size_t idx = 0; idx < start_new_configs; idx++) { for (size_t idx = 0; idx < start_new_configs; idx++) {
@ -597,6 +630,10 @@ static void output_manager_apply(struct sway_server *server,
// Generate the configuration and store it as a temporary // Generate the configuration and store it as a temporary
// config. We keep a record of it so we can remove it later. // config. We keep a record of it so we can remove it later.
struct output_config *oc = output_config_for_config_head(config_head); struct output_config *oc = output_config_for_config_head(config_head);
if (!oc) {
sway_log(SWAY_ERROR, "Allocation failed");
goto error_config;
}
configs[config_idx++] = oc; configs[config_idx++] = oc;
} }
@ -604,6 +641,8 @@ static void output_manager_apply(struct sway_server *server,
// if any output configured for enablement fails to be enabled, even if it // if any output configured for enablement fails to be enabled, even if it
// was not part of the config heads we were asked to configure. // was not part of the config heads we were asked to configure.
ok = apply_output_configs(configs, configs_len, test_only, false); ok = apply_output_configs(configs, configs_len, test_only, false);
error_config:
for (size_t idx = start_new_configs; idx < configs_len; idx++) { for (size_t idx = start_new_configs; idx < configs_len; idx++) {
struct output_config *cfg = configs[idx]; struct output_config *cfg = configs[idx];
if (!test_only && ok) { if (!test_only && ok) {
@ -614,7 +653,7 @@ static void output_manager_apply(struct sway_server *server,
} }
free(configs); free(configs);
done: error:
if (ok) { if (ok) {
wlr_output_configuration_v1_send_succeeded(cfg); wlr_output_configuration_v1_send_succeeded(cfg);
if (server->delayed_modeset != NULL) { if (server->delayed_modeset != NULL) {
@ -649,6 +688,11 @@ void handle_output_power_manager_set_mode(struct wl_listener *listener,
struct sway_output *output = event->output->data; struct sway_output *output = event->output->data;
struct output_config *oc = new_output_config(output->wlr_output->name); struct output_config *oc = new_output_config(output->wlr_output->name);
if (!oc) {
sway_log(SWAY_ERROR, "Allocation failed");
return;
}
switch (event->mode) { switch (event->mode) {
case ZWLR_OUTPUT_POWER_V1_MODE_OFF: case ZWLR_OUTPUT_POWER_V1_MODE_OFF:
oc->power = 0; oc->power = 0;

View File

@ -18,6 +18,7 @@
#include "sway/output.h" #include "sway/output.h"
#include "sway/input/input-manager.h" #include "sway/input/input-manager.h"
#include "sway/input/cursor.h" #include "sway/input/cursor.h"
#include "sway/input/keyboard.h"
#include "sway/input/seat.h" #include "sway/input/seat.h"
#include "wlr-layer-shell-unstable-v1-protocol.h" #include "wlr-layer-shell-unstable-v1-protocol.h"
#include "sway/desktop/idle_inhibit_v1.h" #include "sway/desktop/idle_inhibit_v1.h"
@ -1446,3 +1447,193 @@ json_object *ipc_json_get_binding_mode(void) {
json_object_new_string(config->current_mode->name)); json_object_new_string(config->current_mode->name));
return current_mode; return current_mode;
} }
json_object *ipc_json_describe_binding_flags(uint32_t flags) {
json_object *json_flags = json_object_new_array();
if (flags & BINDING_RELEASE) {
json_object_array_add(json_flags, json_object_new_string("release"));
} else if (flags & BINDING_LOCKED) {
json_object_array_add(json_flags, json_object_new_string("locked"));
} else if (flags & BINDING_BORDER) {
json_object_array_add(json_flags, json_object_new_string("border"));
} else if (flags & BINDING_CONTENTS) {
json_object_array_add(json_flags, json_object_new_string("contents"));
} else if (flags & BINDING_TITLEBAR) {
json_object_array_add(json_flags, json_object_new_string("titlebar"));
} else if (flags & BINDING_CODE) {
json_object_array_add(json_flags, json_object_new_string("code"));
} else if (flags & BINDING_RELOAD) {
json_object_array_add(json_flags, json_object_new_string("reload"));
} else if (flags & BINDING_INHIBITED) {
json_object_array_add(json_flags, json_object_new_string("inhibited"));
} else if (flags & BINDING_NOREPEAT) {
json_object_array_add(json_flags, json_object_new_string("norepeat"));
}
return json_flags;
}
json_object *ipc_json_describe_switch_binding(struct sway_switch_binding *binding) {
json_object *json_binding = json_object_new_object();
json_object_object_add(json_binding, "command", json_object_new_string(binding->command));
json_object *type = NULL;
switch (binding->type) {
case WLR_SWITCH_TYPE_LID:
type = json_object_new_string("lid");
break;
case WLR_SWITCH_TYPE_TABLET_MODE:
type = json_object_new_string("tablet_mode");
break;
}
json_object_object_add(json_binding, "type", type);
json_object *trigger = NULL;
switch (binding->trigger) {
case SWAY_SWITCH_TRIGGER_OFF:
trigger = json_object_new_string("off");
break;
case SWAY_SWITCH_TRIGGER_ON:
trigger = json_object_new_string("on");
break;
case SWAY_SWITCH_TRIGGER_TOGGLE:
trigger = json_object_new_string("on");
break;
}
json_object_object_add(json_binding, "trigger", trigger);
json_object *flags = ipc_json_describe_binding_flags(binding->flags);
json_object_object_add(json_binding, "flags", flags);
return json_binding;
}
json_object *ipc_json_describe_binding(struct sway_binding *binding) {
json_object *json_binding = json_object_new_object();
json_object_object_add(json_binding, "command", json_object_new_string(binding->command));
const char *names[10];
int len = get_modifier_names(names, binding->modifiers);
json_object *modifiers = json_object_new_array();
for (int i = 0; i < len; ++i) {
json_object_array_add(modifiers, json_object_new_string(names[i]));
}
json_object_object_add(json_binding, "modifiers", modifiers);
json_object *input_codes = json_object_new_array();
int input_code = 0;
json_object *symbols = json_object_new_array();
json_object *symbol = NULL;
json_object *binding_flags = ipc_json_describe_binding_flags(binding->flags);
json_object_object_add(json_binding, "flags", binding_flags);
switch (binding->type) {
case BINDING_KEYCODE:
json_object_object_add(json_binding, "type", json_object_new_string("keycode"));
// bindcode: populate input_codes
uint32_t keycode;
for (int i = 0; i < binding->keys->length; ++i) {
keycode = *(uint32_t *)binding->keys->items[i];
json_object_array_add(input_codes, json_object_new_int(keycode));
if (i == 0) {
input_code = keycode;
}
}
break;
case BINDING_KEYSYM:
json_object_object_add(json_binding, "type", json_object_new_string("keysym"));
goto symbols;
case BINDING_MOUSESYM:
json_object_object_add(json_binding, "type", json_object_new_string("mousesym"));
goto symbols;
case BINDING_MOUSECODE:
json_object_object_add(json_binding, "type", json_object_new_string("mousecode"));
symbols:; // bindsym/mouse: populate symbols
uint32_t keysym;
char buffer[64];
for (int i = 0; i < binding->keys->length; ++i) {
keysym = *(uint32_t *)binding->keys->items[i];
if (keysym >= BTN_LEFT && keysym <= BTN_LEFT + 8) {
snprintf(buffer, 64, "button%u", keysym - BTN_LEFT + 1);
} else if (xkb_keysym_get_name(keysym, buffer, 64) < 0) {
continue;
}
json_object *str = json_object_new_string(buffer);
if (i == 0) {
// str is owned by both symbol and symbols. Make sure
// to bump the ref count.
json_object_array_add(symbols, json_object_get(str));
symbol = str;
} else {
json_object_array_add(symbols, str);
}
}
break;
default:
json_object_put(input_codes);
json_object_put(symbols);
json_object_put(json_binding);
return NULL; // do not send any event
}
json_object_object_add(json_binding, "input_codes", input_codes);
json_object_object_add(json_binding, "input_code", json_object_new_int(input_code));
json_object_object_add(json_binding, "symbols", symbols);
json_object_object_add(json_binding, "symbol", symbol);
bool mouse = binding->type == BINDING_MOUSECODE ||
binding->type == BINDING_MOUSESYM;
json_object_object_add(json_binding, "input_type", mouse
? json_object_new_string("mouse")
: json_object_new_string("keyboard"));
json_object_object_add(json_binding, "input_device",
json_object_new_string(binding->input));
return json_binding;
}
json_object *ipc_json_describe_binding_mode(struct sway_mode *mode) {
json_object *json_mode = json_object_new_object();
json_object_object_add(json_mode, "name", json_object_new_string(mode->name));
json_object *bindings = json_object_new_array();
for (int i = 0; i < mode->keysym_bindings->length; i++) {
struct sway_binding *binding = mode->keysym_bindings->items[i];
json_object *json_binding = ipc_json_describe_binding(binding);
if (json_binding) {
json_object_array_add(bindings, json_binding);
}
}
for (int i = 0; i < mode->keycode_bindings->length; i++) {
struct sway_binding *binding = mode->keycode_bindings->items[i];
json_object *json_binding = ipc_json_describe_binding(binding);
if (json_binding) {
json_object_array_add(bindings, json_binding);
}
}
for (int i = 0; i < mode->mouse_bindings->length; i++) {
struct sway_binding *binding = mode->mouse_bindings->items[i];
json_object *json_binding = ipc_json_describe_binding(binding);
if (json_binding) {
json_object_array_add(bindings, json_binding);
}
}
for (int i = 0; i < mode->switch_bindings->length; i++) {
struct sway_switch_binding *binding = mode->switch_bindings->items[i];
json_object *json_binding = ipc_json_describe_switch_binding(binding);
if (json_binding) {
json_object_array_add(bindings, json_binding);
}
}
json_object_object_add(json_mode, "bindings", bindings);
return json_mode;
}

View File

@ -397,77 +397,17 @@ void ipc_event_binding(struct sway_binding *binding) {
} }
sway_log(SWAY_DEBUG, "Sending binding event"); sway_log(SWAY_DEBUG, "Sending binding event");
json_object *json_binding = json_object_new_object(); json_object *json_binding = ipc_json_describe_binding(binding);
json_object_object_add(json_binding, "command", json_object_new_string(binding->command)); if (!json_binding) {
const char *names[10];
int len = get_modifier_names(names, binding->modifiers);
json_object *modifiers = json_object_new_array();
for (int i = 0; i < len; ++i) {
json_object_array_add(modifiers, json_object_new_string(names[i]));
}
json_object_object_add(json_binding, "event_state_mask", modifiers);
json_object *input_codes = json_object_new_array();
int input_code = 0;
json_object *symbols = json_object_new_array();
json_object *symbol = NULL;
switch (binding->type) {
case BINDING_KEYCODE:; // bindcode: populate input_codes
uint32_t keycode;
for (int i = 0; i < binding->keys->length; ++i) {
keycode = *(uint32_t *)binding->keys->items[i];
json_object_array_add(input_codes, json_object_new_int(keycode));
if (i == 0) {
input_code = keycode;
}
}
break;
case BINDING_KEYSYM:
case BINDING_MOUSESYM:
case BINDING_MOUSECODE:; // bindsym/mouse: populate symbols
uint32_t keysym;
char buffer[64];
for (int i = 0; i < binding->keys->length; ++i) {
keysym = *(uint32_t *)binding->keys->items[i];
if (keysym >= BTN_LEFT && keysym <= BTN_LEFT + 8) {
snprintf(buffer, 64, "button%u", keysym - BTN_LEFT + 1);
} else if (xkb_keysym_get_name(keysym, buffer, 64) < 0) {
continue;
}
json_object *str = json_object_new_string(buffer);
if (i == 0) {
// str is owned by both symbol and symbols. Make sure
// to bump the ref count.
json_object_array_add(symbols, json_object_get(str));
symbol = str;
} else {
json_object_array_add(symbols, str);
}
}
break;
default:
sway_log(SWAY_DEBUG, "Unsupported ipc binding event"); sway_log(SWAY_DEBUG, "Unsupported ipc binding event");
json_object_put(input_codes);
json_object_put(symbols);
json_object_put(json_binding);
return; // do not send any event return; // do not send any event
} }
json_object_object_add(json_binding, "input_codes", input_codes); // Modifiers are "event_state_mask" in i3 ipc binding event
json_object_object_add(json_binding, "input_code", json_object_new_int(input_code)); json_object *modifiers = json_object_object_get(json_binding, "modifiers");
json_object_object_add(json_binding, "symbols", symbols); json_object_get(modifiers);
json_object_object_add(json_binding, "symbol", symbol); json_object_object_del(json_binding, "modifiers");
json_object_object_add(json_binding, "event_state_mask", modifiers);
bool mouse = binding->type == BINDING_MOUSECODE ||
binding->type == BINDING_MOUSESYM;
json_object_object_add(json_binding, "input_type", mouse
? json_object_new_string("mouse")
: json_object_new_string("keyboard"));
json_object *json = json_object_new_object(); json_object *json = json_object_new_object();
json_object_object_add(json, "change", json_object_new_string("run")); json_object_object_add(json, "change", json_object_new_string("run"));
@ -876,16 +816,39 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
case IPC_GET_BINDING_MODES: case IPC_GET_BINDING_MODES:
{ {
json_object *modes = json_object_new_array(); if (!buf[0]) {
for (int i = 0; i < config->modes->length; i++) { json_object *modes = json_object_new_array();
struct sway_mode *mode = config->modes->items[i]; for (int i = 0; i < config->modes->length; i++) {
json_object_array_add(modes, json_object_new_string(mode->name)); struct sway_mode *mode = config->modes->items[i];
json_object_array_add(modes, json_object_new_string(mode->name));
}
const char *json_string = json_object_to_json_string(modes);
ipc_send_reply(client, payload_type, json_string,
(uint32_t)strlen(json_string));
json_object_put(modes); // free
goto exit_cleanup;
} else {
struct sway_mode *mode = NULL;
for (int i = 0; i < config->modes->length; i++) {
mode = config->modes->items[i];
if (strcmp(buf, mode->name) == 0) {
break;
}
mode = NULL;
}
if (!mode) {
const char *error = "{ \"success\": false, \"error\": \"No mode with that name\" }";
ipc_send_reply(client, payload_type, error,
(uint32_t)strlen(error));
goto exit_cleanup;
} else {
json_object *json_mode = ipc_json_describe_binding_mode(mode);
const char *json_string = json_object_to_json_string(json_mode);
ipc_send_reply(client, payload_type, json_string, (uint32_t)strlen(json_string));
json_object_put(json_mode);
goto exit_cleanup;
}
} }
const char *json_string = json_object_to_json_string(modes);
ipc_send_reply(client, payload_type, json_string,
(uint32_t)strlen(json_string));
json_object_put(modes); // free
goto exit_cleanup;
} }
case IPC_GET_BINDING_STATE: case IPC_GET_BINDING_STATE:

View File

@ -70,6 +70,7 @@
#define SWAY_XDG_SHELL_VERSION 5 #define SWAY_XDG_SHELL_VERSION 5
#define SWAY_LAYER_SHELL_VERSION 4 #define SWAY_LAYER_SHELL_VERSION 4
#define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1 #define SWAY_FOREIGN_TOPLEVEL_LIST_VERSION 1
#define SWAY_PRESENTATION_VERSION 2
bool allow_unsupported_gpu = false; bool allow_unsupported_gpu = false;
@ -327,7 +328,7 @@ bool server_init(struct sway_server *server) {
wl_signal_add(&server->pointer_constraints->events.new_constraint, wl_signal_add(&server->pointer_constraints->events.new_constraint,
&server->pointer_constraint); &server->pointer_constraint);
wlr_presentation_create(server->wl_display, server->backend); wlr_presentation_create(server->wl_display, server->backend, SWAY_PRESENTATION_VERSION);
wlr_alpha_modifier_v1_create(server->wl_display); wlr_alpha_modifier_v1_create(server->wl_display);
server->output_manager_v1 = server->output_manager_v1 =

View File

@ -1017,7 +1017,7 @@ An object containing the following properties:
} }
``` ```
## 8. GET_BINDING_MODES ## 8. GET_BINDING_MODES (WITHOUT A PAYLOAD)
*MESSAGE*++ *MESSAGE*++
Retrieve the list of binding modes that currently configured Retrieve the list of binding modes that currently configured
@ -1035,6 +1035,286 @@ default binding mode
] ]
``` ```
## 8. GET_BINDING_MODES (WITH A PAYLOAD)
*MESSAGE*++
When sent with a mode name as the payload, this retrieves the list of keybinds
configured for that mode.
*REPLY*++
An object that represents the configuration for the mode with the name sent as
the payload. It has the following properties:
[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
|- name
: string
:[ The mode name
|- bindings
: array
: The list of keybinds for the mode
The objects in the keybind list describe one keybind each, and have the
following properties:
[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
|- type
: string
:[ The type of this keybind.
|- command
: string
: The sway command that is configured to run for this binding.
|- flags
: array
: Flags describing special properties of this binding.
Bindings of type *keysym*, *keycode*, *mousesym*, and *mousecode* have these
properties:
[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
| modifiers
: array
:[ The modifier keys that are configured for this binding
|- input_codes
: array
: For code keybinds, the keycodes or mousecodes that are configured for this
binding
|- input_code
: integer
: The first value of input_codes, or 0 if it is empty. For i3 compatibility.
|- symbols
: array
: For symbol keybinds, the keysyms or mouse buttons that are configured for
this binding.
|- symbol
: string
: The first value of symbols, or null if it is empty. For i3 compatiblity.
|- input_type
: string
: Has the value *keyboard* or *mouse* if the binding is a keysym/keycode or
mousesym/mousecode binding respectively.
|- input_device
: string
: The input identifier of devices that may trigger this binding.
And bindings of type *lid* have these properties:
[- *PROPERTY*
:- *DATA TYPE*
:- *DESCRIPTION*
|- state
: string
:[ The lid state which triggers this bindings.
The *flags* property has these values
[- *FLAG*
:- *DESCRIPTION*
|- release
:[ The binding will run when the keycombo is released
|- locked
: The binding will run even if a screen locking program is active
|- border
: Mouse only. The binding will run when the cursor is over the window border.
|- contents
: Mouse only. The binding will run when the cursor is over the window content.
|- titlebar
: Mouse only. The binding will run when the cursor is over the window titlebar.
|- code
: The code binding was converted from a keysym.
|- reload
: Switch only. The binding will also execute on config reload.
|- inhibited
: The binding will ignore shortcut inhibitors.
|- norepeat
: The binding will not run when repeating a held key.
*Example Reply:*
```
{
"name": "resize",
"bindings": [
{
"command": "resize shrink width 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"h"
],
"symbol": "h",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize grow height 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"j"
],
"symbol": "j",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize shrink height 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"k"
],
"symbol": "k",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize grow width 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"l"
],
"symbol": "l",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize shrink width 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Left"
],
"symbol": "Left",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize grow height 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Down"
],
"symbol": "Down",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize shrink height 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Up"
],
"symbol": "Up",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "resize grow width 10px",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Right"
],
"symbol": "Right",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "mode \"default\"",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Return"
],
"symbol": "Return",
"input_type": "keyboard",
"input_device": "*"
},
{
"command": "mode \"default\"",
"modifiers": [
],
"flags": [
],
"type": "keysym",
"input_codes": [
],
"input_code": 0,
"symbols": [
"Escape"
],
"symbol": "Escape",
"input_type": "keyboard",
"input_device": "*"
}
]
}
```
## 9. GET_CONFIG ## 9. GET_CONFIG
*MESSAGE*++ *MESSAGE*++

View File

@ -349,7 +349,7 @@ void container_arrange_title_bar(struct sway_container *con) {
h_padding = width - config->titlebar_h_padding - marks_buffer_width; h_padding = width - config->titlebar_h_padding - marks_buffer_width;
} }
h_padding = MAX(h_padding, 0); h_padding = MAX(h_padding, config->titlebar_h_padding);
int alloc_width = MIN((int)node->width, int alloc_width = MIN((int)node->width,
width - h_padding - config->titlebar_h_padding); width - h_padding - config->titlebar_h_padding);
@ -375,7 +375,7 @@ void container_arrange_title_bar(struct sway_container *con) {
h_padding = config->titlebar_h_padding; h_padding = config->titlebar_h_padding;
} }
h_padding = MAX(h_padding, 0); h_padding = MAX(h_padding, config->titlebar_h_padding);
int alloc_width = MIN((int) node->width, int alloc_width = MIN((int) node->width,
width - h_padding - config->titlebar_h_padding); width - h_padding - config->titlebar_h_padding);