-
Notifications
You must be signed in to change notification settings - Fork 191
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
Skip mirrored outputs #247
Conversation
Thanks for the patch. One small question, is the output with num_clones > 0 the "real" one or the cloned one? In other words, if the user has the same output cloned two times will this patch skip the two clones? |
I found it pretty much impossible to find documentation for this, so I attached two mirrors to my laptop and patched eDP-1 is my primary, DP-1 and DP2 are set up as
(The hacky patch, just in case it matters) diff --git a/lemonbar.c b/lemonbar.c
index 528c2f0..840cc6f 100644
--- a/lemonbar.c
+++ b/lemonbar.c
@@ -995,7 +995,7 @@ get_randr_monitors (void)
// Output disconnected, not attached to any CRTC or mirrored ?
if (!oi_reply || oi_reply->crtc == XCB_NONE || oi_reply->connection != XCB_RANDR_CONNECTION_CONNECTED
- || oi_reply->num_clones > 0) {
+ || oi_reply->num_clones > 2) {
free(oi_reply);
continue;
}
@@ -1011,6 +1011,7 @@ get_randr_monitors (void)
int name_len = xcb_randr_get_output_info_name_length(oi_reply);
uint8_t *name_ptr = xcb_randr_get_output_info_name(oi_reply);
+ printf("OUTPUT %d CLONES: %d NAME: %s\n", i, oi_reply->num_clones, name_ptr);
bool is_valid = true; |
:( Okay so please hold off on reviewing this. It looks like my understanding of |
I looked at what other software does and realized we'd need to check for overlapping rectangles in the outputs, and I thought I'd seen similar code in There was a check which doesn't run this when With this verbose patch diff --git a/lemonbar.c b/lemonbar.c
index 83d9677..28b598f 100644
--- a/lemonbar.c
+++ b/lemonbar.c
@@ -1055,9 +1055,11 @@ get_randr_monitors (void)
// Does I contain J ?
if (i != j && mons[j].width) {
+ printf("Checking %s for overlapping.\n", mons[j].name);
if (mons[j].x >= mons[i].x && mons[j].x + mons[j].width <= mons[i].x + mons[i].width &&
mons[j].y >= mons[i].y && mons[j].y + mons[j].height <= mons[i].y + mons[i].height) {
mons[j].width = 0;
+ printf("Match! Removing %s for overlapping.\n", mons[j].name);
valid--;
}
}
Thanks for your patience with this, sorry the original version of this PR was spurious. |
That's valid for everything about XCB heh
Oh well, I guess (that code was written quite a while ago) the old logic was meant to skip the deduplication logic if the user specifies a set of monitors to cover. But I don't think that's desirable, I cannot come up with a reason to keep that logic. Thanks for the investigation, let's merge this and see if anybody complains :D |
I think that #241 reports an issue that I'm also seeing: if I start
lemonbar
after I have a second monitor connected as a mirror, I get two bars, but they are both docked to the bottom of the same screen, and the blank one covers the real one.I've tested this commit and it seems to fix this behavior.
(I'm a big fan of
lemonbar
, thanks for writing it!)