hyprland-community / pyprland

Scratchpads & many goodies for Hyprland [maintainer=@fdev31]
MIT License
345 stars 15 forks source link

[FEAT] [layout_center] No way to have a fullscreen "main window" not covering a bar #108

Closed clotodex closed 3 months ago

clotodex commented 3 months ago

Pyprland version 2.3.5

Describe the bug When using any offset (without a large enough margin) the window is "pushed" off the screen.

To Reproduce

[layout_center]
margin = 0 # make sure this is lower than the offset
offset = [0, 30]

open a center layout with a program that uses the full height (e.g. vim) and observe the bottom of the window to be beyond reach.

Expected behavior I expect the window to be resized to fit into the "center layout"

Configuration (provide following files/samples when relevant):

Additional context This is a common issue since these two scenarios can easily overlap:

This plugin is crucial for me since I am just switching from qtile where this is a core feature in their Max layout.

fdev31 commented 3 months ago

Are you using scaling on your monitor or something not so common ?

You are welcome, also former qtile user here ;)

clotodex commented 3 months ago

haha great :D And yes actually, I never thought of that but I have fractional scaling on my laptop screen. I might be able to check tomorrow what happens without scaling for me.

fdev31 commented 3 months ago

In theory scaling is supported, but it could be another option. Anyway your test outcome will be useful, I'll also probably need more info like the full pypr log and a dump of hyprctl -j clients. The sample configuration you are using is more or less the same as mine, so that not the root cause.

clotodex commented 3 months ago

It is not the scaling - I scaled my screen back to 1x and the issue persists. I did not check your code, but if there is some step that resizes the window, it feels like it just puts the hight to screen-margin and does not take offset into account.

Anyways, I dumped all that you desired :D let me know if it helps.

The two windows I had open for testing:

{
    "address": "0x55fc751e8b80",
    "mapped": true,
    "hidden": false,
    "at": [5, 48],
    "size": [1910, 1147],
    "workspace": {
        "id": 1,
        "name": "1"
    },
    "floating": false,
    "monitor": 0,
    "class": "kitty",
    "title": "sleep 4; hyprctl -j ~",
    "initialClass": "kitty",
    "initialTitle": "kitty",
    "pid": 208771,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "swallowing": "0x0",
    "focusHistoryID": 1
},{
    "address": "0x55fc75d97b70",
    "mapped": true,
    "hidden": false,
    "at": [11, 33],
    "size": [1902, 1180],
    "workspace": {
        "id": 1,
        "name": "1"
    },
    "floating": true,
    "monitor": 0,
    "class": "kitty",
    "title": "nvim /tmp/test ~",
    "initialClass": "kitty",
    "initialTitle": "kitty",
    "pid": 153669,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "swallowing": "0x0",
    "focusHistoryID": 0
}

And a wlr-dump of my monitor:

eDP-1 "AU Optronics 0xC199 (eDP-1)"
  Make: AU Optronics
  Model: 0xC199
  Physical size: 340x220 mm
  Enabled: yes
  Modes:
    2560x1600 px, 165.039993 Hz (preferred)
    2560x1600 px, 60.028999 Hz (preferred, current)
  Position: 0,0
  Transform: normal
  Scale: 1.332031
  Adaptive Sync: disabled

