WayfireWM / wayfire

A modular and extensible wayland compositor
https://wayfire.org/
MIT License
2.37k stars 175 forks source link

Stick panel on the screen while using cube or expo #1683

Closed bootkernel closed 5 months ago

bootkernel commented 1 year ago

Currently, the panel is shown in each workspace when either cube or expo plugin is triggered - which is clearly an expected behavior.

However, I'm trying to achieve something else: Is there a suggested way to make the panel stick to the screen (on the usual location) and not make it appear in every workspace separately? So when the Cube or Expo plugin is triggered, the panel stays and sticks always on top of the screen.

I'd appreciate any pointers on what files to look at (E.g changes to a specific code snippet?) or what changes I can make (E.g Do I need to make any changes to the render hooks? etc.) to achieve this.

PS. I also saw a similar question here: https://github.com/WayfireWM/wayfire/issues/1488#issue-1252383829

Thanks!

ammen99 commented 1 year ago

Hi, there were recent changes which make this possible. What do you want to do with the areas on the workspace previews covered by the panel though? Do you want them cut off, or empty, or have a duplicate panel on them? All of these combinations are achievable, but require slightly different changes.

bootkernel commented 1 year ago

Hi, It'd not hurt to cut them off at all but I'd like to leave them empty instead.

ammen99 commented 1 year ago

So here's how the code for cube and expo works: they render 'workspace stream nodes'. These nodes render other nodes in the corresponding layers (background, bottom, workspace, top, overlay). To leave panels out, you'd need to ignore the top and/or overlay layers here: https://github.com/WayfireWM/wayfire/blob/master/src/output/workspace-stream.cpp#L156

After that, you should put the cube node (which draws the whole cube + background) below the top layer, so that the top and overlay layers are visible (and thus the panels in them). Currently, cube adds its node at the very top of the scenegraph: https://github.com/WayfireWM/wayfire/blob/master/plugins/cube/cube.cpp#L398

If you have no idea what the scenegraph is, I'd recommend looking at https://github.com/WayfireWM/wayfire/wiki/Scenegraph and also executing a wf::dump_scene() at some place in the plugins to see how the full scenegraph looks at runtime.

bootkernel commented 1 year ago

Ah I see, these are very helpful pointers, thanks a lot, I'll take a look at them and make those changes. I looked at Scenegraph earlier but needed to read it thoroughly, but I'll read it and explore it further.

There's also another thing I wanted to know regarding the expo (not sure if I should open another issue) - I was earlier looking at the expo plugin and workspace-wall codebase, and I was trying to achieve something like this:

SmartSelect_20230110_152402_Samsung Notes

Currently, the expo plugin zooms back to the workspace clicked, but I want it to zoom back to arbitrary an space when clicked and not snap into any workspace (like this image above). Do you have any suggestions/pointers on what to look at to achieve this?

ammen99 commented 1 year ago

Just set the workspace wall viewport appropriately - it is an arbitrary rectangle which can cover one or more workspaces. This is how the expo animation works: https://github.com/WayfireWM/wayfire/blob/master/plugins/single_plugins/expo.cpp#L334

bootkernel commented 1 year ago

Thanks a ton! 😊 This is very useful information.

ammen99 commented 1 year ago

@bootkernel Just curious, are you trying to create a plugin which allows free scrolling (kinda like paperwm)?

bootkernel commented 1 year ago

@ammen99 I'm creating a desktop environment based on Wayfire for an OS I've been developing - not necessarily a plugin but yes, a desktop environment with a scrollable/zoomable interface.

bootkernel commented 1 year ago

Just set the workspace wall viewport appropriately - it is an arbitrary rectangle which can cover one or more workspaces. This is how the expo animation works: https://github.com/WayfireWM/wayfire/blob/master/plugins/single_plugins/expo.cpp#L334

I went ahead and set the viewport accordingly - it works perfectly, zooms into any arbitrary point in the workspace wall. However, I noticed that the workspace snaps into a target workspace after the animation ends which I believe is because of this: https://github.com/WayfireWM/wayfire/blob/master/plugins/single_plugins/expo.cpp#L344

I tried setting the same coordinates that I used for the wall->set_viewport() here output->workspace->set_workspace(target_ws); but it gave me a not valid workspace error which is expected since it's at an arbitrary point.

Would achieving this require changing https://github.com/WayfireWM/wayfire/blob/master/src/output/workspace-impl.cpp#L466 i.e set_workspace() implementation or is there any other way to achieve this during deactivation?

This is what it looks like currently (zooms into an arbitrary point but then snaps into the target_ws): https://user-images.githubusercontent.com/33711869/212924532-8060ec3a-2932-4364-8904-75e31865e97e.mp4

ammen99 commented 1 year ago

@bootkernel The target workspace is in another coordinate system. If you have 3x3 workspace grid, then workspaces are [0, 2] x [0, 2] and that is the parameter to set_workspace().

Of course the problem is that when you zoom in and expo exits, the workspace wall is no longer active - so core will revert to aligning to a particular workspace. You have two options: keep up the illusion (e.g. keep workspace-wall active even after expo is done) - this may cause conflicts with other plugins though, because then they cannot have their custom rendering done. Or, you can simply forget about Wayfire's workspace management and do it this way:

Of course, I am making some assumptions on what you are trying to achieve, as I am not familiar with your goals.

bootkernel commented 1 year ago

Okay I see, I feel like the second option is a better way to achieve what I wanted (i.e zoom in/out at/from anywhere on the screen and create an illusion where all the workspaces look like a singular giant wall) - I tried the first option that you mentioned but it was causing issues like you said. I'll try the second option. Thank you for the detailed explanation.

bootkernel commented 1 year ago

Hey @ammen99, although this isn't directly related to this issue, posting it here anyways, I'm trying to build a plugin that is a combination of wrot's 3d and move - it's for a 3D/VR like interface where I can move a window around, and the window will rotate as I move/drag it around the screen (as wrot currently doesn't have a move functionality). I got a bit lost when looking at the implementation of the move plugin.

Do you suggest looking at specific functions in move to allow movement of the windows too in wrot?

bootkernel commented 5 months ago

Solved! Thanks for all the pointers!

ammen99 commented 5 months ago

Solved! Thanks for all the pointers!

Ok, glad you figured it out! I somehow missed your previous question, sorry for that. Feel free to leave a link to your plugin if you're going to publish it ;)