Skip to content
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

Merged
merged 16 commits into from
Dec 14, 2017
Merged

Add output config #1503

merged 16 commits into from
Dec 14, 2017

Conversation

emersion
Copy link
Member

@emersion emersion commented Dec 6, 2017

  • Merge new output config params
  • Init new output config params
  • wlr_output_layout_add

Test plan:

  • Configure each property (resolution, refresh rate, position, scale, transform)
  • Test hotplugging
  • Test IPC

@emersion emersion changed the title Add output config [WIP] Add output config Dec 6, 2017
@emersion emersion changed the title [WIP] Add output config Add output config Dec 6, 2017
}
}
if (!best) {
sway_log(L_ERROR, "Configured mode for %s not available", output->name);
Copy link

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


void merge_output_config(struct output_config *dst, struct output_config *src) {
if (src->name) {
if (dst->name) {
Copy link

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.

@@ -23,6 +25,30 @@ void swayc_descendants_of_type(swayc_t *root, enum swayc_types type,
}
}

static void update_root_geometry() {
Copy link

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).

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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

event from what?

Copy link
Contributor

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.

}
const char *name = argv[0];

struct output_config *output = calloc(1, sizeof(struct output_config));
Copy link

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().

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
Copy link

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) {
Copy link

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?

@acrisci
Copy link

acrisci commented Dec 6, 2017

Code looks ok, will test it in a few hours. Can you provide an example config snippet?

@emersion
Copy link
Member Author

emersion commented Dec 9, 2017

Example config:

output WL-1 pos 10,10 transform 90 scale 2

Try changing these at runtime.

@@ -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() {
Copy link

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.

@@ -6,6 +6,7 @@
#include <libinput.h>
#include <stdint.h>
#include <string.h>
#include <wayland-server.h>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?


struct output_config *output = new_output_config();
if (!output) {
return cmd_results_new(CMD_FAILURE, "output", "Unable to allocate output config");
Copy link

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.

@acrisci
Copy link

acrisci commented Dec 11, 2017

Instead of this update_root_geometry() madness, why not listen for the change event of the output layout and update the root geometry then?

output->x = output_layout_box->x;
output->y = output_layout_box->y;
output->width = output_layout_box->width;
output->height = output_layout_box->height;
Copy link

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;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Copy link
Member Author

@emersion emersion Dec 12, 2017

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).

@acrisci
Copy link

acrisci commented Dec 11, 2017

output_add_notify() needs to handle the case where the new output is disabled.

@emersion
Copy link
Member Author

output_add_notify() needs to handle the case where the new output is disabled.

This is already the case, but this is handled in apply_output_config.

arrange_windows(soutput->swayc, -1, -1);
}

static void output_transform_notify(struct wl_listener *listener, void *data) {
Copy link

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?

@ddevault
Copy link
Contributor

Initial feedback

  • Xwayland crashes on changes
  • I would prefer to replace refresh_rate/resolution with a single mode command: WIDTHxHEIGHT@RATE, and have res just be an alias for mode

@emersion
Copy link
Member Author

Xwayland crashes on changes

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 CloseInput.

}
output->name = strdup(name);

// TODO: atoi doesn't handle invalid numbers
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}
sort_workspaces(root_container.children->items[p]);
// TODO WLR: is this needed anymore?
//update_visibility(root_container.children->items[p]);
Copy link
Contributor

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.
Copy link
Contributor

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

@ddevault
Copy link
Contributor

LGTM 👍

@ddevault ddevault merged commit 1aab9ae into swaywm:wlroots Dec 14, 2017
@ddevault
Copy link
Contributor

Thanks!

@emersion emersion deleted the output-config branch July 23, 2018 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants