Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: treat sticky windows as on current desktop #113

Merged
merged 1 commit into from
Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/native_platform/lib/src/linux/linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class Linux implements NativePlatform {
return windows;
}

/// wmctrl reports a window's desktop number as -1 if it is "sticky".
/// For example, if using GNOME's "Workspaces on primary display only"
/// preference every window on secondary displays will have "desktop: -1";
static const _kStickyWindowIdentifier = -1;

/// Takes a line of output from wmctrl and if valid returns a [Window].
Future<Window?> _buildWindow(String wmctrlLine, bool showHidden) async {
final parts = wmctrlLine.split(' ');
Expand All @@ -55,7 +60,8 @@ class Linux implements NativePlatform {

// Which virtual desktop this window is on.
final windowDesktop = int.tryParse(parts[1]);
final windowOnCurrentDesktop = (windowDesktop == _desktop);
final windowOnCurrentDesktop = (windowDesktop == _desktop ||
windowDesktop == _kStickyWindowIdentifier);
if (!windowOnCurrentDesktop && !showHidden) return null;

final pid = int.tryParse(parts[2]);
Expand Down