-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3963 Fix window resizing not work on linux
- Loading branch information
1 parent
f6ba7e4
commit 5764443
Showing
7 changed files
with
169 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:wox/utils/log.dart'; | ||
|
||
class LinuxWindowManager { | ||
static const _channel = MethodChannel('com.wox.window_manager'); | ||
|
||
static final LinuxWindowManager instance = LinuxWindowManager._(); | ||
|
||
LinuxWindowManager._(); | ||
|
||
Future<void> setSize(double width, double height) async { | ||
try { | ||
Logger.instance.info("LinuxWindowManager", "Setting size to: $width x $height"); | ||
final Map<String, dynamic> arguments = { | ||
'width': width, | ||
'height': height, | ||
}; | ||
await _channel.invokeMethod<void>('setSize', arguments); | ||
} catch (e) { | ||
Logger.instance.error("LinuxWindowManager", "Error setting window size: $e"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/services.dart'; | ||
import 'package:wox/utils/log.dart'; | ||
|
||
class LinuxWindowManager { | ||
static const _channel = MethodChannel('com.wox.window_manager'); | ||
|
||
static final LinuxWindowManager instance = LinuxWindowManager._(); | ||
|
||
LinuxWindowManager._(); | ||
|
||
Future<void> setSize(double width, double height) async { | ||
try { | ||
await _channel.invokeMethod('setSize', { | ||
'width': width, | ||
'height': height, | ||
}); | ||
} catch (e) { | ||
Logger.instance.error("LinuxWindowManager", "Error setting window size: $e"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "gtk_window.h" | ||
|
||
bool is_gtk_available() { | ||
// Check if we're running under GTK | ||
const char* xdg_session_type = g_getenv("XDG_SESSION_TYPE"); | ||
const char* desktop_session = g_getenv("DESKTOP_SESSION"); | ||
const char* current_desktop = g_getenv("XDG_CURRENT_DESKTOP"); | ||
|
||
if (xdg_session_type != nullptr && | ||
(g_strcmp0(xdg_session_type, "wayland") == 0 || g_strcmp0(xdg_session_type, "x11") == 0)) { | ||
if (current_desktop != nullptr && | ||
(g_strstr_len(current_desktop, -1, "GNOME") != nullptr || | ||
g_strstr_len(current_desktop, -1, "Unity") != nullptr || | ||
g_strstr_len(current_desktop, -1, "XFCE") != nullptr || | ||
g_strstr_len(current_desktop, -1, "Pantheon") != nullptr || | ||
g_strstr_len(current_desktop, -1, "MATE") != nullptr || | ||
g_strstr_len(current_desktop, -1, "Cinnamon") != nullptr)) { | ||
return true; | ||
} | ||
if (desktop_session != nullptr && | ||
(g_strstr_len(desktop_session, -1, "gnome") != nullptr || | ||
g_strstr_len(desktop_session, -1, "unity") != nullptr || | ||
g_strstr_len(desktop_session, -1, "xfce") != nullptr || | ||
g_strstr_len(desktop_session, -1, "mate") != nullptr || | ||
g_strstr_len(desktop_session, -1, "cinnamon") != nullptr)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
void resize_gtk_window(GtkWindow* window, int width, int height) { | ||
if (window == nullptr) { | ||
return; | ||
} | ||
|
||
// Set minimum size to prevent window from becoming too small | ||
gtk_window_set_resizable(window, TRUE); | ||
gtk_window_set_default_size(window, width, height); | ||
gtk_window_resize(window, width, height); | ||
|
||
// Force the window to process the resize | ||
gtk_widget_queue_resize(GTK_WIDGET(window)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef GTK_WINDOW_H_ | ||
#define GTK_WINDOW_H_ | ||
|
||
#include <gtk/gtk.h> | ||
|
||
bool is_gtk_available(); | ||
void resize_gtk_window(GtkWindow* window, int width, int height); | ||
|
||
#endif // GTK_WINDOW_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters