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

Double click tauri-drag-region to maximize #1839

Closed
Shotman opened this issue May 15, 2021 · 7 comments · Fixed by #2106
Closed

Double click tauri-drag-region to maximize #1839

Shotman opened this issue May 15, 2021 · 7 comments · Fixed by #2106

Comments

@Shotman
Copy link

Shotman commented May 15, 2021

Describe the bug
Double click not working on element with data-tauri-drag-region attribute
To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/Shotman/tauri-bordeless-vue
  2. Run yarn tauri:serve
  3. Double click on custom sidebar
  4. Event not triggered

Prebuilt packages are available if you don't want to build the project in the releases

Expected behavior
The event should be triggered

Screenshots
If applicable, add screenshots to help explain your problem.

Platform and Versions (please complete the following information):

Operating System - Windows, version 10.0.19042 X64
Webview2 - 90.0.818.62

Node.js environment
Node.js - 15.12.0
@tauri-apps/cli - 1.0.0-beta.0
@tauri-apps/api - 1.0.0-beta.1

Global packages
npm - 7.12.0
yarn - 1.22.5

Rust environment
rustc - 1.52.1
cargo - 1.52.0

App directory structure
/.git
/.github
/.history
/node_modules
/public
/src
/src-tauri

App
tauri.rs - 1.0.0-beta.1
build-type - bundle
CSP - default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline' img-src: 'self'
distDir - Set automatically by Vue CLI plugin
devPath - Set automatically by Vue CLI plugin
framework - Vue.js (Vue CLI)
bundler - Webpack

@amrbashir
Copy link
Member

I see you're on Windows, unfortunately dragging the window requires capturing the mouse and sending HTCAPTION msg to the window to simulate a click on a title bar so the dblclick event won't be delivered to the webview correctly.

I see you want the dblclick on data-tauri-drag-region to simulate "double click titlebar to maximize the window", which you won't need to do when I finally fix the aero-snap and allow-resizing of borderless window on Windows.

@amrbashir
Copy link
Member

amrbashir commented Jun 24, 2021

related to tauri-apps/tao#103

@amrbashir
Copy link
Member

I am gonna change the title since we can't do anything atm to correctly forward the double click so this issue will be about double click to maximixe instead.

@amrbashir amrbashir changed the title Double click not working with data-tauri-drag-region attribute Double click tauri-drag-region to maximize Jun 24, 2021
@amrbashir
Copy link
Member

amrbashir commented Jun 28, 2021

Apparently I was wrong, fixing the Aero-Snap on windows, didn't maximize the window on double clicking a drag-region.

A solution to this problem can be like this, I'd like your input @lucasfernog:

document.addEventListener('mousedown', (e) => {
	if (e.target.hasAttribute('data-tauri-drag-region') && e.buttons === 1) {
		e.detail === 2
			// only call maximize for Windows platform or other platforms that has this behavior for normal windows ?
			? maximize()
            : drag();
	}
})

@lucasfernog
Copy link
Member

Makes sense @amrbashir

@icanhazpython
Copy link

Is there a way to prevent this behavior? I have a custom window without decorations and I'd like to allow moving the window, but I'd like to disable double-click to maximize and aero snap. I set a min/max size for my window in the config, but that doesn't stop the window from maximizing in either of these situations.
Thanks

@FabianLars
Copy link
Member

@icanhazpython Sorry for the super long delay.
You can add an event listener on the relevant element which then calls startDragging(). The tauri-drag-region attribute does the same under the hood (but with the addition of the double-click handler).

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 a pull request may close this issue.

5 participants