-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
ta/monitor ordering #919
ta/monitor ordering #919
Conversation
ThomasAdam
commented
Oct 23, 2023
- WIP
- WIP: Monitor ordering
d9c84d6
to
02613b8
Compare
The order only seems to be set at the initialization stage, if I run Now that I see what you are doing with this, I think my lexographic order approach would be worthwhile. If the monitors are all in the same line, you'll get the same result here, but there will also be a predictable order for other setups as well. (well I'm assuming in a line means the top coordinate is all the same, with different sized monitors lined up along the bottom, which I think is a very odd setup, it would be different). |
Hey @somiaj Yeah -- there's definitely some rough edges which I've yet to deal with, such as recreating the ordering should the layout change while FVWM is running. I completely agree about your lexicographical approach -- I'm just not too sure how best to implement it. |
@ThomasAdam point me to which part of the code assigns the order, I might be able to come up with something, should be just a simple sort, and since the number of monitors will always be small, a standard sort algorithm should do the trick. |
@ThomasAdam It seems like First you need a compare function, such as: int mon_compare(const void *m1, const void *m2)
{
const struct monitor *mon1 = m1;
const struct monitor *mon2 = m2;
if (mon1->si->y == mon2->si->y) {
return mon2->si->x - mon1->si->x;
} else {
return mon2->si->y - mon1->si->y;
}
} Then just put all of the monitors into an array, qsort(mon_array, number_of_monitors, sizeof(monitor), mon_compare); The array will be sorted, then just number the monitors based on their position in the array: for (int i = 0; i < number_of_monitors; i++) {
mon_array[i]->si->number = i;
} My c knowledge is still very basic, and just following examples, so I'm sure this will need to be adjusted. |
429d4f5
to
c26fdb0
Compare
c26fdb0
to
2a16531
Compare
My quick tests (with only two monitors) seem to show it works. I even tested my optimization suggestion and I get the exact same result. It still doesn't update the ordering on monitor changes, I have to restart fvwm to get the ordering to update. |
2a16531
to
d3f66a6
Compare
Really? I'm moving the ordering of screens around using xrandr, and they update just fine, without restarting fvwm. What am I missing? |
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.
Seems to work now!!
Sort the list of monitors which fvwm tracks in an ascending linear progression, from left-to-right. Currently, any monitors which are above or below will not to be tracked in this way. In doing so, it then becomes possible to use: $[monitor.0.name] Which would yield the name of the first monitor on the left. $[montor.1.name] Would be the monitor on the right of monitor 0, and so on. This therefore makes position geometries easier, as in: Style moo StartsOnScreen $[monitor.2.name] Regardless of whether the monitor ordering changes, or the same config is used across different monitors.
Store the list of monitors in a Red-black tree, rather than a TAILQ list. This should allow for better insertion sorting of the monitors in different configurations.
Tag each monitor with a number when inserting -- the idea being that monitor 0 -> n represents the ordering for each monitor.
When a RandR event occurs, ensure the monitor(s) affected are removed and reinserted into the tree so that their position changes also.
When looking up numbers from a string, use strtonum() (from BSD) rather than atoi() so that we can distinguish between errors.
Update the fvwm documentation to mention how RandR screens are arranged and detected. While here, remove mention that RandR is optional, it is now a core dependency.
1378ee1
to
1ecad54
Compare
When outputting JSON information, include the randr order number assigned to the specific monitor. This also bumps the version to 3.