Merge lp:~dgadomski/compiz/remember-focus-improved into lp:compiz/0.9.12

Proposed by Dariusz Gadomski
Status: Superseded
Proposed branch: lp:~dgadomski/compiz/remember-focus-improved
Merge into: lp:compiz/0.9.12
Diff against target: 162 lines (+66/-0)
5 files modified
include/core/screen.h (+1/-0)
metadata/core.xml.in (+5/-0)
src/privatescreen.h (+17/-0)
src/screen.cpp (+42/-0)
src/window.cpp (+1/-0)
To merge this branch: bzr merge lp:~dgadomski/compiz/remember-focus-improved
Reviewer Review Type Date Requested Status
Christopher Townsend Needs Fixing
Brandon Schaefer Pending
Marco Trevisan (TreviƱo) Pending
Compiz Maintainers Pending
Review via email: mp+244855@code.launchpad.net

This proposal has been superseded by a proposal from 2014-12-19.

Description of the change

Adds handling for the unity launcher initiated focusing. In CompWindow::activate() call the window id is cached for the appropriate viewport.

Additionally I have included Brandon's fix for LP: #1398512.

Fixes: LP: #1393020, LP: #1398512.

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

Please rebase to what's in lp:compiz now as there are 2 text conflicts when merging your branch. Once done, we'll continue reviewing.

review: Needs Fixing
Revision history for this message
Christopher Townsend (townsend) wrote :

Also, I'm targeting bug #1125442 instead of the other two because those other two were fixed in reverting the original fix and this MP still fixes the original bug without (hopefully) causing any regressions.

3918. By Dariusz Gadomski

CompScreen: Save focused window id before changing viewport.

This allows to restore focus after returning to one of the previous viewport positions.
Introduces a new setting (General Options / Focus & Raise Behaviour / Remember Focus)
Fixes: LP #1125442

3919. By Dariusz Gadomski

CompScreen: Fix "Remember Focus" interaction with Unity launcher.

Adds an additional Window caching on explicit window activation.

Fixes: 1393020

3920. By Brandon Schaefer

When you move through a workspace, it ends up saving the ActiveWindow() under
that workspace. This is incorrect, since that window doesn't belong to that
workspace.

The fix, is simple to double check a window belong to the workspace we are
attempting to restore focus to.

Fixes: 1398512

Unmerged revisions

3920. By Brandon Schaefer

When you move through a workspace, it ends up saving the ActiveWindow() under
that workspace. This is incorrect, since that window doesn't belong to that
workspace.

The fix, is simple to double check a window belong to the workspace we are
attempting to restore focus to.

Fixes: 1398512

3919. By Dariusz Gadomski

CompScreen: Fix "Remember Focus" interaction with Unity launcher.

Adds an additional Window caching on explicit window activation.

Fixes: 1393020

3918. By Dariusz Gadomski

CompScreen: Save focused window id before changing viewport.

