Closed ninetynin closed 1 week ago
data-tauri-drag-region
must be applied to the inner-most element, so in your case probably this
<body>
<div class="titlebar" id="titlebar">
<div data-tauri-drag-region>
<div class="titlebar-button" id="titlebar-minimize">
<img src="https://api.iconify.design/mdi:window-minimize.svg" alt="minimize" />
</div>
<div class="titlebar-button" id="titlebar-maximize">
<img src="https://api.iconify.design/mdi:window-maximize.svg" alt="maximize" />
</div>
<div class="titlebar-button" id="titlebar-close">
<img src="https://api.iconify.design/mdi:close.svg" alt="close" />
</div>
</div>
</div>
<script src="main.js"></script>
</body>
instead of
<body>
<div data-tauri-drag-region class="titlebar" id="titlebar">
<div>
<div class="titlebar-button" id="titlebar-minimize">
<img src="https://api.iconify.design/mdi:window-minimize.svg" alt="minimize" />
</div>
<div class="titlebar-button" id="titlebar-maximize">
<img src="https://api.iconify.design/mdi:window-maximize.svg" alt="maximize" />
</div>
<div class="titlebar-button" id="titlebar-close">
<img src="https://api.iconify.design/mdi:close.svg" alt="close" />
</div>
</div>
</div>
<script src="main.js"></script>
</body>
(assuming the double div wasn't an accident and actually used for something)
If you have similar issues in the future / other apps, you can get the actual click target via document.addEventListener("click", console.log);
data-tauri-drag-region
must be applied to the inner-most element, so in your case probably this<body> <div class="titlebar" id="titlebar"> <div data-tauri-drag-region> <div class="titlebar-button" id="titlebar-minimize"> <img src="https://api.iconify.design/mdi:window-minimize.svg" alt="minimize" /> </div> <div class="titlebar-button" id="titlebar-maximize"> <img src="https://api.iconify.design/mdi:window-maximize.svg" alt="maximize" /> </div> <div class="titlebar-button" id="titlebar-close"> <img src="https://api.iconify.design/mdi:close.svg" alt="close" /> </div> </div> </div> <script src="main.js"></script> </body>
instead of
<body> <div data-tauri-drag-region class="titlebar" id="titlebar"> <div> <div class="titlebar-button" id="titlebar-minimize"> <img src="https://api.iconify.design/mdi:window-minimize.svg" alt="minimize" /> </div> <div class="titlebar-button" id="titlebar-maximize"> <img src="https://api.iconify.design/mdi:window-maximize.svg" alt="maximize" /> </div> <div class="titlebar-button" id="titlebar-close"> <img src="https://api.iconify.design/mdi:close.svg" alt="close" /> </div> </div> </div> <script src="main.js"></script> </body>
(assuming the double div wasn't an accident and actually used for something)
If you have similar issues in the future / other apps, you can get the actual click target via
document.addEventListener("click", console.log);
@FabianLars I tried removing the double div and tested it but nope still cant reposition and If you have similar issues in the future / other apps, you can get the actual click target via document.addEventListener("click", console.log);
and i didnt understand about this part like is this related to repositining somehow
Can you please tell why would you close the issue as not planned tho I'm sure this issue isnt gonna be just to myself as a lot of apps in windows eg. opera gx, vscode, spotify and a lot of other ones so if they are migrating from other framewroks to tauri they definitely need that and not being able to reposition it is a major issue as i dont think everyone is gonna use their window set to fullscreen all the time thanks
I tried removing the double div and tested it but nope still cant reposition and If you have similar issues in the future / other apps, you can get the actual click target via document.addEventListener("click", console.log); and i didnt understand about this part like is this related to repositining somehow
You can use this to figure out which element you need to add the attribute to. If you paste that code into the devtools console and then click on your titlebar element it will print the actually clicked element which is useful if you have many nested elements for example.
Can you please tell why would you close the issue as not planned tho I'm sure this issue isnt gonna be just to myself as a lot of apps in windows eg. opera gx, vscode, spotify and a lot of other ones so if they are migrating from other framewroks to tauri they definitely need that and not being able to reposition it is a major issue as i dont think everyone is gonna use their window set to fullscreen all the time thanks
It was closed as not planned because there's no general bug. This is 99% a config/usage error in your app and i'd rather have to re-open the issue later if it proves that there's actually a bug than forgetting to close the issue later (for example if you hadn't reacted anymore i would not get a new notification for this issue and therefore would not remember to close it). I know this comes of as a bit hostile but with the amount of open issues this is currently required to stay on top of things (we're a very small team).
@FabianLars
I've encountered a similar issue. Here is part of the App.vue
code :
<script setup lang="ts">
document.addEventListener("click", console.log)
</script>
<!--This code has been greatly simplified and is only an example.-->
<template>
<div>
<div class="title-bar">
<div class="inner" data-tauri-drag-region style="width: 100%;height: 100%;background-color: aqua">
</div>
</div>
</div>
</template>
The div that is printed by document.addEventListener("click", console.log)
is the one currently possessing the data-tauri-drag-region
attribute. When attempting to drag the window, an error occurs as shown in the following image:
So I tried to add permissions in the file src-tauri/capabilities/default.json
,like this :
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"window:default",
"core:window:allow-start-dragging",
"window:allow-start-dragging",
"shell:allow-open"
],
"capabilities": [
]
}
src-tauri/tauri.conf.json
:
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "test-client",
"version": "0.1.0",
"identifier": "com.test",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"label": "main",
"width": 250,
"maxWidth": 250,
"height": 300,
"maxHeight": 300,
"resizable": false,
"maximizable": false,
"maximized": false,
"center": true,
"focus": true,
"alwaysOnTop": true,
"decorations": false,
"dragDropEnabled": true
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
But it still reports an error :
Uncaught (in promise) window.start_dragging not allowed.
Permissions associated with this command: window:allow-start-dragging.
npm run tauri info
:
> test-client@0.1.0 tauri
> tauri info
[✔] Environment
- OS: Windows 10.0.22631 x86_64 (X64)
✔ WebView2: 129.0.2792.89
✔ MSVC: Visual Studio Community 2022
✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
- node: 20.18.0
- npm: 10.8.2
[-] Packages
- tauri 🦀: 2.0.4
- tauri-build 🦀: 2.0.1
- wry 🦀: 0.46.2
- tao 🦀: 0.30.3
- tauri-cli 🦀: 2.0.3
- @tauri-apps/api : 2.0.2
- @tauri-apps/cli : 2.0.3
[-] Plugins
- tauri-plugin-shell 🦀: 2.0.1
- @tauri-apps/plugin-shell : 2.0.0
[-] App
- build-type: bundle
- CSP: unset
- frontendDist: ../dist
- devUrl: http://localhost:1420/
- framework: Vue.js
- bundler: Vite
Describe the bug
I found issue1 issue2 but both are fixes for resizing the window when using custom titlebar by setting the decorations to false but I'm unable to move reposition the window to some other (x,y) position with same size in windows11
https://github.com/user-attachments/assets/1fbdb65f-c330-4a97-a472-5ccd7c10e201
As you can see in the video I'm not able to move the window to some other location
Reproduction
set
"decorations": false
in tauri.conf.json and select vanilla js while creating the app and these are frontend codesindex.html
styles.css
main.js
Expected behavior
No response
Full
tauri info
outputStack trace
No response
Additional context
No response