diff --git a/extensions/native-window-placement/Makefile.am b/extensions/native-window-placement/Makefile.am index c53a6149..6d86e1f5 100644 --- a/extensions/native-window-placement/Makefile.am +++ b/extensions/native-window-placement/Makefile.am @@ -1,3 +1,14 @@ EXTENSION_ID = native-window-placement include ../../extension.mk + +gschemas_in = org.gnome.shell.extensions.native-window-placement.gschema.xml.in + +@INTLTOOL_XML_NOMERGE_RULE@ + +gsettings_SCHEMAS = $(gschemas_in:.xml.in=.xml) + +@GSETTINGS_RULES@ + +CLEANFILES += $(gschemas_in:.xml.in=.valid) $(gsettings_SCHEMAS) +EXTRA_DIST += $(gschemas_in) diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js index 7ced09c1..ce8a9916 100644 --- a/extensions/native-window-placement/extension.js +++ b/extensions/native-window-placement/extension.js @@ -1,6 +1,7 @@ // -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- // import just everything from workspace.js: const Clutter = imports.gi.Clutter; +const Gio = imports.gi.Gio; const Lang = imports.lang; const Mainloop = imports.mainloop; const Meta = imports.gi.Meta; @@ -19,9 +20,12 @@ const Tweener = imports.ui.tweener; const Workspace = imports.ui.workspace; const WindowPositionFlags = Workspace.WindowPositionFlags; +const WindowPlacementStrategy = { + NATURAL: 0, + GRID: 1, +}; + // testing settings for natural window placement strategy: -const WINDOW_PLACEMENT_STRATEGY = "natural" // window placement strategy: natural | grid -const WINDOW_PLACEMENT_NATURAL_MORESCREEN = true; // activate mod4-directions-part that tries to use more screen real estate const WINDOW_PLACEMENT_NATURAL_FILLGAPS = true; // enlarge windows at the end to fill gaps // not implemented yet const WINDOW_PLACEMENT_NATURAL_GRID_FALLBACK = true; // fallback to grid mode if all windows have the same size and positions. // not implemented yet const WINDOW_PLACEMENT_NATURAL_ACCURACY = 20; // accuracy of window translate moves (KDE-default: 20) @@ -105,6 +109,18 @@ Rect.prototype = { // Put your extension initialization code here function main() { + let settings = new Gio.Settings({ schema: 'org.gnome.shell.extensions.native-window-placement' }); + let placementStrategy = settings.get_enum('strategy'); + settings.connect('changed::strategy', function() { + placementStrategy = settings.get_enum('strategy'); + // we don't update immediately, we wait for a relayout + // (and hope for the best) + }); + let useMoreScreen = settings.get_boolean('use-more-screen'); + settings.connect('changed::use-more-screen', function() { + useMoreScreen = settings.get_boolean('use-more-screen'); + }); + /** * _calculateWindowTransformationsNatural: * @clones: Array of #MetaWindow @@ -182,7 +198,7 @@ function main() { rects[j].translate(diff[0], diff[1]); - if (WINDOW_PLACEMENT_NATURAL_MORESCREEN) { + if (useMoreScreen) { // Try to keep the bounding rect the same aspect as the screen so that more // screen real estate is utilised. We do this by splitting the screen into nine // equal sections, if the window center is in any of the corner sections pull the @@ -316,12 +332,14 @@ function main() { let targets = []; let scales = []; - switch (WINDOW_PLACEMENT_STRATEGY) { - case "natural": + switch (placementStrategy) { + case WindowPlacementStrategy.NATURAL: [clones, targets] = this._calculateWindowTransformationsNatural(clones); break; - case "grid": default: + log ('Invalid window placement strategy'); + placementStrategy = WindowPlacementStrategy.GRID; + case WindowPlacementStrategy.GRID: [clones, targets] = this._calculateWindowTransformationsGrid(clones); break; } @@ -384,8 +402,7 @@ function main() { } /// position window titles on top of windows in overlay //// - - if ( PLACE_WINDOW_CAPTIONS_ON_TOP ) { + if (settings.get_boolean('window-captions-on-top')) { Workspace.WindowOverlay.prototype._init = function(windowClone, parentActor) { let metaWindow = windowClone.metaWindow; diff --git a/extensions/native-window-placement/org.gnome.shell.extensions.native-window-placement.gschema.xml.in b/extensions/native-window-placement/org.gnome.shell.extensions.native-window-placement.gschema.xml.in new file mode 100644 index 00000000..873bfd7b --- /dev/null +++ b/extensions/native-window-placement/org.gnome.shell.extensions.native-window-placement.gschema.xml.in @@ -0,0 +1,26 @@ + + + + + + + + 'natural' + <_summary>Window placement strategy + <_description>The algorithm used to layout thumbnails in the overview. 'grid' to use the default grid based algorithm, + 'natural' to use another one that reflects more the position and size of the actual window + + + true + <_summary>Use more screen for windows + <_description>Try to use more screen for placing window thumbnails by adapting to screen aspect ratio, and consolidating + them further to reduce the bounding box. This setting applies only with the natural placement strategy. + + + true + <_summary>Place window captions on top + <_description>If true, place window captions on top the respective thumbnail, overriding shell default of placing it at + the bottom. Changing this setting requires restarting the shell to have any effect. + + + diff --git a/po/POTFILES.in b/po/POTFILES.in index 5a3b4854..5efb1047 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -5,6 +5,7 @@ extensions/auto-move-windows/org.gnome.shell.extensions.auto-move-windows.gschem extensions/dock/extension.js extensions/example/extension.js extensions/gajim/extension.js +extensions/native-window-placement/org.gnome.shell.extensions.native-window-placement.gschema.xml.in extensions/user-theme/org.gnome.shell.extensions.user-theme.gschema.xml.in extensions/windowsNavigator/extension.js extensions/xrandr-indicator/extension.js