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

[bug] Using appWindow.setSize right after appWindow.setResizable doesn't resize window in Ubuntu 22.04.1 LTS #545

Closed
euirim opened this issue Aug 31, 2022 · 7 comments · Fixed by #553 or #532
Labels
help wanted Help is requested to fix this issue platform: Linux type: bug

Comments

@euirim
Copy link

euirim commented Aug 31, 2022

Describe the bug

In my tauri.conf.json, I've set my window's resizable value to false because I did not want users to be able to resize the window using their cursor. I did, however, want to support users resizing the window to specific resolutions (e.g. 1440x900) via a dropdown. So when the user triggers a resize, I run the following code:

await appWindow.setResizable(true);
await appWindow.setSize(new LogicalSize(1440, 900));
await appWindow.setResizable(false); // prevent user from resizing window using cursor

On Ubuntu 22.04 LTS with no graphical tweaks, the window does not resize after running this code, however. Even when I run the same logic in rust using tauri:window, I still run into the same issue.

Interestingly, if I remove the last line (setResizable(false)), resizing works only if the logical size is greater than or equal to the height and width specified in my tauri.conf.json. Please scroll down this issue post to see my full tauri.conf.json.

If I set my tauri.conf.json to specify "resizable": true and remove the setResizable lines in my code, resizing works as expected.

Reproduction

See description

Expected behavior

See description

Platform and versions

Environment
  › OS: Ubuntu 22.04 X64
  › Node.js: 16.14.0
  › npm: 8.3.1
  › pnpm: 6.11.0
  › yarn: 1.22.17
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.5
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.5,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.2,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/
  › framework: Svelte

App directory structure
  ├─ .routify
  ├─ src
  ├─ node_modules
  ├─ public
  ├─ src-tauri
  ├─ python
  ├─ .git
  ├─ dist
  └─ .vscode

Stack trace

N/A (none produced)

Additional context

Here is my tauri.conf.json:

{
	"$schema": "../node_modules/@tauri-apps/cli/schema.json",
	"build": {
		"beforeBuildCommand": "yarn build",
		"beforeDevCommand": "yarn dev",
		"devPath": "http://localhost:3000",
		"distDir": "../dist"
	},
	"package": {
		"productName": "X",
		"version": "0.1.0"
	},
	"tauri": {
		"allowlist": {
			"all": true
		},
		"bundle": {
			"active": true,
			"category": "DeveloperTool",
			"copyright": "",
			"deb": {
				"depends": []
			},
			"externalBin": [],
			"icon": [
				"icons/32x32.png",
				"icons/128x128.png",
				"icons/128x128@2x.png",
				"icons/icon.icns",
				"icons/icon.ico"
			],
			"identifier": "com.tauri.dev",
			"longDescription": "",
			"macOS": {
				"entitlements": null,
				"exceptionDomain": "",
				"frameworks": [],
				"providerShortName": null,
				"signingIdentity": null
			},
			"resources": [],
			"shortDescription": "",
			"targets": "all",
			"windows": {
				"certificateThumbprint": null,
				"digestAlgorithm": "sha256",
				"timestampUrl": ""
			}
		},
		"security": {
			"csp": null
		},
		"updater": {
			"active": false
		},
		"windows": [
			{
				"fullscreen": false,
				"resizable": false,
				"title": "X",
				"height": 1080,
				"width": 1920
			}
		]
	}
}
@euirim euirim added status: needs triage This issue or pull request needs to be investigated type: bug labels Aug 31, 2022
@amrbashir
Copy link
Member

looks like this is the same as #302

@euirim
Copy link
Author

euirim commented Aug 31, 2022

Thanks. They may be tangentially related but the fix mentioned in that issue appears to have been included in tao v0.12.2, which is what I'm using. Furthermore, I've noticed problems even when I don't set setResizable(false) where the window cannot be resized to a size less than the default height and width.

@keiya01 I've seen your PR for the setResizable issues. Do you think it's related to the issues I'm having here?

@amrbashir amrbashir removed the status: needs triage This issue or pull request needs to be investigated label Aug 31, 2022
@amrbashir
Copy link
Member

I will move this to tao since I can reproduce it, seems the fix did nothing.

@amrbashir amrbashir transferred this issue from tauri-apps/tauri Aug 31, 2022
@amrbashir amrbashir added platform: Linux help wanted Help is requested to fix this issue labels Aug 31, 2022
@wusyong
Copy link
Member

wusyong commented Sep 6, 2022

Maybe we should remove set_default_size when initializing windows. Will this help?

@amrbashir
Copy link
Member

unfortunately not. I tried so many different combinations and got nothing. It seems like if GtkWindow::resize happens asynchronously and GtkWindow::set_resizable is immediate so it will lock the size before resize can do its thing (this is just my observations).

@wusyong
Copy link
Member

wusyong commented Sep 6, 2022

I found GtkWindow::set_size_request will ignore resizable property. But calling set_resizable after it will still overwrite the call somehow.
How do other platforms behave? Can they still resize by calling method when resizable is false?

@amrbashir
Copy link
Member

The problem with GtkWindow::set_size_request is that if you call it to set the width to 200 for example, users can't resize the window afterwards using the mouse to a value that is less than 200

amrbashir pushed a commit that referenced this issue Sep 7, 2022
…#553)

* Try cargo r --example resizable and press space

* Set dault size to (1, 1)

* Remove all set_size_request

* Add platform-specific note to set_resizable

* Add change file

* cargo fmt

Co-authored-by: Wu Yu Wei <wusyong9104@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help is requested to fix this issue platform: Linux type: bug
Projects
None yet
3 participants