Closed doroved closed 5 months ago
@ahkohd Hi, any thoughts on what the problem might be :)
Perhaps we need to write our own data-tauri-drag-region
handler that won't conflict with NSPanel?
Apparently there is a conflict between acceptFirstMouse
and always_on_top
(in case of NSPanel instead of always_on_top
we just don't hide the panel when changing focus) due to the fact that while clicking on data-tauri-drag-region
2 events acceptFirstMouse
and start_dragging are triggered simultaneously and that's why sometimes we get a bug with window/panel position change.
I seem to have solved the problem by adding a 100ms delay for start_dragging
.
By the way, here https://github.com/tauri-apps/tauri/issues/6568 there is a problem with NSWindow in Tauri 2.0.0-alpha.2, although I have everything ok in 1.6.2, only with NSPanel (by the way you should check .always_on_top for NSPanel).
Here is the solution to the problem. At the moment it seems that everything is ok, I will click, test further)
<script setup lang="ts">
import { appWindow } from "@tauri-apps/api/window";
const fixDragging = () => {
setTimeout(() => {
appWindow.startDragging();
}, 100);
};
</script>
<template>
<div
class="flex h-screen items-center justify-center text-slate-300"
@mousedown="fixDragging"
>
</template>
If further tests show that the problem is fixed, then Tauri developers should add 100ms delay in this code. https://github.com/tauri-apps/tauri/blob/0c61784efbec4ae5e9d1c89460dcb3380e46b65e/core/tauri/src/window/scripts/drag.js#L42
@doroved, I'm glad you found a workaround to this issue!
@doroved, I'm glad you found a workaround to this issue!
I think we can close this issue, I described the problem and solution here: https://github.com/tauri-apps/tauri/issues/6568#issuecomment-2131272886
I don't know if it makes sense to do something for nspanel, it's probably better to wait for the edit to be made on the Tauri side, and if someone encounters this problem now, they can use my solution.
@doroved, I'm glad you found a workaround to this issue!
I think we can close this issue, I described the problem and solution here: tauri-apps/tauri#6568 (comment)
I don't know if it makes sense to do something for nspanel, it's probably better to wait for the edit to be made on the Tauri side, and if someone encounters this problem now, they can use my solution.
Okay, I'll pin the issue. Thanks!
In my application, I use the ability to pin a window and I ran into a problem, the cause of which I searched for many hours)
Make these edits to the code to reproduce the problem.
acceptFirstMouse
andstartDragging
After starting the application, open the application by clicking on the system tray icon, you can drag the window anywhere, then you have to click in the area outside the window, wait a few seconds, then click in the
data-tauri-drag-region
. It is still unclear what exactly triggers the problem, but you will notice that when you click on thedata-tauri-drag-region
again, the window position will change dramatically. https://youtu.be/McfLrebxq7IAnd if you drag the window to the upper right corner and do the operation described above, the window will disappear altogether, apparently changing its position outside the visibility of the macbook window. https://youtu.be/vof60XG6Dm4
When using a regular window, without tauri-nspanel with the settings
always_on_top(true)
andaccept_first_mouse(true)
I do not see such a problem.I hope you will be able to solve this problem and maybe better implement it in tauri-nspanel package.