ssokolow / quicktile

Adds window-tiling hotkeys to any X11 desktop. (An analogue to WinSplit Revolution for people who don't want to use Compiz Grid)
https://ssokolow.com/quicktile/
GNU General Public License v2.0
861 stars 78 forks source link

Quicktile ignores left or right panels that do not cover full height, resulting in window/window or window/panel overlap. Fix provided. #64

Closed fidergo-stephane-gourichon closed 4 years ago

fidergo-stephane-gourichon commented 8 years ago

Hi, on Xubuntu 16.04, environment XFCE, panel does not seem to be taken into account in computing window size. The code (current commit 5800b84) shows that you made efforts to trim regions based on struts.

More specifically, there is a two-screen setup : 1920x1080 main screen plus 2560x1440 screen on the right. There is a panel, 25 pixels wide, on the right of the rightmost screen. Current code fails to account for it.

Observed: code computes width that are e.g. 2560 or 1280

Expected: code computes width that are 2560-25=2535 or half of it (that would be 1267 or 1268).

As a result, window manager either keeps them aside from the panel and they overlap, or let them and they get under the panel.

fidergo-stephane-gourichon commented 8 years ago

Here's a raw log. The computed width should not be 1280 but something like 1267 or 1268.

DEBUG: Received keybind: <Primary><Alt><Mod2>KP_Home
DEBUG: Executing command 'top-left' with arguments (), {}
DEBUG: Operating on window 0x54200fa with title "Terminal - [free_software_involvement]stephane@n551jk: /org/gourichon/n551j901G/SG/projects/free_software_involvement/2016/2016-03-16/quicktile" and geometry (1920, 0, 1705, 712)
DEBUG:  Window is on monitor 1, which has geometry gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Gathered _NET_WM_STRUT_PARTIAL values:
    [[0, 25, 0, 0, 0, 0, 198, 1240, 0, 0, 0, 0]]
DEBUG: Usable region of monitor calculated as:
    Region: [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)]
    Rectangle: gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Selected preset sequence:
    ((0.0, 0.0, 0.5, 0.5), (0.0, 0.0, 0.3333333333333333, 0.5), (0.0, 0.0, 0.6666666666666666, 0.5))
DEBUG: Selected preset sequence resolves to these monitor-relative pixel dimensions:
    [[0, 0, 1280, 720], [0, 0, 853, 720], [0, 0, 1706, 720]]
DEBUG: Target preset is gtk.gdk.Rectangle(0, 0, 1280, 720) relative to monitor gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Calling reposition() with default gravity and dimensions (1920, 0, 1280, 720)
DEBUG:  Window is on monitor 1, which has geometry gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG:  Repositioning to (1920, 0, 1280, 720)
fidergo-stephane-gourichon commented 8 years ago

Adding more debug lines in the code shows where the problem is: gdk_screen reports dimensions for the full desktop, not the correct 2560x1440 for the right screen.

DEBUG: Received keybind: <Primary><Alt><Mod2>KP_Page_Up
DEBUG: Executing command 'top-right' with arguments (), {}
DEBUG: Operating on window 0x54200fa with title "Terminal - [free_software_involvement]stephane@n551jk: /org/gourichon/n551j901G/SG/projects/free_software_involvement/2016/2016-03-16/quicktile" and geometry (2750, 0, 1705, 712)
DEBUG:  Window is on monitor 1, which has geometry gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Using directly monitor as usable_rect gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Gathered _NET_WM_STRUT_PARTIAL values:
    [[0, 25, 0, 0, 0, 0, 198, 1240, 0, 0, 0, 0]]
DEBUG: Screen width,height is 4480,1440
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 1440)] the rectangle (0, 0, 0, 1)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 1440)] the rectangle (4455, 198, 25, 1043)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)] the rectangle (0, 0, 1, 0)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)] the rectangle (0, 1440, 1, 0)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)] the rectangle (0, 0, 0, 1440)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)] the rectangle (4455, 198, 25, 1440)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1242)] the rectangle (0, 0, 4480, 0)
DEBUG: Substracting from region [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1242)] the rectangle (0, 1440, 4480, 0)
DEBUG: Usable region of monitor calculated as:
    Region: [gtk.gdk.Rectangle(1920, 0, 2560, 198), gtk.gdk.Rectangle(1920, 198, 2535, 1043), gtk.gdk.Rectangle(1920, 1241, 2560, 199)]
    Rectangle: gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Selected preset sequence:
    ((0.5, 0.0, 0.5, 0.5), (0.6666666666666667, 0.0, 0.3333333333333333, 0.5), (0.33333333333333337, 0.0, 0.6666666666666666, 0.5))
DEBUG: Selected preset sequence resolves to these monitor-relative pixel dimensions:
    [[1280, 0, 1280, 720], [1706, 0, 853, 720], [853, 0, 1706, 720]]
DEBUG: Target preset is gtk.gdk.Rectangle(1280, 0, 1280, 720) relative to monitor gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Result exceeds usable (non-rectangular) region of desktop. (overlapped a non-fullwidth panel?) Reducing to within largest usable rectangle: gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG: Calling reposition() with default gravity and dimensions (3200, 0, 1280, 720)
DEBUG:  Window is on monitor 1, which has geometry gtk.gdk.Rectangle(1920, 0, 2560, 1440)
DEBUG:  Repositioning to (3200, 0, 1280, 720)
fidergo-stephane-gourichon commented 8 years ago

Correct observation, wrong deduction. Screen width 4480 is probably correct.

I found where the bug is. Preparing pull request.

fidergo-stephane-gourichon commented 8 years ago

Fixes for me. Created pull request #65.

ssokolow commented 8 years ago

Thanks. At the moment, I'm very busy with my degree project, but I'll try to make time to review this as soon as possible.

fidergo-stephane-gourichon commented 6 years ago

Bug not reproduced on current master (commit 06c4b036ba12bd40a07bf01bdeff340432be8108). Behavior looks very much like the one I obtained with my patch #65. You did not merge it, I guess you somehow rewrote/picked from it? Thanks anyway. I guess you can close this issue. :-)

ssokolow commented 6 years ago

I did do some refactoring, but I don't think I got around to touching the code which would be responsible for that.

It's more likely that something changed on your desktop or there was a bug in either libwnck, your window manager, or how they interact, and that got fixed. I'm going to leave this and #65 open until I have time to set up some VMs in VirtualBox to try to reproduce this so I can write a regression test.

fidergo-stephane-gourichon commented 6 years ago

In a strict analysis, you're totally right. Old quicktile showed bug on Ubuntu 16.04, new quicktile does not show bug on Ubuntu 18.04. Comparing with two changed parameters at once (quicktile and distro) doesn't strictly prove anything. My commit 22264b93a203148fc9c3890fbb25769d7a96d4f7 made sense from the experimental values I got on Ubuntu 16.04. Perhaps it's not needed at all on Ubuntu 18.04. One would have to either test old quicktile on Ubuntu 18.04, or new quicktile on Ubuntu 16.04. Thank you for your attention.

fidergo-stephane-gourichon commented 6 years ago

Facts confirm your analysis. Current master 06c4b036ba12bd40a07bf01bdeff340432be8108 on Ubuntu 18.04 has correct behavior. Same commit on Ubuntu 16.04 has bug. What is observed is: my patch #65 is necessary to fix bug on Ubuntu 16.04, not necessary on Ubuntu 18.04. (Haven't tried with my patch on 18.04.)

ssokolow commented 4 years ago

Given the complete rewrite of panel handling that is still ongoing in the GTK 3 port, I'm going to mention this and #65 in #108 and close this, so I can track progress there.