From 2592f6f31c72d8c48279eb428345e88f771904b7 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 4 Jul 2023 21:58:58 +0900 Subject: [PATCH 1/5] PiP: Check workspace before hiding the window --- plugins/pip/PopupWindow.vala | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 5a21043ee..63dda0d40 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -38,8 +38,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private bool off_screen = false; private Clutter.Grab? grab = null; - private static unowned Meta.Window? previous_focus = null; - // From https://opensourcehacker.com/2011/12/01/calculate-aspect-ratio-conserving-resize-for-images-in-javascript/ private static void calculate_aspect_ratio_size_fit (float src_width, float src_height, float max_width, float max_height, out float width, out float height) { @@ -48,13 +46,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { height = src_height * ratio; } - private static bool get_window_is_normal (Meta.Window window) { - var window_type = window.get_window_type (); - return window_type == Meta.WindowType.NORMAL - || window_type == Meta.WindowType.DIALOG - || window_type == Meta.WindowType.MODAL_DIALOG; - } - public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) { Object (wm: wm, window_actor: window_actor); } @@ -71,14 +62,12 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { set_pivot_point (0.5f, 0.5f); set_easing_mode (Clutter.AnimationMode.EASE_IN_QUAD); - var window = window_actor.get_meta_window (); + unowned var window = window_actor.get_meta_window (); window.unmanaged.connect (on_close_click_clicked); - window.notify["appears-focused"].connect (() => { - Idle.add (() => { - update_window_focus (); - return Source.REMOVE; - }); - }); + window.notify["appears-focused"].connect (update_window_focus); + + unowned var workspace_manager = wm.get_display ().get_workspace_manager (); + workspace_manager.active_workspace_changed.connect (update_window_focus); clone = new Clutter.Clone (window_actor); @@ -311,21 +300,15 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private void update_window_focus () { - unowned Meta.Window focus_window = wm.get_display ().get_focus_window (); - if ((focus_window != null && !get_window_is_normal (focus_window)) - || (previous_focus != null && !get_window_is_normal (previous_focus))) { - previous_focus = focus_window; - return; - } + unowned var workspace_manager = wm.get_display ().get_workspace_manager (); + unowned var active_workspace = workspace_manager.get_active_workspace (); + unowned var window = window_actor.get_meta_window (); - var window = window_actor.get_meta_window (); - if (window.appears_focused) { + if (window.appears_focused && window.located_on_workspace (active_workspace)) { hide (); } else if (!window_actor.is_destroyed ()) { show (); } - - previous_focus = focus_window; } private void update_size () { From be0f2775d639457bfff7f99ed10c1d19763f7e30 Mon Sep 17 00:00:00 2001 From: lenemter Date: Tue, 4 Jul 2023 22:00:16 +0900 Subject: [PATCH 2/5] Update metainfo --- data/gala.metainfo.xml.in | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/data/gala.metainfo.xml.in b/data/gala.metainfo.xml.in index ffa72fec6..94f62caa2 100644 --- a/data/gala.metainfo.xml.in +++ b/data/gala.metainfo.xml.in @@ -25,6 +25,18 @@ contact_at_elementary.io + + +

Improvements:

+
    +
  • Updated translations
  • +
+
+ + PiP doesn't become visible by changing workspaces + +
+

Improvements:

From 92bf3c3a4d70bdd52df49729221660a33aa91942 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 5 Jul 2023 00:41:10 +0900 Subject: [PATCH 3/5] Reduce diff --- plugins/pip/PopupWindow.vala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 63dda0d40..0e599c875 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -38,6 +38,8 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { private bool off_screen = false; private Clutter.Grab? grab = null; + private static unowned Meta.Window? previous_focus = null; + // From https://opensourcehacker.com/2011/12/01/calculate-aspect-ratio-conserving-resize-for-images-in-javascript/ private static void calculate_aspect_ratio_size_fit (float src_width, float src_height, float max_width, float max_height, out float width, out float height) { @@ -50,6 +52,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { Object (wm: wm, window_actor: window_actor); } + private static bool get_window_is_normal (Meta.Window window) { + var window_type = window.get_window_type (); + return window_type == Meta.WindowType.NORMAL + || window_type == Meta.WindowType.DIALOG + || window_type == Meta.WindowType.MODAL_DIALOG; + } + construct { unowned var display = wm.get_display (); var scale = display.get_monitor_scale (display.get_current_monitor ()); @@ -300,6 +309,13 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } private void update_window_focus () { + unowned Meta.Window focus_window = wm.get_display ().get_focus_window (); + if ((focus_window != null && !get_window_is_normal (focus_window)) + || (previous_focus != null && !get_window_is_normal (previous_focus))) { + previous_focus = focus_window; + return; + } + unowned var workspace_manager = wm.get_display ().get_workspace_manager (); unowned var active_workspace = workspace_manager.get_active_workspace (); unowned var window = window_actor.get_meta_window (); @@ -309,6 +325,9 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { } else if (!window_actor.is_destroyed ()) { show (); } + + + previous_focus = focus_window; } private void update_size () { From effbc5c5c9ea7dd9d3549384d4dcb38a309dc558 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 5 Jul 2023 00:42:11 +0900 Subject: [PATCH 4/5] Reduce diff 2 --- plugins/pip/PopupWindow.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 0e599c875..595edc9dc 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -48,10 +48,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { height = src_height * ratio; } - public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) { - Object (wm: wm, window_actor: window_actor); - } - private static bool get_window_is_normal (Meta.Window window) { var window_type = window.get_window_type (); return window_type == Meta.WindowType.NORMAL @@ -59,6 +55,10 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { || window_type == Meta.WindowType.MODAL_DIALOG; } + public PopupWindow (Gala.WindowManager wm, Meta.WindowActor window_actor) { + Object (wm: wm, window_actor: window_actor); + } + construct { unowned var display = wm.get_display (); var scale = display.get_monitor_scale (display.get_current_monitor ()); From c19abf8fea193555e53434f733e7f82636da2479 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 5 Jul 2023 00:42:37 +0900 Subject: [PATCH 5/5] Remove extra space --- plugins/pip/PopupWindow.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/pip/PopupWindow.vala b/plugins/pip/PopupWindow.vala index 595edc9dc..f875ef677 100644 --- a/plugins/pip/PopupWindow.vala +++ b/plugins/pip/PopupWindow.vala @@ -326,7 +326,6 @@ public class Gala.Plugins.PIP.PopupWindow : Clutter.Actor { show (); } - previous_focus = focus_window; }