Skip to content

Commit

Permalink
Merge branch 'master' into fix-cursor-events
Browse files Browse the repository at this point in the history
  • Loading branch information
OkamiW authored Nov 22, 2024
2 parents 6cd51ff + 5312376 commit 199e59e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions include/sway/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ struct output_config *find_output_config(struct sway_output *output);
void free_output_config(struct output_config *oc);

void request_modeset(void);
void force_modeset(void);
bool modeset_is_pending(void);

bool spawn_swaybg(void);

Expand Down
6 changes: 3 additions & 3 deletions sway/commands/include.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

struct cmd_results *cmd_include(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "include", EXPECTED_EQUAL_TO, 1))) {
if ((error = checkarg(argc, "include", EXPECTED_AT_LEAST, 1))) {
return error;
}

char *files = join_args(argv, argc);
// We don't care if the included config(s) fails to load.
load_include_configs(argv[0], config, &config->swaynag_config_errors);
load_include_configs(files, config, &config->swaynag_config_errors);

return cmd_results_new(CMD_SUCCESS, NULL);
}
21 changes: 16 additions & 5 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ void request_modeset(void) {
}
}

bool modeset_is_pending(void) {
return server.delayed_modeset != NULL;
}

void force_modeset(void) {
if (server.delayed_modeset != NULL) {
wl_event_source_remove(server.delayed_modeset);
server.delayed_modeset = NULL;
}
apply_stored_output_configs();
}

static void begin_destroy(struct sway_output *output) {
if (output->enabled) {
output_disable(output);
Expand All @@ -428,6 +440,9 @@ static void begin_destroy(struct sway_output *output) {
output->wlr_output->data = NULL;
output->wlr_output = NULL;

wl_event_source_remove(output->repaint_timer);
output->repaint_timer = NULL;

request_modeset();
}

Expand Down Expand Up @@ -493,12 +508,8 @@ static void handle_request_state(struct wl_listener *listener, void *data) {
// 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;
}
force_modeset();
}

static unsigned int last_headless_num = 0;
Expand Down
6 changes: 6 additions & 0 deletions sway/ipc-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ void ipc_client_handle_command(struct ipc_client *client, uint32_t payload_lengt
}

list_t *res_list = execute_command(buf, NULL, NULL);
if (modeset_is_pending()) {
// IPC expects commands to have taken immediate effect, so we need
// to force a modeset after output commands. We do a single modeset
// here to avoid modesetting for every output command in sequence.
force_modeset();
}
transaction_commit_dirty();
char *json = cmd_results_to_json(res_list);
int length = strlen(json);
Expand Down
1 change: 1 addition & 0 deletions sway/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ int main(int argc, char **argv) {
}

config->active = true;
force_modeset();
load_swaybars();
run_deferred_commands();
run_deferred_bindings();
Expand Down
4 changes: 2 additions & 2 deletions sway/sway.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ The following commands may only be used in the configuration file.
*default_orientation* horizontal|vertical|auto
Sets the default container layout for tiled containers.

*include* <path>
Includes another file from _path_. _path_ can be either a full path or a
*include* <paths...>
Include files from _paths_. _paths_ can include either a full path or a
path relative to the parent config, and expands shell syntax (see
*wordexp*(3) for details). The same include file can only be included once;
subsequent attempts will be ignored.
Expand Down
1 change: 0 additions & 1 deletion sway/tree/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void output_destroy(struct sway_output *output) {
destroy_scene_layers(output);
list_free(output->workspaces);
list_free(output->current.workspaces);
wl_event_source_remove(output->repaint_timer);
wlr_color_transform_unref(output->color_transform);
free(output);
}
Expand Down

0 comments on commit 199e59e

Please sign in to comment.