gerritdevriese / kzones

KDE KWin Script for snapping windows into zones
https://store.kde.org/p/1909220
GNU General Public License v3.0
240 stars 14 forks source link

Overlapping zone indicator behavior #1

Closed gabrielfern closed 1 year ago

gabrielfern commented 1 year ago

First of all, I'd like to congratulate you, very nice work!

Now to the problem, I must say, it's a bit niche though.

If someone has the center of zones overlapping, like in the zone example below:

[
    {
        "name": "Layout 2",
        "padding": 0,
        "zones": [
            {
                "name": "1",
                "x": 0,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "name": "2",
                "x": 25,
                "y": 0,
                "height": 100,
                "width": 50
            },
            {
                "name": "3",
                "x": 15,
                "y": 10,
                "height": 80,
                "width": 70
            },
            {
                "name": "4",
                "x": 75,
                "y": 0,
                "height": 100,
                "width": 25
            }
        ]
    }
]

You can see zones 2 and 3 have the zone indicator in the exact same place (center of the screen). Using shortcuts it's perfectly fine to move a window to zones 2 and 3. But when dragging a window, the zone that seems to take precedence is zone 2. And when using the OSD functionality (ctrl+alt+c), clicking in the center seems to activate zone 3 instead.

In summary, the problem is just the inconsistency of the two alternatives to move a window to the zone that's overlapped with another. I think it would be awesome if the two activation alternatives would have the same behavior (or giving precedence to the first zone in the array that's overlapping, or to the last).

Another more fancy way to solve this issue would be to support moving zone indicators outside the middle of the zone. So, for overlapping zones, one could have the indicator slightly above, while the other could have it below.

Once again, nice work, and thank you!

gerritdevriese commented 1 year ago

Hi, thanks, that is indeed a very interesting use case I hadn't thought about yet. Moving the indicator seems like the best way to deal with this problem.

I added the option to offset zone indicators from within the layouts json.

As an example, the following layout will move the indicators to be above each other:

[
    {
        "name": "Layout 2",
        "padding": 0,
        "zones": [
            {
                "name": "1",
                "x": 0,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "name": "2",
                "x": 25,
                "y": 0,
                "height": 100,
                "width": 50,
                "indicator": {
                    "offset": {
                        "y": -50
                    }
                }
            },
            {
                "name": "3",
                "x": 15,
                "y": 10,
                "height": 80,
                "width": 70,
                "indicator": {
                    "offset": {
                        "y": 50
                    }
                }
            },
            {
                "name": "4",
                "x": 75,
                "y": 0,
                "height": 100,
                "width": 25
            }
        ]
    }
]

Are you able to build the script and test it?

gabrielfern commented 1 year ago

Yes, I tested it, working flawlessly. And we can move it on the x or y axis, awesome!

As a suggestion, these added properties could be mentioned in the readme.

Thank you for the quick solution!