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

app: add support to hidden minimize and maximize buttons on macos and … #143

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kkeybbs
Copy link

@kkeybbs kkeybbs commented Aug 29, 2024

Two options app.HiddenMinimizeButton and app.HiddenMaximizeButton are added to create a window without minimize or/and maximize buttons.

hide both minimize and maximize buttons

w := new(app.Window)
w.Option(app.HiddenMinimizeButton(true), app.HiddenMaximizeButton(true))
image

hide minimize button, keep maximize button:

w := new(app.Window)
w.Option(app.HiddenMinimizeButton(true), app.HiddenMaximizeButton(false))
  • on macOS:
image
  • on Windows:
image

app/os.go Outdated
Comment on lines 49 to 52
// HiddenMinimizeButton hide the window's minimize button
HiddenMinimizeButton bool
// HiddenMaximizeButton hide the window's maximize button
HiddenMaximizeButton bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should either note that these don't work under Linux, or make them work under Linux.

Copy link
Author

Choose a reason for hiding this comment

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

I have tried for days to test on ubuntu with os_x11.go, but still not working.

  • _NET_WM_ALLOWED_ACTIONS
  • _MOTIF_WM_HINTS
  • _NET_WM_WINDOW_TYPE: _NET_WM_WINDOW_TYPE_DIALOG

They all didn't work. I belive these properties also depend on window manager implementation, according to infomations bellow:

I'll continue wokring to make them work on x11 and wayland, but this may take long time.
So I add tips "only works for windows and macOS" for the options.
Maybe the feature working only on some os is acceptable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the feature working only on some os is acceptable?

Fine with me. Better than nothing! Thanks for trying.

@eliasnaur
Copy link
Contributor

Can you describe the use-cases you need these controls for? Can we just automatically apply them when, say, MinSize == MaxSize?

@kkeybbs
Copy link
Author

kkeybbs commented Sep 9, 2024

Can you describe the use-cases you need these controls for? Can we just automatically apply them when, say, MinSize == MaxSize?

Some usefull cases in my business products:

  • using both HiddenMaximizeButton and HiddenMinimizeButton
    • Making a dialog window, such as application's "About" dialog. Just need closing insteadof minimizing and maximizing.
    • Instead of minimizing to Dock, user can click the app, and makes it work in the background and an icon in the systray. Users like this easy experience, it saves spaces in Dock.
  • using HiddenMaximizeButton, to disallow a window to be a fullscreen window in new desktop on macOS.

So maybe I can try how to make a window be dialog in x11.

Sometimes HiddenMaximizeButton can be automatically apply with "MinSize == MaxSize", but not always when size is screen size. Maximizing will make the window as a new fullscreen window in macOS. So leave them standalone will be better.

@eliasnaur
Copy link
Contributor

Sorry for the slow response; I'm unusually busy these days.

Can you describe the use-cases you need these controls for? Can we just automatically apply them when, say, MinSize == MaxSize?

Some usefull cases in my business products:

* using both HiddenMaximizeButton and HiddenMinimizeButton
  
  * Making a dialog window, such as application's "About" dialog. Just need closing insteadof minimizing and maximizing.
  * Instead of minimizing to Dock, user can click the app, and makes it work in the background and an icon in the systray. Users like this easy experience, it  saves spaces in Dock.

* using HiddenMaximizeButton, to disallow a window to be a fullscreen window in new desktop on macOS.

Upon further though, perhaps the rules could be:

  • If MinSize != {0, 0}, hide/disable minimize button
  • If MaxSize != {0, 0}, hide/disable maximize button.

What do you think?

So maybe I can try how to make a window be dialog in x11.

Sometimes HiddenMaximizeButton can be automatically apply with "MinSize == MaxSize", but not always when size is screen size. Maximizing will make the window as a new fullscreen window in macOS. So leave them standalone will be better.

Can you elaborate? What is special about the screen size?

@kkeybbs
Copy link
Author

kkeybbs commented Oct 30, 2024

I'm not sure if the rules from app.Option like this app.MinSize(0, 0)?
So MinSize != {0, 0} and MaxSize != {0, 0} will always be true.

// MinSize sets the minimum size of the window.
func MinSize(w, h unit.Dp) Option {
	if w <= 0 {
		panic("width must be larger than or equal to 0")
	}
	if h <= 0 {
		panic("height must be larger than or equal to 0")
	}
	return func(m unit.Metric, cnf *Config) {
		cnf.MinSize = image.Point{
			X: m.Dp(w),
			Y: m.Dp(h),
		}
	}
}

While windows always match the rule MinSize != {0, 0}, most users want to show the minimize button, only a few want to hide, so we still need an option app.HiddenMinimizeButton(true)

@eliasnaur
Copy link
Contributor

If you're saying there's no way to revert to no MinSize once a MinSize has been set, then yes. It seems to me Gio will need to allow app.MinSize(0, 0) to mean "remove min size cosntraint". Same with app.MaxSize.

Would you like to contribute that change as well?

@kkeybbs
Copy link
Author

kkeybbs commented Dec 13, 2024

You are right as the initial size may be {0, 0}, or Gio change this cosntraint.

But when using MinSize != {0, 0}, most users just want to make the window not too small, and still keep the minimize button. Only few users want to hide/disable it.

And changing the rules change the default window-style which the most users expected.
Explicit options to hide minimize and maximize buttons are good for the most.

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.

3 participants