-
-
Notifications
You must be signed in to change notification settings - Fork 5
WIP: Tiling support #105
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
base: master
Are you sure you want to change the base?
WIP: Tiling support #105
Changes from all commits
51922ea
db5fb11
2faee12
4c07b65
4ea61e5
d2788b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,9 @@ import { overview } from 'resource:///org/gnome/shell/ui/main.js'; | |
|
|
||
| import EventManager from './eventManager.js'; | ||
| import { areSameState } from './states.js'; | ||
| import { MAXIMIZATION_TYPE } from '../constants.js'; | ||
|
|
||
| const { VERTICAL, BOTH } = Meta.MaximizeFlags; | ||
| const { VERTICAL, HORIZONTAL, BOTH } = Meta.MaximizeFlags; | ||
|
|
||
| const SIZE_CHANGE_EVENT = 'size-changed'; | ||
| const WORKSPACE_CHANGE_EVENT = 'workspace-switched'; | ||
|
|
@@ -24,26 +25,37 @@ const OVERVIEW_HIDING = 'hiding'; | |
| // FIXME: this causes the overview to close on login | ||
| const isDesktopIconsNG = window => window.customJS_ding !== undefined; // this is to ignore "Desktop Icons NG"'s window hacks | ||
|
|
||
| // Check if window is full screen or monitor sized | ||
| const isFullScreen = window => window.is_monitor_sized() || window.is_screen_sized(); | ||
|
|
||
| /** | ||
| * Determines if a window is maximized or full-screen | ||
| * | ||
| * @param {Meta.Window} window - The window to check | ||
| * @param {string} maximizationType - Maximization type definition | ||
| * @returns {boolean} True if the window is maximized or full-screen | ||
| */ | ||
| const isMaximized = window => { | ||
| const isMaximized = (window, maximizationType = MAXIMIZATION_TYPE.BOTH) => { | ||
| // Ignore Desktop Icons NG windows | ||
| if (isDesktopIconsNG(window)) | ||
| return false; | ||
|
|
||
|
|
||
| // Check if window is full-screen | ||
| if (window.is_monitor_sized() || window.is_screen_sized()) | ||
| return true; | ||
|
|
||
|
|
||
| // Check if window is maximized (either vertically or both dimensions) | ||
| const maximizeFlags = window.get_maximized(); | ||
| return [BOTH, VERTICAL].includes(maximizeFlags); | ||
| const windowMaximizeState = window.get_maximized(); | ||
|
|
||
| switch (maximizationType) { | ||
| case MAXIMIZATION_TYPE.BOTH: | ||
| return windowMaximizeState === BOTH || isFullScreen(window); | ||
| case MAXIMIZATION_TYPE.VERTICAL: | ||
| return windowMaximizeState === VERTICAL || windowMaximizeState === BOTH; | ||
| case MAXIMIZATION_TYPE.HORIZONTAL: | ||
| return windowMaximizeState === HORIZONTAL || windowMaximizeState === BOTH; | ||
| case MAXIMIZATION_TYPE.ANY: | ||
| return windowMaximizeState === VERTICAL || | ||
| windowMaximizeState === HORIZONTAL || | ||
| windowMaximizeState === BOTH || isFullScreen(window); | ||
| default: | ||
| return windowMaximizeState === BOTH; | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix the default case |
||
| } | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -70,6 +82,7 @@ export default class WindowEvents { | |
| this.workspace = null; | ||
| this.inOverview = false; | ||
| this.maximizedWindows = new Set(); | ||
| this.maximizationType = MAXIMIZATION_TYPE.BOTH; // Default value | ||
| this.lastState = null; | ||
| } | ||
|
|
||
|
|
@@ -82,6 +95,23 @@ export default class WindowEvents { | |
| this.stateChangeCallback = callback; | ||
| } | ||
|
|
||
| setMaximizationType(type) { | ||
| this.maximizationType = type; | ||
| this.forceStateUpdate(); | ||
| } | ||
|
|
||
| forceStateUpdate() { | ||
| // Update the maximized windows set based on the current maximization type | ||
| this.maximizedWindows = this.getMaximizedWindowIds(); | ||
|
|
||
| // Force a state change emission | ||
| this.stateChangeCallback({ | ||
| maximizedWindows: this.maximizedWindows, | ||
| currentWorkspace: this.workspace, | ||
| inOverview: this.inOverview | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the current window state | ||
| * | ||
|
|
@@ -130,7 +160,7 @@ export default class WindowEvents { | |
| * @param {Meta.Window} window - The window that changed size | ||
| */ | ||
| const onWindowSizeChange = window => { | ||
| if (isMaximized(window)) | ||
| if (isMaximized(window, this.maximizationType)) | ||
| this.maximizedWindows.add(window.get_id()); | ||
| else | ||
| this.maximizedWindows.delete(window.get_id()); | ||
|
|
@@ -179,7 +209,7 @@ export default class WindowEvents { | |
| ); | ||
| } | ||
|
|
||
| if (isMaximized(window)) | ||
| if (isMaximized(window, this.maximizationType)) | ||
| this.maximizedWindows.add(window.get_id()); | ||
|
|
||
| this.eventManager.attachWindowEventOnce( | ||
|
|
@@ -209,11 +239,13 @@ export default class WindowEvents { | |
| */ | ||
| const onWindowRaise = (_, windowActor) => { | ||
| const window = windowActor.get_meta_window(); | ||
| if (isMaximized(window)) | ||
| if (isMaximized(window, this.maximizationType)) | ||
| this.maximizedWindows.add(window.get_id()); | ||
| this.emitStateChange(); | ||
| }; | ||
|
|
||
| const forceStateChangeEmission = () => emitStateChange(true); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wtf is this |
||
|
|
||
| this.workspace = this.workspaceManager.get_active_workspace(); | ||
|
|
||
| // TODO: what if the window starts as maximized dimensions but is not "snapped"? | ||
|
|
@@ -310,7 +342,7 @@ export default class WindowEvents { | |
| return new Set( | ||
| this.display | ||
| .list_all_windows() | ||
| .filter(isMaximized) | ||
| .filter(window => isMaximized(window, this.maximizationType)) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bring in the ismaximized in scope so it can read this. |
||
| .map(window => window.get_id()) | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,15 @@ export default class GradientTopBar extends Extension { | |
| const config = getConfig(settings); | ||
| applyGradientStyle(config, this.path); | ||
|
|
||
| // For other behaviors, we need to track window states | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a check if we're using a simple gradient and return if so. |
||
| if (!this.windowEvents) { | ||
| // If window events were not initialized, initialize them now | ||
| this.initializeWindowEvents(); | ||
| } | ||
| // Update maximization type if it changed | ||
| if (this.windowEvents) | ||
| this.windowEvents.setMaximizationType(config.maximizationType); | ||
|
|
||
| const maximizedBehavior = getMaximizedBehavior(settings); | ||
|
|
||
| // If set to keep-gradient, disable window events to save resources | ||
|
|
@@ -34,12 +43,9 @@ export default class GradientTopBar extends Extension { | |
| return; | ||
| } | ||
|
|
||
| // For other behaviors, we need to track window states | ||
| if (!this.windowEvents) { | ||
| // If window events were not initialized, initialize them now | ||
| this.initializeWindowEvents(); | ||
| } | ||
| this.windowEvents.enable(); | ||
|
|
||
| // Force update to apply the current behavior | ||
| this.windowEvents.forceStateUpdate(); | ||
| }; | ||
| } | ||
|
|
@@ -62,6 +68,10 @@ export default class GradientTopBar extends Extension { | |
| global.window_manager, | ||
| global.get_workspace_manager() | ||
| ); | ||
| const config = getConfig(this._settings); | ||
|
|
||
| // Set the maximization type from settings | ||
| this.windowEvents.setMaximizationType(config.maximizationType); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not be there wtf |
||
|
|
||
| this.windowEvents.setStateChangeCallback( | ||
| ({ maximizedWindows, currentWorkspace, inOverview }) => { | ||
|
|
@@ -134,6 +144,7 @@ export default class GradientTopBar extends Extension { | |
| this.toggleGradient(false); | ||
| detachSettingsListeners(this._settings, this.onSettingsChanged); | ||
|
|
||
| this.windowEvents = null; | ||
| this.isEffectApplied = false; | ||
| this._settings = null; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix constant and we can do a loop here.