@setoelkahfi / svara / commits / 9e70c3c

fix: disabled maximize when fullscreen

mellbacon committed Jul 16, 2023 at 12:05 UTC 9e70c3cfb7fad69f809f68f4d2d80f78c29b34a3
2 files changed +68 -43
src/config/commands.ts
+20
@@ -142,6 +142,26 @@ export const commands = {
142 //
143 }
144 },
145 + "minimizeWindow": {
146 + "keybind": "",
147 + "command": () => {
148 + appWindow.minimize()
149 + }
150 + },
151 + "maximizeWindow": {
152 + "keybind": "",
153 + "command": async () => {
154 + if (await appWindow.isFullscreen()) {
155 + return;
156 + }
157 + if (await appWindow.isMaximized()) {
158 + appWindow.unmaximize();
159 + }
160 + else {
161 + appWindow.maximize()
162 + }
163 + }
164 + },
165 "closeWindow": {
166 "keybind": "Alt+F4",
167 "command": async () => {
src/lib/Header.svelte
+48 -43
@@ -42,8 +42,8 @@
42 ]},
43 {menuname: "Window", children: [
44 {name: "New Window", disabled: true, shortcut: commands.openNewWindow.keybind, action: commands.openNewWindow.command},
45 - {name: "Minimize Window", shortcut: "", action: async () => {await appWindow.minimize()}},
46 - {name: "Maximize Window", shortcut: "", action: async () => {await appWindow.maximize()}},
45 + {name: "Minimize Window", shortcut: commands.minimizeWindow.keybind, action: commands.minimizeWindow.command},
46 + {name: "Maximize Window", shortcut: commands.maximizeWindow.keybind, action: commands.maximizeWindow.command},
47 {name: "Close Window", shortcut: commands.closeWindow.keybind, action: commands.closeWindow.command},
48 ]},
49 {menuname: "Help", children: [
@@ -56,50 +56,55 @@
56 {name: "About", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
57 ]},
58 ];
59 +
60 + const x = appWindow.isFullscreen()
61 </script>
60 -<div id="header">
61 - <div id="logo"></div>
62 - <div id="menubar">
63 - {#each items as item}
64 - <Dropdown menu={item}></Dropdown>
65 - {/each}
66 - </div>
67 - <div class="divider"></div>
68 - <div id="workspace" title="" data-tauri-drag-region>
69 - {$workspaceName}
70 - </div>
71 - <div id="handle" data-tauri-drag-region></div>
72 - <div class="tools">
73 -
74 - <div class="settings-button">
75 - <Dropdown right menu={{icon: Settings, children: [
76 - {name: "Settings", shortcut: "", action: () => {addTab("Settings", "Settings", new settings({target: document.getElementById("tabview")}))}},
77 - {name: "Keymap", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}
78 - ]
79 - }} />
62 +
63 +{#if x}
64 + <div id="header">
65 + <div id="logo"></div>
66 + <div id="menubar">
67 + {#each items as item}
68 + <Dropdown menu={item}></Dropdown>
69 + {/each}
70 + </div>
71 + <div class="divider"></div>
72 + <div id="workspace" title="" data-tauri-drag-region>
73 + {$workspaceName}
74 + </div>
75 + <div id="handle" data-tauri-drag-region></div>
76 + <div class="tools">
77 +
78 + <div class="settings-button">
79 + <Dropdown right menu={{icon: Settings, children: [
80 + {name: "Settings", shortcut: "", action: () => {addTab("Settings", "Settings", new settings({target: document.getElementById("tabview")}))}},
81 + {name: "Keymap", disabled: true, shortcut: "", action: () => {console.warn("Feature not implemented yet.")}}
82 + ]
83 + }} />
84 + </div>
85 + </div>
86 + <div id="window-controls">
87 + <!-- svelte-ignore a11y-click-events-have-key-events -->
88 + <div
89 + class="window-button"
90 + id="minimize"
91 + on:click={commands.minimizeWindow.command}
92 + />
93 + <!-- svelte-ignore a11y-click-events-have-key-events -->
94 + <div
95 + class="window-button"
96 + id="maximize"
97 + on:click={commands.maximizeWindow.command}
98 + />
99 + <!-- svelte-ignore a11y-click-events-have-key-events -->
100 + <div
101 + class="window-button"
102 + id="close"
103 + on:click={commands.closeWindow.command}
104 + />
105 </div>
106 </div>
82 - <div id="window-controls">
83 - <!-- svelte-ignore a11y-click-events-have-key-events -->
84 - <div
85 - class="window-button"
86 - id="minimize"
87 - on:click={() => appWindow.minimize()}
88 - />
89 - <!-- svelte-ignore a11y-click-events-have-key-events -->
90 - <div
91 - class="window-button"
92 - id="maximize"
93 - on:click={async () => { (await appWindow.isMaximized()) ? appWindow.unmaximize() : appWindow.maximize(); }}
94 - />
95 - <!-- svelte-ignore a11y-click-events-have-key-events -->
96 - <div
97 - class="window-button"
98 - id="close"
99 - on:click={commands.closeWindow.command}
100 - />
101 - </div>
102 -</div>
107 +{/if}
108
109 <style lang="scss">
110 #header {