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

shift modifier to select multiple zones #43

Open
imthenachoman opened this issue Jul 19, 2023 · 10 comments
Open

shift modifier to select multiple zones #43

imthenachoman opened this issue Jul 19, 2023 · 10 comments

Comments

@imthenachoman
Copy link

Once we define zones, a window can only be dropped into a specific zone.

It would be nice if, while dragging a window around, you can press shift or ctrl or something to select multiple zones.

For example, you drag to one zone, then press shift/ctrl and drag to another zone and let go. Then the window would drop to a new "meta zone".

I can give more examples if needed.

@gerritdevriese
Copy link
Owner

As we don't have modifiers (yet), maybe it's an idea to add a small "hitbox" between zones, so when you hover over it, it automatically picks the two neighboring zones to snap into?

Something like this:
image

@jbtrystram
Copy link

As we don't have modifiers (yet), maybe it's an idea to add a small "hitbox" between zones, so when you hover over it, it automatically picks the two neighboring zones to snap into?

I think the modifier key would be more intuitive to use

@jbtrystram
Copy link

I think this feature would be an awesome addition. I started looking at the code, to see if I could contribute that.
I've never wrote any kwin scripts before, so bear with me :)

I'm writing my thought process here, in case @gerritdevriese want to give some feedback.

From what I understand, the script is designed this way (in a nutshell):

  • when moving a client, look at the client position and determine what zone it is hovering . Set the result to highlightedZone
  • When the client stop moving, set its geometry to match highlightedZone

So a way to make that work would be something like :

  • Have an highlightedZone be an array
  • If $modifierKey is pressed, when the hovered zone search concludes, append the result to the array. If not, overwrite the array.
  • when the client stops moving, compute the size of the sum of the highlighted zones and set the geometry to match accordingly.

I'll give this a go and see how this ends up :)

@gerritdevriese
Copy link
Owner

I am also in favor of modifier keys instead of hitboxes, but at that time I hadn't found a good way to handle key presses using the KWin API. Maybe it's possible now, but haven't looked in to it recently.

@jbtrystram You can definitely try to tackle this if you want, your thought process looks alright.

@irasponsible
Copy link

irasponsible commented Feb 20, 2024

As a short-term alternative to do something similar, for anyone like me who might be looking, you can make overlapping zones. Only works consistently if you have the snapping set to only when over the icon.

{
"name": "Multiple Offsets",
"padding": 0,
"zones": [
        {
            "x": 0,
            "y": 0,
            "height": 100,
            "width": 30
        },
        {
            "x": 0,
            "y": 0,
            "height": 100,
            "width": 70
        },
        {
            "x": 30,
            "y": 0,
            "height": 100,
            "width": 70
        },
        {
            "x": 70,
            "y": 0,
            "height": 100,
            "width": 30
        }
        ]
}

@fynzhak
Copy link
Contributor

fynzhak commented Apr 16, 2024

@irasponsible , that's a brilliant idea! I've implemented it for myself and it's working quite well.
Unfortunately, the rendering of the zones shows all the overlaps, so it looks bad. I hacked together something that only renders the target zone and it looks pretty good that way.
zonetargets

@gerritdevriese , is this something you'd be interested in supporting? It is kind of a weird scenario and I'm not sure of the best way to handle it. An option to only render the target zone? It is a slight improvement at least for my layout, but I'm debating if it's worth the extra complexity in general.

@SinanAkkoyun
Copy link

https://github.dev/SinanAkkoyun/kde-kzones/tree/clean-overlapping-zones
https://github.dev/SinanAkkoyun/kde-kzones/tree/clean-overlapping-zones-plasma-5

For everyone that wants the quick hack that @fynzhak showed (I just changed 2 lines of code, there is no option to disable the change)

@SinanAkkoyun
Copy link

{
        "name": "Super Grid",
        "padding": 26,
        "zones": [
            {
                "x": 25,
                "y": 0,
                "height": 100,
                "width": 50
            },
            {
                "x": 25,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "x": 50,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "x": 0,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "x": 75,
                "y": 0,
                "height": 100,
                "width": 25
            },
            {
                "x": 0,
                "y": 0,
                "height": 50,
                "width": 25
            },
            {
                "x": 0,
                "y": 50,
                "height": 50,
                "width": 25
            },
            {
                "x": 75,
                "y": 0,
                "height": 50,
                "width": 25
            },
            {
                "x": 75,
                "y": 50,
                "height": 50,
                "width": 25
            }
        ]
    },

@fynzhak
Copy link
Contributor

fynzhak commented May 2, 2024

Thanks for sharing that @SinanAkkoyun !

I finally had some time this morning to dig into it a little bit too.
Here's a branch that adds an option to choose to render only the target zone or all zones on the overlay:
https://github.com/fynzhak/kzones/tree/target_only

I have mine set up to disable the Zone Selector and render only the target zone. That gives me the effect in the screenshot above.

The problem is that if you do have the Zone Selector enabled, it will still render all the overlapping zones and looks bad. I'm not sure what can be done about that. Maybe it's the price to pay for wanting the overlap?

Also, in case anyone is interested, here's my layout:

{
    "name": "AllZones",
    "padding": 0,
    "zones": [
        {
            "x": 0,
            "y": 0,
            "height": 100,
            "width": 25
        },
        {
            "x": 25,
            "y": 0,
            "height": 100,
            "width": 25
        },
        {
            "x": 50,
            "y": 0,
            "height": 100,
            "width": 25
        },
        {
            "x": 75,
            "y": 0,
            "height": 100,
            "width": 25
        },
        {
            "x": 25,
            "y": 0,
            "height": 100,
            "width": 50
        },
        {
            "x": 0,
            "y": 0,
            "height": 50,
            "width": 25
        },
        {
            "x": 25,
            "y": 0,
            "height": 50,
            "width": 25
        },
        {
            "x": 50,
            "y": 0,
            "height": 50,
            "width": 25
        },
        {
            "x": 75,
            "y": 0,
            "height": 50,
            "width": 25
        },
        {
            "x": 0,
            "y": 50,
            "height": 50,
            "width": 25
        },
        {
            "x": 25,
            "y": 50,
            "height": 50,
            "width": 25
        },
        {
            "x": 50,
            "y": 50,
            "height": 50,
            "width": 25
        },
        {
            "x": 75,
            "y": 50,
            "height": 50,
            "width": 25
        },
        {
            "x": 0,
            "y": 0,
            "height": 100,
            "width":50
        },
        {
            "x": 50,
            "y": 0,
            "height": 100,
            "width":50
        }
    ]
}

@SinanAkkoyun
Copy link

That's awesome! Thank you for sharing :)

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

No branches or pull requests

6 participants