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

feat: options to disable individual window controls, closes #116 #574

Merged
merged 28 commits into from
Oct 11, 2022

Conversation

caesar
Copy link
Contributor

@caesar caesar commented Sep 29, 2022

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

Platform support

API macOS Windows Linux
Window::set_closable ✔️ ✔️ ✔️
Window::is_closable ✔️ ✔️ ✔️
WindowBuilder::with_closable ✔️ ✔️ ✔️
Window::set_minimizable ✔️ ✔️
Window::is_minimizable ✔️ ✔️
WindowBuilder::with_minimizable ✔️ ✔️
Window::set_maximizable ✔️ ✔️
Window::is_maximizable ✔️ ✔️
WindowBuilder::with_maximizable ✔️ ✔️

I am not able to find any GTK APIs which would make it possible to implement the minimizable and maximizable APIs on Linux.

See #116 and tauri-apps/tauri#2353, tauri-apps/tauri#4286.

@caesar
Copy link
Contributor Author

caesar commented Sep 30, 2022

Maximizable / Zoomable / Fullscreenable could also be considered.

It should be noted that disabling maximize was requested in each of the linked issues.
However, a few thoughts…:

  • Disabling resize already disables maximize. Would it ever make sense to disable maximize when the window can be resized to that size anyway?
  • On macOS, maximize isn't (really) a thing. We would want to disable "zoom" which is sometimes equivalent to maximize but not always (app-dependent). In which case: should a hypothetical set_maximizable also enable/disable zoom on macOS, or would a separate set_zoomable method be better?
  • On macOS, zoom and fullscreen share the same button. I think the only way to disable either of them is to directly disable the button, something like this:
    NSButton *button = [window standardWindowButton:NSWindowZoomButton];
    [button setEnabled: NO];

@amrbashir
Copy link
Member

Maximizable / Zoomable / Fullscreenable could also be considered.

It should be noted that disabling maximize was requested in each of the linked issues. However, a few thoughts…:

  • Disabling resize already disables maximize. Would it ever make sense to disable maximize when the window can be resized to that size anyway?

Yeah, they can be separate from each other.

  • On macOS, maximize isn't (really) a thing. We would want to disable "zoom" which is sometimes equivalent to maximize but not always (app-dependent). In which case: should a hypothetical set_maximizable also enable/disable zoom on macOS, or would a separate set_zoomable method be better?

set_maximizable is better to fit the terminology of other platforms and other methods like set_maximized

  • On macOS, zoom and fullscreen share the same button. I think the only way to disable either of them is to directly disable the button, something like this:
    NSButton *button = [window standardWindowButton:NSWindowZoomButton];
    [button setEnabled: NO];

Sure, whatever works for macOS.

@caesar
Copy link
Contributor Author

caesar commented Oct 2, 2022

set_maximizable is better to fit the terminology of other platforms and other methods like set_maximized

Agreed, that probably makes the most sense, especially since Tao seems to implement "zoom" as if it was maximize anyway.

@caesar
Copy link
Contributor Author

caesar commented Oct 8, 2022

Note: I added an example for closable and modified the example for minimize to also cover minimizable.
I hope that's ok.
I thought it unnecessary to also add an example for maximizable since it works identically to minimizable.

@caesar caesar marked this pull request as ready for review October 8, 2022 19:05
@caesar caesar requested a review from a team as a code owner October 8, 2022 19:05
Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

Great work! Thanks

examples/closable.rs Outdated Show resolved Hide resolved
.changes/window-controls-disable.md Outdated Show resolved Hide resolved
examples/minimize.rs Outdated Show resolved Hide resolved
src/platform_impl/windows/window_state.rs Show resolved Hide resolved
src/platform_impl/windows/window.rs Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@caesar caesar requested a review from amrbashir October 10, 2022 16:12
@caesar
Copy link
Contributor Author

caesar commented Oct 10, 2022

Thanks for the review @amrbashir. All the changes made a lot of sense except #574 (comment) – please see my comment there. Is the change in behaviour intended? If so it will be different behaviour from other platforms.

Copy link
Member

@amrbashir amrbashir left a comment

Choose a reason for hiding this comment

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

Last few nit-pick

src/platform_impl/windows/window_state.rs Outdated Show resolved Hide resolved
examples/window_debug.rs Outdated Show resolved Hide resolved
examples/window_debug.rs Outdated Show resolved Hide resolved
examples/window_debug.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/window.rs Outdated Show resolved Hide resolved
src/platform_impl/linux/window.rs Outdated Show resolved Hide resolved
src/window.rs Outdated Show resolved Hide resolved
@caesar
Copy link
Contributor Author

caesar commented Oct 11, 2022

Thanks @amrbashir, that seems to work.

@amrbashir amrbashir merged commit a50fd86 into tauri-apps:dev Oct 11, 2022
@github-actions github-actions bot mentioned this pull request Oct 11, 2022
@caesar caesar deleted the disable-window-controls branch October 12, 2022 22:12
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