Skip to content

Add snap layouts popup on the maximize button - #48

Open
netlinux-ai wants to merge 1 commit into
danakj:mainfrom
netlinux-ai:upstream-snap-layouts
Open

Add snap layouts popup on the maximize button#48
netlinux-ai wants to merge 1 commit into
danakj:mainfrom
netlinux-ai:upstream-snap-layouts

Conversation

@netlinux-ai

Copy link
Copy Markdown

Add snap layouts popup on the maximize button

Hovering a window's maximize button pops up a grid of layout templates, in the
manner of Windows 11's snap layouts. Each template is drawn as a miniature of
the monitor split into zones; the zone under the pointer is highlighted, and
clicking it moves and resizes the window to fill that part of the monitor's
usable area.

Implementation

  • The popup is a new internal window (openbox/snap.c) painted with the
    theme's existing OSD appearances, so it follows the user's theme with no new
    theme requirements. It is anchored below the maximize button and clamped to
    the monitor.
  • It appears after a configurable hover delay, and is taken down on a short
    delay when the pointer leaves (so it can cross the gap between button and
    popup), or immediately on a click elsewhere, a keypress, or the client being
    unmanaged.
  • Zone clicks resize via client_move_resize against the monitor's usable
    area (screen_area), so panels/struts are respected. Fullscreen, shaded and
    maximized states are cleared first.
  • Windows without move/resize functions never get the popup.

Configuration

A new <snapLayouts> block in rc.xml (schema added to rc.xsd):

<snapLayouts>
  <enabled>yes</enabled>
  <delay>500</delay>
  <!-- optional custom layouts, in percent of the monitor's usable area -->
  <layout>
    <zone x="0" y="0" width="50" height="100"/>
    <zone x="50" y="0" width="50" height="100"/>
  </layout>
</snapLayouts>

Six layouts are built in (halves, thirds, quarters, etc.) and are used when
none are configured.

Testing

In daily use as the author's session WM on X11 (glib 2.88, amd64, dual
monitor with an xfce4-panel).

Hovering a window's maximize button pops up a grid of layout templates,
in the manner of Windows 11's snap layouts. Each template is drawn as a
miniature of the monitor split into zones; the zone under the pointer is
highlighted, and clicking it moves and resizes the window to fill that
part of the monitor's usable area.

The popup is a new internal window (openbox/snap.c) painted with the
theme's OSD appearances, anchored below the maximize button and clamped
to the monitor. It appears after a configurable hover delay and is taken
down on a short delay so the pointer can cross the gap into it, or
immediately on a click elsewhere, a keypress, or the client going away.

Configured by a new <snapLayouts> block in rc.xml: <enabled>, <delay>,
and optional <layout><zone x= y= width= height=/></layout> entries given
in percent of the monitor. Six layouts are built in and are used when
none are configured.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sbnwl

sbnwl commented Aug 9, 2026

Copy link
Copy Markdown

@netlinux-ai
Could you please add few pictures to show the impactful changes it brings to the user experience using Openbox. I am already hopeful it is great feature.

(just to clear out the speculation from the description of the pull request)

@netlinux-ai

netlinux-ai commented Aug 10, 2026

Copy link
Copy Markdown
Author

max-snap

This is just a quickie to show it.

Popup appears after about a second. You select the region. The shot shows selecting the top-right quadrant. Then you click and it reshapes the window to that part of the screen. It's just copying the way it's done in Windows 11. I had use of a windows machine and thought it's quite useful so I got Claude to implement it in the window manager I use.

It looks a pretty clean implementation

I use it all the time now on a couple of machines and so far no bugs and side effects.

@sbnwl

sbnwl commented Sep 1, 2026

Copy link
Copy Markdown

@netlinux-ai
I have an update here. I applied both PR48 and PR49 patches in the upstream Debian source and created Ubuntu launchpad PPAs as follows:

  1. Testing PPA: Both PR49 and PR48 patches incorporated together in source code and resulting compiled binaries at https://launchpad.net/~sbnwl/+archive/ubuntu/openbox-workstation-next
  2. Stable PPA: Only PR49 patch incorporated in the source code at https://launchpad.net/~sbnwl/+archive/ubuntu/openbox-workstation.

If you use Ubuntu 26.04, you can add these PPAs to your system and test the resulting performance. So far there are zero regressions in my testing on Ubuntu 26.04 on both PPAs. Both patches, individually or together, work fine in the PPAs.

The advantage (or the good thing) about both patches is that they enhance the Openbox experience, like modern desktop environments provide. Also, the patches do not alter the behavior of existing openbox themes. Both the old and new themes can adopt to the new change if someone likes to do so.

See some screenshots to observe and understand the new behavior.

Screenshot from 2026-09-01 13-08-24 135074420 Screenshot from 2026-09-01 13-05-59 608975249 Screenshot from 2026-09-01 13-02-39 358730847 Screenshot from 2026-09-01 12-57-36 296503874

@netlinux-ai

Copy link
Copy Markdown
Author

Yes I was going for extending the current behaviour not changing it.

I'm not sure the shots show the popup correctly.
Just looks like an empty popup.
I think the zones are just really faint in the shot.

I have another PR if you are interested: adding buttons to the top bar for layers and bringing up obconf.
Just to make it easier and quicker to do those task.

@sbnwl

sbnwl commented Sep 1, 2026

Copy link
Copy Markdown
  1. "I'm not sure the shots show the popup correctly.
    Just looks like an empty popup.
    I think the zones are just really faint in the shot.
    "

Yes, the zones are faint because of the Hovertest theme I created, which does not have great contrast for the popup. The contrast in the popup is better enhanced by using other built-in openbox themes. The good thing is that the tiling works.

  1. "I have another PR if you are interested: adding buttons to the top bar for layers and bringing up obconf."

I think this would be a permanent distraction sort of thing sitting on the titlebar. People only like either keyboard shortcuts to manage tiling or the popup as alternative for on-demand tiling. The simple and minimal, the better the acceptability among users.

Perhaps you could test the PPA sometime. Use any stock Openbox theme you like or a new themerc, and don't forget to add the following block of keys in themerc file:

border.width:                  0
padding.width:                 0
padding.height:                8
window.handle.width:           0
window.client.padding.width:   0
menu.overlap:                  2
*.justify:                     Left
window.button.wistoh:          17
window.title.kgrip:            0

The new key window.button.wistoh defines the width/height aspect ratio of window buttons, and the new key window.title.kgrip defines the empty space (available for grip) above and below the button in the titlebar.

@netlinux-ai

netlinux-ai commented Sep 1, 2026

Copy link
Copy Markdown
Author

Well that's fine but this is what I have:
image

The button between the minimise and maximise is to start obconf
image
This is obconf with the layer and obconf button conf.

In a separate thread I was also thinking about obconf and the theme creation and management.

@sbnwl

sbnwl commented Sep 1, 2026

Copy link
Copy Markdown

I think you should have hover-to-tile popup only.
No obconf (O) or layer (Y), which would do too much scattered patching in the source tree.

I believe to keep neat and minimal patch footprints across the source tree.

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

Successfully merging this pull request may close these issues.

2 participants