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

Accelerator for "cycle to next monitor" #190

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jrdietrick
Copy link
Contributor

I was gazing longingly at https://github.com/lanoxx/tilda/tree/wip/monitornames. That branch is ambitious, and I would love to see it come all the way through at some point, but this is a simple solution that gets me 95% of the way there.

Between home and the office, I have at least three different multi-monitor workstations I plug into on a weekly basis, each with a different monitor type and physical geometry. Sometimes the external monitor is on the left (and thus is monitor #0), and sometimes it's on the right. Sometimes my terminal is front and center, and I want it on my tiny 1366x768 laptop display, and sometimes I want it on the secondary display. Etc.

All this adds up to a lot of diving into the wizard to jam the "Select monitor" combo box. So I wanted a keybinding to just move tilda to the next monitor.

As described in e5805e7, I made a call about how the window should be positioned on the destination monitor in the likely event that the workarea sizes are different. I think all three options (the implemented one, plus the two alternatives listed in that commit msg) are pretty reasonable, and would be happy to modify this patch to implement any of them.

@lanoxx
Copy link
Owner

lanoxx commented Oct 8, 2015

Hi,

thanks for your patches, I have no time to review them not but I will try to take a look during the weekend. Just one quick note: the gdk_screen_get_monitor_workarea function is kind of broken and only works for the primary screen. I have been pushing for a fix but that requires an extension of the EWMH specification, you may track that here and here.

@lanoxx
Copy link
Owner

lanoxx commented Oct 10, 2015

Those patches look good in general, but I have some issues with it.

First I don't agree with the <Primary>Right default hotkey, that is far too likely to be in use by other applications in which case we either end up with a broken hotkey or we block the hotkey for other applications. How about using <Super><Shift>Right, anything with super is usually not likely to be taken by some other application.

Second, In the first patch it you need to also change the size of the tilda window, look at combo_monitor_selection_changed_cb how I compare current_rectangle and last_rectangle and then resize the size. This is not prefect, because as I wrote in my last comment the gdk_screen_get_monitor_workarea function somethings reports wrong work area sizes, but in general this works. Without this you might be moving the tilda window from your desktop monitor to a smaller notebook monitor and then the size is way too big there.

Third, your code duplicates part of the code in combo_monitor_selection_changed_cb, please move that into a common function which is called from both callbacks, so we do not end up with duplicate code.

I am planning to release 1.3 soon (probably end of October), so if you want this to end up in 1.3 then please send me a rebased version with the the fixes soon.

@jrdietrick
Copy link
Contributor Author

Appreciate the review and feedback! Agreed on all counts. I'll work up a revised set of patches and get it back to you.

Thanks!

@lanoxx
Copy link
Owner

lanoxx commented Oct 11, 2015

Just a quick heads up, I pushed some commits from the wip/monitornames (but not all of them), so Tilda now makes use of the monitor name instead of the monitor number, please consider that when you rebase your patches

@jrdietrick
Copy link
Contributor Author

Awesome! Will rework on top of those, hopefully within the next day or two. Thanks.

Notes / loose ends:

* I went from an original approach of setting the relative x and y coordinates
to (0, 0) after cycling to the next monitor, to instead preserving the relative
x and y against the newly-selected display. In both cases not messing with the
size. This might not be the *best* approach -- some other possibilities I can
think of would be (1) a "proportional transposition", or (2) just setting the
position and/or size to arbitrary, consistent values (like filling the entire
workspace on the new monitor). I spend almost all my time in fullscreen mode,
however, so I am neither affected by nor the best judge of this use case.

* No effort is made to update the wizard UI if we cycle monitors while the
wizard is open. (It looks like we aren't supposed to be able to trigger hotkeys
while the wizard is open, but I was able to get it to work by changing focus.)
This decicison is based on the precedent set by other hotkeys such as "enable
fullscreen".

* What would an integration with the wip/monitornames branch look like? Or,
that branch, done right and completely, probably supersedes us.
Sometimes -- usually if a monitor is hotplugged or the multiple-monitor
geometry is changed -- the prevailing (x_pos, y_pos) in the absolute
coordinate space do not agree with show_on_monitor_number. We now add some
additional logic to trust show_on_monitor_number above all; if the newly-
calculated absolute (x, y) that we get from trying to retain relative
position on our new monitor places the window outside the workarea of the
destination monitor, we drop the hammer and set x and/or y to 0 as needed.

This means, for example, if you have a Dell monitor on your left (as monitor
0) and an LG monitor on your right (as monitor 1), and have tilda on monitor
0 (the Dell), but then change your virtual monitor configuration such that the
LG is to the left of the Dell, tilda will go from being on monitor 0 to monitor
1, but without updating its configuration values. And your absolute coordinates
might be messed up, too. With this patch, next time you cycle the monitors,
you'll land tilda on the Dell (where it already is!), but after that, things
will operate normally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants