Merge pull request #72 from Stivvo/output-compile-set

Define monitor's x,y at compile time
main
Devin J. Pohly 2021-01-06 16:44:31 -05:00 committed by GitHub
commit 4bf2923f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 17 deletions

View File

@ -28,12 +28,14 @@ static const Layout layouts[] = {
* The order in which monitors are defined determines their position. * The order in which monitors are defined determines their position.
* Non-configured monitors are always added to the left. */ * Non-configured monitors are always added to the left. */
static const MonitorRule monrules[] = { static const MonitorRule monrules[] = {
/* name mfact nmaster scale layout rotate/reflect */ /* name mfact nmaster scale layout rotate/reflect x y */
/* example of a HiDPI laptop monitor: /* example of a HiDPI laptop monitor:
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, { "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 },
*/ */
/* the order in which monitors are defined here affects the order in which
* focusmon and tagmon cycle trough the monitors */
/* defaults */ /* defaults */
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL }, { NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, 0, 0 },
}; };
/* keyboard */ /* keyboard */

21
dwl.c
View File

@ -186,6 +186,8 @@ typedef struct {
float scale; float scale;
const Layout *lt; const Layout *lt;
enum wl_output_transform rr; enum wl_output_transform rr;
int x;
int y;
} MonitorRule; } MonitorRule;
typedef struct { typedef struct {
@ -814,11 +816,9 @@ createmon(struct wl_listener *listener, void *data)
/* This event is raised by the backend when a new output (aka a display or /* This event is raised by the backend when a new output (aka a display or
* monitor) becomes available. */ * monitor) becomes available. */
struct wlr_output *wlr_output = data; struct wlr_output *wlr_output = data;
Monitor *m;
const MonitorRule *r; const MonitorRule *r;
size_t nlayers; size_t nlayers;
Monitor *moni, *insertmon = NULL; Monitor *m, *moni, *insertmon = NULL;
int x = 0;
/* The mode is a tuple of (width, height, refresh rate), and each /* The mode is a tuple of (width, height, refresh rate), and each
* monitor supports only a specific set of modes. We just pick the * monitor supports only a specific set of modes. We just pick the
@ -851,12 +851,11 @@ createmon(struct wl_listener *listener, void *data)
wl_list_for_each(moni, &mons, link) wl_list_for_each(moni, &mons, link)
if (m->position > moni->position) if (m->position > moni->position)
insertmon = moni; insertmon = moni;
if (insertmon) {
x = insertmon->w.x + insertmon->w.width; if (insertmon) /* insertmon is the leftmost monitor to m */
wl_list_insert(&insertmon->link, &m->link); wl_list_insert(&insertmon->link, &m->link);
} else { else
wl_list_insert(&mons, &m->link); wl_list_insert(&mons, &m->link);
}
wlr_output_enable(wlr_output, 1); wlr_output_enable(wlr_output, 1);
if (!wlr_output_commit(wlr_output)) if (!wlr_output_commit(wlr_output))
@ -868,13 +867,7 @@ createmon(struct wl_listener *listener, void *data)
* display, which Wayland clients can see to find out information about the * display, which Wayland clients can see to find out information about the
* output (such as DPI, scale factor, manufacturer, etc). * output (such as DPI, scale factor, manufacturer, etc).
*/ */
wlr_output_layout_add(output_layout, wlr_output, x, 0); wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);
wl_list_for_each_reverse(moni, &mons, link) {
/* All monitors to the right of the new one must be moved */
if (moni == m)
break;
wlr_output_layout_move(output_layout, moni->wlr_output, moni->w.x + m->wlr_output->width, 0);
}
sgeom = *wlr_output_layout_get_box(output_layout, NULL); sgeom = *wlr_output_layout_get_box(output_layout, NULL);
nlayers = LENGTH(m->layers); nlayers = LENGTH(m->layers);