BurntSushi / wingo

A fully-featured window manager written in Go.
Do What The F*ck You Want To Public License
1k stars 89 forks source link

Move window controls to the left #138

Open Happy-Ferret opened 6 years ago

Happy-Ferret commented 6 years ago

This is something I've been struggling with for a while now. I'd like to move the window controls (minimize, maximize, close) to the left and display the title text to the right of them.

What changes in code are necessary to achieve that? I don't quite understand the way frame/full.go is supposed to work.

BurntSushi commented 6 years ago

Sorry, but I don't know. I wrote that code over six years ago and I no longer understand it. There isn't that much code, so I think you'll just need to sit down and play with it to see how it works.

Happy-Ferret commented 6 years ago

No worries.

Did some "hacking" and found the relevant part.

Most of the magic happens in moveresizePieces(), updateIcon and updateTitle.

The pieces' MROpt(fX...) actually controls the placement relative to the other elements.

So to place the minimize button to the left (I like the idea of having minimize on the outside and close to the right of it. I'm an ergonomic oddball...) I changed

f.buttonMinimize.MROpt(fX,
        f.buttonMaximize.x()-f.buttonMinimize.w(), 0, 0, 0)

to

f.buttonMinimize.MROpt(fX,
                f.titleBar.x()+f.buttonMinimize.w(), 0, 0, 0)

The result: minimize is now to the left of the titleBar (which, contrary to what it may sound like, is not a wrapper for titleText and/or icon but a mere "splitter" and drag element, dividing the left and right sides of the frame).

Note to myself: Think about switching the geometry from int to float, for more precise placement/spacing.

Happy-Ferret commented 6 years ago

Still largely a WIP (the buttons should probably be closer to the left corner still, and the title centered), but this is what my little "fork" of wingo looks right now.

I already have an idea on how I may implement double clicks, too (since I'm getting rid of the maximize button and the maximize action should be triggered by double clicking anywhere on the frame, I'll need).

Just thought I'd post my progress. Always nice to share. 😸

wm

BurntSushi commented 6 years ago

Awesome, that looks great! Nice work! :)