Skip to content

Commit c1ae92e

Browse files
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6wtellaho
andcommitted
refactor(desktop): inline window-drag handling back into AppShell
Removes the branch-only useTauriWindowDrag hook and restores main's inline pointerdown/dblclick drag effect in AppShell. The hook was an unrelated refactor that snuck onto this branch via an earlier evil merge; it does not exist in main. Drag logic is byte-identical to main, so behavior is preserved. Keeps PR #1066 scoped to the channel-management work. Co-authored-by: Taylor Ho <[email protected]> Signed-off-by: Taylor Ho <[email protected]>
1 parent 781403b commit c1ae92e

2 files changed

Lines changed: 35 additions & 39 deletions

File tree

‎desktop/src/app/AppShell.tsx‎

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import * as React from "react";
2+
import { getCurrentWindow } from "@tauri-apps/api/window";
23
import { useQueryClient } from "@tanstack/react-query";
34
import { Outlet, useLocation } from "@tanstack/react-router";
45

5-
import { deriveShellRoute } from "@/app/AppShell.helpers";
6+
import {
7+
deriveShellRoute,
8+
isWindowDragHandleEvent,
9+
} from "@/app/AppShell.helpers";
610
import { AppShellProvider } from "@/app/AppShellContext";
711
import {
812
AppShellOverlays,
@@ -16,7 +20,6 @@ import { useMarkAsReadShortcuts } from "@/app/useMarkAsReadShortcuts";
1620
import { useSettingsShortcuts } from "@/app/useSettingsShortcuts";
1721
import { useAppShellDesktopNotifications } from "@/app/useAppShellDesktopNotifications";
1822
import { useThreadActivityFeedItems } from "@/app/useThreadActivityFeedItems";
19-
import { useTauriWindowDrag } from "@/app/useTauriWindowDrag";
2023
import { useWebviewZoomShortcuts } from "@/app/useWebviewZoomShortcuts";
2124
import {
2225
channelsQueryKey,
@@ -85,7 +88,6 @@ const LazySettingsScreen = React.lazy(async () => {
8588

8689
export function AppShell() {
8790
useWebviewZoomShortcuts();
88-
useTauriWindowDrag();
8991

9092
const workspacesHook = useWorkspaces();
9193
const [isAddWorkspaceOpen, setIsAddWorkspaceOpen] = React.useState(false);
@@ -207,6 +209,36 @@ export function AppShell() {
207209
pubkey: identityQuery.data?.pubkey,
208210
});
209211

212+
React.useEffect(() => {
213+
function handlePointerDown(event: PointerEvent) {
214+
if (event.button !== 0 || event.detail > 1) {
215+
return;
216+
}
217+
218+
if (!isWindowDragHandleEvent(event)) {
219+
return;
220+
}
221+
222+
void getCurrentWindow().startDragging();
223+
}
224+
225+
function handleDoubleClick(event: MouseEvent) {
226+
if (event.button !== 0 || !isWindowDragHandleEvent(event)) {
227+
return;
228+
}
229+
230+
event.preventDefault();
231+
void getCurrentWindow().toggleMaximize();
232+
}
233+
234+
window.addEventListener("pointerdown", handlePointerDown, true);
235+
window.addEventListener("dblclick", handleDoubleClick, true);
236+
return () => {
237+
window.removeEventListener("pointerdown", handlePointerDown, true);
238+
window.removeEventListener("dblclick", handleDoubleClick, true);
239+
};
240+
}, []);
241+
210242
const {
211243
followedRootIds,
212244
isFollowing: isFollowingThread,

‎desktop/src/app/useTauriWindowDrag.ts‎

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)