This allows to restore focus after returning to one of the previous viewport positions.
Introduces a new setting (General Options / Focus & Raise Behaviour / Remember Focus)
Fixes: LP #1125442

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/screen.h'
2--- include/core/screen.h 2012-12-03 10:36:42 +0000
3+++ include/core/screen.h 2014-12-19 09:10:51 +0000
4@@ -417,6 +417,7 @@
5 virtual void setNextActiveWindow(Window id) = 0;
6 virtual Window getNextActiveWindow() const = 0;
7 virtual CompWindow * focusTopMostWindow () = 0;
8+ virtual void saveViewportFocus (const CompPoint& vp, Window id) = 0;
9 // End of "internal use only" functions
10
11 protected:
12
13=== modified file 'metadata/core.xml.in'
14--- metadata/core.xml.in 2014-12-02 19:37:10 +0000
15+++ metadata/core.xml.in 2014-12-19 09:10:51 +0000
16@@ -141,6 +141,11 @@
17 <_long>Focus prevention windows</_long>
18 <default>any</default>
19 </option>
20+ <option type="bool" name="remember_vp_focus">
21+ <_short>Remember Focus</_short>
22+ <_long>Remember Focus Per Workspace</_long>
23+ <default>true</default>
24+ </option>
25 </group>
26 <group>
27 <_short>Key bindings</_short>
28
29=== modified file 'src/privatescreen.h'
30--- src/privatescreen.h 2014-12-02 19:37:10 +0000
31+++ src/privatescreen.h 2014-12-19 09:10:51 +0000
32@@ -47,6 +47,7 @@
33
34 #include "core_options.h"
35
36+#include <map>
37 #include <set>
38
39 CompPlugin::VTable * getCoreVTable ();
40@@ -89,6 +90,17 @@
41 unsigned int viewportY;
42 };
43
44+// to allow using CompPoint as std::map keys
45+struct PointCompare
46+{
47+ bool operator () (const CompPoint& p1, const CompPoint& p2)
48+ {
49+ if (p1.x () == p2.x ())
50+ return p1.y () < p2.y ();
51+ return p1.x () < p2.x ();
52+ }
53+};
54+
55 namespace compiz
56 {
57 namespace core
58@@ -1071,6 +1083,7 @@
59 virtual void setNextActiveWindow(Window id);
60 virtual Window getNextActiveWindow() const;
61 virtual CompWindow * focusTopMostWindow ();
62+ virtual void saveViewportFocus (const CompPoint& vp, Window id);
63
64 public :
65
66@@ -1165,6 +1178,8 @@
67
68 bool handlePingTimeout();
69
70+ CompWindow * findViewportFocusCandidate ();
71+
72 Window below;
73 CompTimer autoRaiseTimer_;
74 Window autoRaiseWindow_;
75@@ -1175,6 +1190,8 @@
76 PrivateScreen privateScreen;
77 compiz::private_screen::WindowManager windowManager;
78 unsigned int showingDesktopMask_;
79+ typedef std::map<CompPoint, Window, PointCompare> FocusMap;
80+ FocusMap savedViewportFocus;
81 };
82
83 #endif
84
85=== modified file 'src/screen.cpp'
86--- src/screen.cpp 2014-12-02 19:37:10 +0000
87+++ src/screen.cpp 2014-12-19 09:10:51 +0000
88@@ -2688,6 +2688,11 @@
89 }
90 }
91 }
92+ else
93+ {
94+ // check if there was a focused window stored
95+ focus = findViewportFocusCandidate ();
96+ }
97
98 if (!focus)
99 {
100@@ -3784,6 +3789,8 @@
101 if (!tx && !ty)
102 return;
103
104+ saveViewportFocus (privateScreen.viewPort.vp, activeWindow ());
105+
106 privateScreen.viewPort.vp.setX (privateScreen.viewPort.vp.x () + tx);
107 privateScreen.viewPort.vp.setY (privateScreen.viewPort.vp.y () + ty);
108
109@@ -5155,6 +5162,41 @@
110 return true;
111 }
112
113+void
114+CompScreenImpl::saveViewportFocus (const CompPoint& vp, Window id)
115+{
116+ if (privateScreen.optionGetRememberVpFocus () &&
117+ (privateScreen.optionGetHsize () * privateScreen.optionGetVsize () > 1))
118+ {
119+ if (id != None)
120+ {
121+ savedViewportFocus[vp] = id;
122+ }
123+ }
124+}
125+
126+CompWindow *
127+CompScreenImpl::findViewportFocusCandidate ()
128+{
129+ if (privateScreen.optionGetRememberVpFocus () &&
130+ (privateScreen.optionGetHsize () * privateScreen.optionGetVsize () > 1))
131+ {
132+ FocusMap::iterator it = savedViewportFocus.find (privateScreen.viewPort.vp);
133+ if (it != savedViewportFocus.end ())
134+ {
135+ Window id = it->second;
136+ CompWindow *const w = findWindow (id);
137+ savedViewportFocus.erase (it);
138+
139+ if (w->defaultViewport () != privateScreen.viewPort.vp)
140+ return NULL;
141+
142+ return findWindow (id);
143+ }
144+ }
145+ return NULL;
146+}
147+
148 CompScreenImpl::~CompScreenImpl ()
149 {
150 privateScreen.startupSequence.removeAllSequences ();
151
152=== modified file 'src/window.cpp'
153--- src/window.cpp 2014-09-16 19:37:23 +0000
154+++ src/window.cpp 2014-12-19 09:10:51 +0000
155@@ -4484,6 +4484,7 @@
156 priv->ensureWindowVisibility ();
157 updateAttributes (CompStackingUpdateModeAboveFullscreen);
158 moveInputFocusTo ();
159+ screen->saveViewportFocus (defaultViewport (), id ());
160 }
161
162 #define PVertResizeInc (1 << 0)

Subscribers

People subscribed via source and target branches