-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add output config #1503
Add output config #1503
Conversation
5b7531c
to
aaae590
Compare
} | ||
} | ||
if (!best) { | ||
sway_log(L_ERROR, "Configured mode for %s not available", output->name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no mode is ever set, the drm backend won't ever start up and (I think) the user loses the ability to switch VT so this is a pretty hard crash for a single monitor setup.
The obvious solution is to just set the default mode, but that's a silent error if you don't know to check the logs.
This is an excellent use case for system notifications but we don't have those yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already done here: https://github.com/swaywm/sway/blob/wlroots/sway/desktop/output.c#L111
sway/config/output.c
Outdated
|
||
void merge_output_config(struct output_config *dst, struct output_config *src) { | ||
if (src->name) { | ||
if (dst->name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this guard, just free.
sway/tree/container.c
Outdated
@@ -23,6 +25,30 @@ void swayc_descendants_of_type(swayc_t *root, enum swayc_types type, | |||
} | |||
} | |||
|
|||
static void update_root_geometry() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get output layout extents with wlr_output_layout_get_box(layout, NULL)
.
sway/commands/output.c
Outdated
if (output->name) { | ||
// Try to find the output container and apply configuration now. If | ||
// this is during startup then there will be no container and config | ||
// will be applied during normal "new output" event from wlc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
event from what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't just copy+paste more than a few lines at a time, @emersion - make sure you read everything you import.
sway/commands/output.c
Outdated
} | ||
const char *name = argv[0]; | ||
|
||
struct output_config *output = calloc(1, sizeof(struct output_config)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be simpler to just have a create func here rather than exposing output_config_defaults()
.
sway/tree/container.c
Outdated
if (output->children->length > 0) { | ||
// TODO save workspaces when there are no outputs. | ||
// TODO also check if there will ever be no outputs except for exiting | ||
// program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if there are no outputs, sway should exit.
@@ -139,6 +167,34 @@ static void free_swayc(swayc_t *cont) { | |||
free(cont); | |||
} | |||
|
|||
swayc_t *destroy_output(swayc_t *output) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to explicitly take it out of the output layout?
Code looks ok, will test it in a few hours. Can you provide an example config snippet? |
616d49e
to
4a14aa9
Compare
Example config:
Try changing these at runtime. |
sway/config/output.c
Outdated
@@ -14,13 +14,18 @@ int output_name_cmp(const void *item, const void *data) { | |||
return strcmp(output->name, name); | |||
} | |||
|
|||
void output_config_defaults(struct output_config *oc) { | |||
struct output_config *new_output_config() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to standardize our create function names.
include/sway/config.h
Outdated
@@ -6,6 +6,7 @@ | |||
#include <libinput.h> | |||
#include <stdint.h> | |||
#include <string.h> | |||
#include <wayland-server.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?
sway/commands/output.c
Outdated
|
||
struct output_config *output = new_output_config(); | ||
if (!output) { | ||
return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're out of memory, this is probably going to fail too.
Instead of this |
sway/config/output.c
Outdated
output->x = output_layout_box->x; | ||
output->y = output_layout_box->y; | ||
output->width = output_layout_box->width; | ||
output->height = output_layout_box->height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output container could listen to the output layout change event and automatically keep these in sync.
} | ||
} | ||
|
||
int output_i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used yet, but will be when we'll implement background (see commented code below).
|
This is already the case, but this is handled in |
sway/desktop/output.c
Outdated
arrange_windows(soutput->swayc, -1, -1); | ||
} | ||
|
||
static void output_transform_notify(struct wl_listener *listener, void *data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered not listening to scale/transform/resolution but only output layout changes for determining when to rearrange the windows?
Initial feedback
|
05cdce0
to
9254c5a
Compare
I don't believe this is due to invalid code. I added some code in rootston that changes the output scale on click and Xwayland doesn't crash. I think it's related to having no seat. Plus, the segfault happens in |
sway/commands/output.c
Outdated
} | ||
output->name = strdup(name); | ||
|
||
// TODO: atoi doesn't handle invalid numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we resolve this now?
|
||
if (wl_list_length(&wlr_output->modes) > 0) { | ||
struct wlr_output_mode *mode = NULL; | ||
mode = wl_container_of((&wlr_output->modes)->prev, mode, link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
sway/tree/container.c
Outdated
} | ||
sort_workspaces(root_container.children->items[p]); | ||
// TODO WLR: is this needed anymore? | ||
//update_visibility(root_container.children->items[p]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, pull it out
} | ||
|
||
if (output->children->length > 0) { | ||
// TODO save workspaces when there are no outputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self, put these in the wlroots ticket
LGTM 👍 |
Thanks! |
Test plan: