diff options
author | Que Quotion | 2018-05-13 20:38:15 +0900 |
---|---|---|
committer | Que Quotion | 2018-05-13 20:38:15 +0900 |
commit | b4b2e6cb6333b071610e4cd688ea95f45274715a (patch) | |
tree | 6d550dd5a959959aee8a208a51ab00712388bfa8 /minus-backgroundmanager.patch | |
parent | 58df2d5730517ad586aceef9e6767e9090b14889 (diff) | |
download | aur-b4b2e6cb6333b071610e4cd688ea95f45274715a.tar.gz |
No more wingpanel-interface? But the patch that deletes non-existing Utils.vala from here is fine, so why only the patch that removed BackgroundManager.vala fails?
Diffstat (limited to 'minus-backgroundmanager.patch')
-rw-r--r-- | minus-backgroundmanager.patch | 236 |
1 files changed, 154 insertions, 82 deletions
diff --git a/minus-backgroundmanager.patch b/minus-backgroundmanager.patch index 764b60342c93..9a54da96cfb9 100644 --- a/minus-backgroundmanager.patch +++ b/minus-backgroundmanager.patch @@ -108,9 +108,9 @@ ) vala_precompile (CLIENT_VALA_C ${CMAKE_PROJECT_NAME} ---- src/wingpanel/src/Services/BackgroundManager.vala 2018-03-04 00:30:27.781440874 +0900 -+++ /dev/null 2018-03-03 20:05:09.041298375 +0900 -@@ -1,133 +0,0 @@ +--- src/wingpanel/wingpanel-interface/BackgroundManager.vala 2018-05-13 16:35:27.438070885 +0900 ++++ /dev/null 2018-05-12 19:49:31.706719886 +0900 +@@ -1,204 +0,0 @@ -/* - * Copyright (c) 2011-2015 Wingpanel Developers (http://launchpad.net/wingpanel) - * @@ -130,117 +130,189 @@ - * Boston, MA 02110-1301 USA. - */ - --namespace Wingpanel.Services { -- public enum BackgroundState { -- LIGHT, -- DARK, -- MAXIMIZED, -- TRANSLUCENT_DARK, -- TRANSLUCENT_LIGHT +-public enum BackgroundState { +- LIGHT, +- DARK, +- MAXIMIZED, +- TRANSLUCENT_DARK, +- TRANSLUCENT_LIGHT +-} +- +-public class WingpanelInterface.BackgroundManager : Object { +- private const int WALLPAPER_TRANSITION_DURATION = 150; +- private const double ACUTANCE_THRESHOLD = 8; +- private const double STD_THRESHOLD = 45; +- private const double LUMINANCE_THRESHOLD = 180; +- +- public signal void state_changed (BackgroundState state, uint animation_duration); +- +- public int monitor { private get; construct; } +- public int panel_height{ private get; construct; } +- +- private ulong wallpaper_hook_id; +- +- private Meta.Workspace? current_workspace = null; +- +- private BackgroundState current_state = BackgroundState.LIGHT; +- +- private Utils.ColorInformation? bk_color_info = null; +- +- public BackgroundManager (int monitor, int panel_height) { +- Object (monitor : monitor, panel_height: panel_height); +- +- connect_signals (); +- update_bk_color_info.begin ((obj, res) => { +- update_bk_color_info.end (res); +- update_current_workspace (); +- }); +- } +- +- ~BackgroundManager () { +- var signal_id = GLib.Signal.lookup ("changed", Main.wm.background_group.get_type ()); +- GLib.Signal.remove_emission_hook (signal_id, wallpaper_hook_id); - } - -- [DBus (name = "org.pantheon.gala.WingpanelInterface")] -- public interface InterfaceBus : Object { -- public signal void state_changed (BackgroundState state, uint animation_duration); +- private void connect_signals () { +- Main.screen.workspace_switched.connect (() => { +- update_current_workspace (); +- }); - -- public abstract void initialize (int monitor, int panel_height) throws IOError; -- public abstract void remember_focused_window () throws IOError; -- public abstract void restore_focused_window () throws IOError; +- var signal_id = GLib.Signal.lookup ("changed", Main.wm.background_group.get_type ()); +- +- wallpaper_hook_id = GLib.Signal.add_emission_hook (signal_id, 0, (ihint, param_values) => { +- update_bk_color_info.begin ((obj, res) => { +- update_bk_color_info.end (res); +- check_for_state_change (WALLPAPER_TRANSITION_DURATION); +- }); +- +- return true; +-#if VALA_0_42 +- }); +-#else +- }, null); +-#endif - } - -- public class BackgroundManager : Object { -- private const string DBUS_NAME = "org.pantheon.gala.WingpanelInterface"; -- private const string DBUS_PATH = "/org/pantheon/gala/WingpanelInterface"; +- private void update_current_workspace () { +- var workspace = Main.screen.get_workspace_by_index (Main.screen.get_active_workspace_index ()); +- +- if (workspace == null) { +- warning ("Cannot get active workspace"); - -- private static BackgroundManager? instance = null; +- return; +- } - -- private InterfaceBus? bus = null; +- if (current_workspace != null) { +- current_workspace.window_added.disconnect (on_window_added); +- current_workspace.window_removed.disconnect (on_window_removed); +- } - -- private BackgroundState current_state = BackgroundState.LIGHT; -- private bool use_transparency = true; +- current_workspace = workspace; - -- private bool bus_available { -- get { -- return bus != null; +- foreach (Meta.Window window in current_workspace.list_windows ()) { +- if (window.is_on_primary_monitor ()) { +- register_window (window); - } - } - -- private int monitor; -- private int panel_height; +- current_workspace.window_added.connect (on_window_added); +- current_workspace.window_removed.connect (on_window_removed); - -- public signal void background_state_changed (BackgroundState state, uint animation_duration); +- check_for_state_change (AnimationSettings.get_default ().workspace_switch_duration); +- } - -- public static void initialize (int monitor, int panel_height) { -- var manager = BackgroundManager.get_default (); -- manager.monitor = monitor; -- manager.panel_height = panel_height; -- } +- private void register_window (Meta.Window window) { +- window.notify["maximized-vertically"].connect (() => { +- check_for_state_change (AnimationSettings.get_default ().snap_duration); +- }); - -- private BackgroundManager () { -- PanelSettings.get_default ().notify["use-transparency"].connect (() => { -- use_transparency = PanelSettings.get_default ().use_transparency; -- state_updated (); -- }); +- window.notify["minimized"].connect (() => { +- check_for_state_change (AnimationSettings.get_default ().minimize_duration); +- }); +- } - -- use_transparency = PanelSettings.get_default ().use_transparency; +- private void on_window_added (Meta.Window window) { +- register_window (window); - -- Bus.watch_name (BusType.SESSION, DBUS_NAME, BusNameWatcherFlags.NONE, -- () => connect_dbus (), -- () => bus = null); -- } +- check_for_state_change (AnimationSettings.get_default ().snap_duration); +- } - -- public void remember_window () { -- if (!bus_available) { -- return; -- } +- private void on_window_removed (Meta.Window window) { +- check_for_state_change (AnimationSettings.get_default ().snap_duration); +- } +- +- public async void update_bk_color_info () { +- SourceFunc callback = update_bk_color_info.callback; +- Gdk.Rectangle monitor_geometry; - +- Gdk.Screen.get_default ().get_monitor_geometry (monitor, out monitor_geometry); +- +- Utils.get_background_color_information.begin (Main.wm, monitor, 0, 0, monitor_geometry.width, panel_height, (obj, res) => { - try { -- bus.remember_focused_window (); +- bk_color_info = Utils.get_background_color_information.end (res); - } catch (Error e) { -- warning ("Remembering focused window failed: %s", e.message); +- warning (e.message); +- } finally { +- callback (); - } -- } +- }); +- +- yield; +- } - -- public void restore_window () { -- if (!bus_available) { -- return; -- } +- /** +- * Check if Wingpanel's background state should change. +- * +- * The state is defined as follows: +- * - If there's a maximized window, the state should be MAXIMIZED; +- * - If no information about the background could be gathered, it should be TRANSLUCENT; +- * - If there's too much contrast or sharpness, it should be TRANSLUCENT; +- * - If the background is too bright, it should be DARK; +- * - Else it should be LIGHT. +- */ +- private void check_for_state_change (uint animation_duration) { +- bool has_maximized_window = false; - -- try { -- bus.restore_focused_window (); -- } catch (Error e) { -- warning ("Restoring last focused window failed: %s", e.message); +- foreach (Meta.Window window in current_workspace.list_windows ()) { +- if (window.get_monitor () == monitor) { +- if (!window.minimized && window.maximized_vertically) { +- has_maximized_window = true; +- break; +- } - } - } - -- private bool connect_dbus () { -- try { -- bus = Bus.get_proxy_sync (BusType.SESSION, DBUS_NAME, DBUS_PATH); -- bus.initialize (monitor, panel_height); -- } catch (Error e) { -- warning ("Connecting to \"%s\" failed: %s", DBUS_NAME, e.message); -- return false; -- } +- BackgroundState new_state; - -- bus.state_changed.connect ((state, animation_duration) => { -- current_state = state; -- state_updated (animation_duration); -- }); +- if (has_maximized_window) { +- new_state = BackgroundState.MAXIMIZED; +- } else if (bk_color_info == null) { +- new_state = BackgroundState.TRANSLUCENT_LIGHT; +- } else { +- var luminance_std = Math.sqrt (bk_color_info.luminance_variance); - -- state_updated (); -- return true; -- } +- bool bg_is_busy = luminance_std > STD_THRESHOLD || +- (bk_color_info.mean_luminance < LUMINANCE_THRESHOLD && +- bk_color_info.mean_luminance + 1.645 * luminance_std > LUMINANCE_THRESHOLD ) || +- bk_color_info.mean_acutance > ACUTANCE_THRESHOLD; - -- private void state_updated (uint animation_duration = 0) { -- background_state_changed (use_transparency ? current_state : BackgroundState.MAXIMIZED, animation_duration); -- } +- bool bg_is_dark = bk_color_info.mean_luminance > LUMINANCE_THRESHOLD; +- bool bg_is_busy_dark = bk_color_info.mean_luminance * 1.25 > LUMINANCE_THRESHOLD; - -- public static BackgroundManager get_default () { -- if (instance == null) { -- instance = new BackgroundManager (); -- } +- if (bg_is_busy && bg_is_busy_dark) { +- new_state = BackgroundState.TRANSLUCENT_DARK; +- } else if (bg_is_busy) { +- new_state = BackgroundState.TRANSLUCENT_LIGHT; +- } else if (bg_is_dark) { +- new_state = BackgroundState.DARK; +- } else { +- new_state = BackgroundState.LIGHT; +- } +- } - -- return instance; +- if (new_state != current_state) { +- state_changed (current_state = new_state, animation_duration); - } - } -} + |