This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddb8030
commit e3cfe9d
Showing
6 changed files
with
357 additions
and
47 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,79 @@ | ||
import 'package:flutter/foundation.dart'; | ||
|
||
import 'display.dart'; | ||
|
||
enum WindowManagerMode { | ||
tiling, | ||
floating, | ||
stacking, | ||
} | ||
|
||
class WindowManager extends ChangeNotifier { | ||
WindowManager({ | ||
this.mode = WindowManagerMode.stacking, | ||
}); | ||
|
||
final WindowManagerMode mode; | ||
List<Window> _wins = []; | ||
|
||
void dispose() {} | ||
|
||
Window fromToplevel(DisplayServerToplevel toplevel) { | ||
for (final win in _wins) { | ||
if (win.toplevel == toplevel) return win; | ||
} | ||
|
||
final win = Window._(this, toplevel); | ||
_wins.add(win); | ||
notifyListeners(); | ||
return win; | ||
} | ||
|
||
void removeToplevel(DisplayServerToplevel toplevel) { | ||
_wins.removeWhere((win) => win.toplevel == toplevel); | ||
notifyListeners(); | ||
} | ||
} | ||
|
||
class Window extends ChangeNotifier { | ||
Window._(this.manager, this.toplevel) : | ||
_x = 0, _y = 0, _layer = 0, _minimized = false; | ||
|
||
final WindowManager manager; | ||
final DisplayServerToplevel toplevel; | ||
|
||
@override | ||
void notifyListeners() { | ||
super.notifyListeners(); | ||
manager.notifyListeners(); | ||
} | ||
|
||
double _x; | ||
double get x => _x; | ||
set x(double value) { | ||
_x = value; | ||
notifyListeners(); | ||
} | ||
|
||
double _y; | ||
double get y => _y; | ||
set y(double value) { | ||
_y = value; | ||
notifyListeners(); | ||
} | ||
|
||
int _layer; | ||
int get layer => _layer; | ||
set layer(int value) { | ||
_layer = value; | ||
notifyListeners(); | ||
} | ||
|
||
bool _minimized; | ||
bool get minimized => _minimized; | ||
|
||
set minimized(bool value) { | ||
_minimized = value; | ||
notifyListeners(); | ||
} | ||
} |
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
Oops, something went wrong.