And the pypr log of opening a center layout:

                      ipc - Logger "ipc" initialized // common.py:205
                  startup - Logger "startup" initialized // common.py:205
                     pypr - Logger "pypr" initialized // common.py:205
                     pypr - Loading /home/clotodex/.config/hypr/pyprland.toml // command.py:89
                 pyprland - Logger "pyprland" initialized // common.py:205
                 pyprland - version // ipc.py:101
                 pyprland - activeworkspace // ipc.py:101
                 pyprland - monitors // ipc.py:101
                 pyprland - configured // command.py:154
                  magnify - Logger "magnify" initialized // common.py:205
                  magnify - configured // command.py:154
            layout_center - Logger "layout_center" initialized // common.py:205
            layout_center - configured // command.py:154
                     pypr - ================================[ initialized ]================================= // command.py:355
                 pyprland - event_activewindowv2('55fc75d97b70',) // command.py:177
                 pyprland - active_window = 0x55fc75d97b70 // pyprland.py:76
            layout_center - event_activewindowv2('55fc75d97b70',) // command.py:177
            layout_center - run_layout_center('toggle',) // command.py:177
            layout_center - clients // ipc.py:101
            layout_center - dispatch togglefloating address:0x55fc75d97b70 // ipc.py:144
            layout_center - monitors // ipc.py:101
            layout_center - dispatch resizewindowpixel exact 1902 1180,address:0x55fc75d97b70 // ipc.py:144
            layout_center - dispatch movewindowpixel exact 11 33,address:0x55fc75d97b70 // ipc.py:144
            layout_center - run_layout_center('toggle',) // command.py:177
            layout_center - clients // ipc.py:101
            layout_center - dispatch togglefloating address:0x55fc75d97b70 // ipc.py:144
                 pyprland - event_activewindowv2('55fc751e8b80',) // command.py:177
                 pyprland - active_window = 0x55fc751e8b80 // pyprland.py:76
            layout_center - event_activewindowv2('55fc751e8b80',) // command.py:177

And a sneak peak screenshot of the bottom left corner of my screen (you can not read this text): image

clotodex commented 3 months ago

I checked the code :D

https://github.com/hyprland-community/pyprland/blob/2ad983c3a44a0fc7edbf36e8ed274b0643f6ed54/pyprland/plugins/layout_center.py#L109

This is the line in question and it is actually just simply not taking the offset into account.

In the case where you want the margin to be guaranteed of the bottom the line should look like this (imho): height = monitor["height"] - (2 * margin) - y <- the y is the offset that we also need to remove for it to keep the "desired" margin If we do not want to preserve the margin and are simply interested in not overlapping the screen the code would get more complex, since we need to clamp it to the monitors dimensions: height = monitor["height"] - margin - max(y,margin) <- i guess - this is wildly untested

I would be fine with the first version. What do you think? Is this a simple oversight or did you have something in mind?

fdev31 commented 3 months ago

So offset is considered since it's the starting position... EDIT: I think I got your point, indeed the offset isn't considered in the size of the window, only the margin. The offset is applied after the margin in case you don't want things to be centered, most important is the margin.

Think about the margin to be the "padding" from the screen borders, and offset allows you to shift the window in any direction after that has been applied, so with a margin of zero if you set ANY offset your window will be cropped.

What are you trying to achieve exactly ?

fdev31 commented 3 months ago

If it's rotation, you can try the latest git version... But I see Transform: normal :'(

fdev31 commented 3 months ago

I see from the logs:

            layout_center - dispatch resizewindowpixel exact 1902 1180,address:0x55fc75d97b70 // ipc.py:144
            layout_center - dispatch movewindowpixel exact 11 33,address:0x55fc75d97b70 // ipc.py:144

Does it look like it's having a distance from the border of 11 & 33 pixels ? also the size of the window looks ok here (shouldn't go beyond the screen limits of the screen according to your description?).

From the logs the position indeed looks very odd, but it should fit the screen... do you understand something differently? Also which is your Hyprland version?

clotodex commented 3 months ago

haha ok let me clarfiy and thank you for your time on this.

lets start from the top

With those two setttings my windows are getting cropped at the bottom, since due to no margin, but an offset, the height is too large and outgrows the actual screen size

And to your point - it looks like 11 on the sides and 33 on the top - but negative on the bottom

fdev31 commented 3 months ago

ok, much more clear to me now :+1: to achieve what you want, I see some options:

Any comment/preference?

fdev31 commented 3 months ago

The behavior you want to achieve can be implemented without Pyprland, that was my former setup:

hyprctl dispatch fullscreen 1

Enjoy ;)

fdev31 commented 3 months ago

Still added a commit that allows the list of [x,y] margin in case you REALLY want zero margin without trying something complicated...

clotodex commented 3 months ago

Ayy ok interesting, I am supper sorry for bringing this up then :D Supporting this still makes sense to me so thank you for your time, work and commit! But yeah, I just did not read that part of the docs enough... sorry for that and thank you for pointing it out :) Will likely use a hybrid approach now and play more with center floating layouts (which are just generally cool).