diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2021-01-06 16:44:31 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-06 16:44:31 -0500 | 
| commit | 4bf2923f4ec7d3dadc5a36928f8e98d9734b207d (patch) | |
| tree | 8580be7629a690974ec74372a469361cb46973d1 | |
| parent | 0ff13cf216056a36a261f4eed53c6a864989a9fb (diff) | |
| parent | fa782896f874cd3398940e71c6adbde411343483 (diff) | |
Merge pull request #72 from Stivvo/output-compile-set
Define monitor's x,y at compile time
| -rw-r--r-- | config.def.h | 8 | ||||
| -rw-r--r-- | dwl.c | 21 | 
2 files changed, 12 insertions, 17 deletions
| diff --git a/config.def.h b/config.def.h index 8c1f5ba..982c870 100644 --- a/config.def.h +++ b/config.def.h @@ -28,12 +28,14 @@ static const Layout layouts[] = {   * The order in which monitors are defined determines their position.   * Non-configured monitors are always added to the left. */  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: -	{ "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 */ -	{ 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 */ @@ -186,6 +186,8 @@ typedef struct {  	float scale;  	const Layout *lt;  	enum wl_output_transform rr; +	int x; +	int y;  } MonitorRule;  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  	 * monitor) becomes available. */  	struct wlr_output *wlr_output = data; -	Monitor *m;  	const MonitorRule *r;  	size_t nlayers; -	Monitor *moni, *insertmon = NULL; -	int x = 0; +	Monitor *m, *moni, *insertmon = NULL;  	/* The mode is a tuple of (width, height, refresh rate), and each  	 * 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)  		if (m->position > moni->position)  			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); -	} else { +	else  		wl_list_insert(&mons, &m->link); -	}  	wlr_output_enable(wlr_output, 1);  	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  	 * output (such as DPI, scale factor, manufacturer, etc).  	 */ -	wlr_output_layout_add(output_layout, wlr_output, x, 0); -	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); -	} +	wlr_output_layout_add(output_layout, wlr_output, r->x, r->y);  	sgeom = *wlr_output_layout_get_box(output_layout, NULL);  	nlayers = LENGTH(m->layers); | 
