Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland Pseudo-Client Side Decorations via OSC #7186

Merged
merged 6 commits into from
Nov 29, 2019

Conversation

philipl
Copy link
Member

@philipl philipl commented Nov 26, 2019

I had previously mused about the possibility of doing CSDs on the cheap using OSC, so I dicided to just give it a go. It's a bit weird but it definitely works:

Screenshot from 2019-11-26 09-22-02

Along the way, I also fixed a wayland maximize bug and added support for triggering resize operations with a mouse.

This isn't exactly an RFC but it's also not fully complete. There's some control layout configs you'd probably want to add,and you might want to argue for implementing window control commands for other VOs (x11, win32, etc) although I think these controls have little to no value outside of Wayland.

@Dudemanguy
Copy link
Member

The maximized fix is definitely good and something we should do correctly (it's part of xdg shell after all). I'm personally against CSDs in general (GNOME should just do things correctly imo), but I'm not going to die on a hill for it. If everyone else really wants it, then it's not a big deal to add.

@CounterPillow
Copy link
Contributor

I'm personally against CSDs in general (GNOME should just do things correctly imo), but I'm not going to die on a hill for it.

A compromise would be to make them so ugly that nobody in their right mind would think they are a good idea. Cyan text on a pink background using the cartooniest font one can find on the system, and make the window title "These decorations brought to you by GNOME".

But maybe that's just being too petty.

@philipl
Copy link
Member Author

philipl commented Nov 26, 2019

Screenshot from 2019-11-26 18-25-34

@ghost
Copy link

ghost commented Nov 26, 2019

I mean, if someone went through the trouble of implementing this...
Probably could be useful in no-border mode on other platforms too.

player/command.c Outdated Show resolved Hide resolved
@ghost
Copy link

ghost commented Nov 26, 2019

The commit message subject lines ignore some of the cosmetic rules listed here: https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md#write-good-commit-messages

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@philipl
Copy link
Member Author

philipl commented Nov 26, 2019

I've repushed to fix the subject lines.

I'll adapt to the new win_state functionality after it's pushed, but keep in mind my comment about minimize being write-only for Wayland.

@philipl philipl force-pushed the wayland branch 2 times, most recently from 07c6965 to 23fbc2a Compare November 28, 2019 07:03
@philipl
Copy link
Member Author

philipl commented Nov 28, 2019

I've updated the change set with minimize and maximize implemented as properties, by making the existing minimize property settable (although this now means that the VOs which report state cannot set it, and the VO that can set it can't report it. 🙄). I then added an equivalent maximized property, but it is only implemented on wayland here, of course.

@ghost
Copy link

ghost commented Nov 28, 2019

The subject line convention is still wrong and uses uppercase after :. Otherwise ok.

Today, we support resizing wayland windows when we detect a touch
event in a defined grab zone. As part of implementing
pseudo-decorations, we should have equivalent functionality for
mouse input. And if we detect support for actual decorations we
will not activate the grab zone as the decorations will provide this.
@philipl
Copy link
Member Author

philipl commented Nov 28, 2019

I've updated the subject lines. I'm going to spend a bit more time tweaking the osc part to support left vs right placement and maybe have a pseudo-titlebar and then I'll push if there are no other concerns.

@Dudemanguy ?

@Dudemanguy
Copy link
Member

LGTM

Rather than hard-coding the edge grab zone width, we can make it
user configurable. It seems worthwhile to have separate configs
for pointer and touch usage as the defaults should be different,
and a user might have both input methods in use.
At least with gnome-shell (I know, I know), the compositor does
not provide the old window size when leaving the maximized state.
Instead, we get a toplevel_config event with a 0x0 size and no
additional states.

Today, we already save the window geometry to restore it when leaving
the fullscreen state, so we just need a small change for it to
kick in for leaving the maximized state. If I read this correctly,
we'll still respect the size passed by a compositor that actually
provides the old size.
If we want to implement window pseudo-decorations via OSC, we need a
way to tell the vo to minimize and maximize the window. Today, we have
minimized as a read-only property, and no property for maximized.

Let's made minimized settable and add a maximized property to go with
it. In turn, that requires us to add VOCTRLs for minimizing or
maximizing a window, and an additional WIN_STATE to indicate a
maximized window.
We primarily care about pseudo-decorations for wayland, where
the compositor may not support server-side decorations. So let's
implement the minimize and maximize commands and return the
maximized window state.
Today, if window decorations are not present, either because they were
disabled, or because the platform doesn't support them
(eg: gnome-shell on wayland), there are no window controls, meaning it
is not possible to minimize/maximize/close a window without knowing
keyboard shortcuts.

While you can imagine various ways of offering client side decorations,
it is attractive to consider using OSC because that is functionality
that we already have.

The main work here is defining a separate input area from the main
OSC box with its own buttons, etc.

While we could probably handle auto-detection based on whether
decorations are present or not, it's manually controlled for now.

The window control logic is mostly disconnected from the OSC itself,
except in the case of the `topbar` layout, where there has to be
coordination so that the controls don't get drawn on top of each other.

I had to do fine-positioning of the buttons based on the font on
my system, so don't be surprised if it looks wrong elsewhere.

You could also argue that window controls should be unscaled, even
if the main OSC box is scaled, but I've not tried to do this.
@philipl philipl merged commit a220f08 into mpv-player:master Nov 29, 2019
@philipl philipl deleted the wayland branch November 29, 2019 08:57
@orbea
Copy link
Contributor

orbea commented Nov 30, 2019

@philipl With x11 the hardware mouse cursor is no longer hidden when left idle over a mpv window after this commit a220f08.

I am using the window manager spectrwm which I am not sure is relevant, maybe its different in a full DE?

@philipl
Copy link
Member Author

philipl commented Nov 30, 2019

@orbea File a separate issue with your full config. I can't trivially reproduce such a problem.

@orbea
Copy link
Contributor

orbea commented Nov 30, 2019

@philipl No need anymore, one of the commits last night fixed it. :)

@soloturn
Copy link

what a cool idea @philipl to do it via https://mpv.io/manual/master/#on-screen-controller.

@str225
Copy link

str225 commented Jan 5, 2020

You don't need to show the file title tho, it's redundant

@emanuelserpa
Copy link

is there some command to change the mpv window buttons to the left or is still WIP?

@Dudemanguy
Copy link
Member

Yes.

@emanuelserpa
Copy link

Thank you very much!

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.

7 participants