wmww / gtk-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol
GNU General Public License v3.0
317 stars 16 forks source link

Cannot set both exclusize zone and anchor in 2 edges. #67

Closed rilian-la-te closed 3 years ago

rilian-la-te commented 3 years ago

I want to set both exclusize zone and anchor to top-left. How to do it?

ammen99 commented 3 years ago

Setting exclusive zone does not make any sense if you are anchored to only 2 edges, because the compositor cannot know which edge you want to reserve space from. You need to achor to 1 or 3 edges for exclusive zone to make sense.

rilian-la-te commented 3 years ago

@ammen99 I want to do like this: (panel in top-left) - (exclusive zone in top) (panel in left-top) - (exclusive zone in left)

It should depend on where window is smaller. If I anchored to 1 or 3 edges, window will be in center, which I do not want.

wmww commented 3 years ago

Hello! Unfortunately, there's not much I can do. This issue is with the layer shell protocol which is controlled by the wlroots developers, not me. You've got two options:

I would guess getting this corner case (sorry, had to) added to the protocol is unlikely to happen, at least not unless there were multiple other users who wanted the same thing. I'm going to focus on workarounds.

The most obvious is to make two layer surface windows. One with your panel's content and anchored to the corner, and the other transparent, anchored to the side and with the exclusive zone you want. You can make a window transparent with gtk_widget_set_opacity(window, 0.0). You may want to connect your main window's size_allocate signal to a function that sets the empty window's exclusive zone. exclusive zones can be bigger than the surface, so don't worry about resizing the GTK window bigger than 1x1. You may also need to set the corner window's exclusive zone to -1. This isn't well documented in GTK Layer Shell, but according to the protocol this should keep it from being effected by other surface's exclusive zones. There still might be issues if you have multiple panels anchored to the same side.

The other way I can think of is anchoring to 3 edges and using a very large margin to make it look like it's in one corner. Getting the logic right here might be tricky, so I wouldn't prefer this method.

Closing the issue as this is not a problem with the library, but feel free to keep replying.

rilian-la-te commented 3 years ago

@wmww this is not about adding this to protocol, this is about layer-shell request. How I see it in layer-shell? if window has auto_exclusive_zone and anchored to 2 edges, then:

  1. get_preferred_size of widget
  2. check, which is smaller
  3. set exclusive zone for this edge.

Or you means than it is not possible for protocol to have such exclusive zone?

wmww commented 3 years ago

Or you means than it is not possible for protocol to have such exclusive zone?

Correct. The protocol doesn't allow setting an exclusive zone for a particular edge, the edge is implied by the surface's anchor. The GTK Layer Shell API maps quite closely to the wlr-layer-shell Wayland protocol. The biggest difference is that GTK Layer Shell will automatically change the exclusive zone as the window size changes if auto exclusive zone is enabled (but you can still set exclusive zone manually if you want).