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
=== modified file 'include/core/screen.h'
--- include/core/screen.h 2012-12-03 10:36:42 +0000
+++ include/core/screen.h 2014-12-19 09:10:51 +0000
@@ -417,6 +417,7 @@
417 virtual void setNextActiveWindow(Window id) = 0;417 virtual void setNextActiveWindow(Window id) = 0;
418 virtual Window getNextActiveWindow() const = 0;418 virtual Window getNextActiveWindow() const = 0;
419 virtual CompWindow * focusTopMostWindow () = 0;419 virtual CompWindow * focusTopMostWindow () = 0;
420 virtual void saveViewportFocus (const CompPoint& vp, Window id) = 0;
420 // End of "internal use only" functions421 // End of "internal use only" functions
421422
422protected:423protected:
423424
=== modified file 'metadata/core.xml.in'
--- metadata/core.xml.in 2014-12-02 19:37:10 +0000
+++ metadata/core.xml.in 2014-12-19 09:10:51 +0000
@@ -141,6 +141,11 @@
141 <_long>Focus prevention windows</_long>141 <_long>Focus prevention windows</_long>
142 <default>any</default>142 <default>any</default>
143 </option>143 </option>
144 <option type="bool" name="remember_vp_focus">
145 <_short>Remember Focus</_short>
146 <_long>Remember Focus Per Workspace</_long>
147 <default>true</default>
148 </option>
144 </group>149 </group>
145 <group>150 <group>
146 <_short>Key bindings</_short>151 <_short>Key bindings</_short>
147152
=== modified file 'src/privatescreen.h'
--- src/privatescreen.h 2014-12-02 19:37:10 +0000
+++ src/privatescreen.h 2014-12-19 09:10:51 +0000
@@ -47,6 +47,7 @@
4747
48#include "core_options.h"48#include "core_options.h"
4949
50#include <map>
50#include <set>51#include <set>
5152
52CompPlugin::VTable * getCoreVTable ();53CompPlugin::VTable * getCoreVTable ();
@@ -89,6 +90,17 @@
89 unsigned int viewportY;90 unsigned int viewportY;
90};91};
9192
93// to allow using CompPoint as std::map keys
94struct PointCompare
95{
96 bool operator () (const CompPoint& p1, const CompPoint& p2)
97 {
98 if (p1.x () == p2.x ())
99 return p1.y () < p2.y ();
100 return p1.x () < p2.x ();
101 }
102};
103
92namespace compiz104namespace compiz
93{105{
94namespace core106namespace core
@@ -1071,6 +1083,7 @@
1071 virtual void setNextActiveWindow(Window id);1083 virtual void setNextActiveWindow(Window id);
1072 virtual Window getNextActiveWindow() const;1084 virtual Window getNextActiveWindow() const;
1073 virtual CompWindow * focusTopMostWindow ();1085 virtual CompWindow * focusTopMostWindow ();
1086 virtual void saveViewportFocus (const CompPoint& vp, Window id);
10741087
1075 public :1088 public :
10761089
@@ -1165,6 +1178,8 @@
11651178
1166 bool handlePingTimeout();1179 bool handlePingTimeout();
11671180
1181 CompWindow * findViewportFocusCandidate ();
1182
1168 Window below;1183 Window below;
1169 CompTimer autoRaiseTimer_;1184 CompTimer autoRaiseTimer_;
1170 Window autoRaiseWindow_;1185 Window autoRaiseWindow_;
@@ -1175,6 +1190,8 @@
1175 PrivateScreen privateScreen;1190 PrivateScreen privateScreen;
1176 compiz::private_screen::WindowManager windowManager;1191 compiz::private_screen::WindowManager windowManager;
1177 unsigned int showingDesktopMask_;1192 unsigned int showingDesktopMask_;
1193 typedef std::map<CompPoint, Window, PointCompare> FocusMap;
1194 FocusMap savedViewportFocus;
1178};1195};
11791196
1180#endif1197#endif
11811198
=== modified file 'src/screen.cpp'
--- src/screen.cpp 2014-12-02 19:37:10 +0000
+++ src/screen.cpp 2014-12-19 09:10:51 +0000
@@ -2688,6 +2688,11 @@
2688 }2688 }
2689 }2689 }
2690 }2690 }
2691 else
2692 {
2693 // check if there was a focused window stored
2694 focus = findViewportFocusCandidate ();
2695 }
26912696
2692 if (!focus)2697 if (!focus)
2693 {2698 {
@@ -3784,6 +3789,8 @@
3784 if (!tx && !ty)3789 if (!tx && !ty)
3785 return;3790 return;
37863791
3792 saveViewportFocus (privateScreen.viewPort.vp, activeWindow ());
3793
3787 privateScreen.viewPort.vp.setX (privateScreen.viewPort.vp.x () + tx);3794 privateScreen.viewPort.vp.setX (privateScreen.viewPort.vp.x () + tx);
3788 privateScreen.viewPort.vp.setY (privateScreen.viewPort.vp.y () + ty);3795 privateScreen.viewPort.vp.setY (privateScreen.viewPort.vp.y () + ty);
37893796
@@ -5155,6 +5162,41 @@
5155 return true;5162 return true;
5156}5163}
51575164
5165void
5166CompScreenImpl::saveViewportFocus (const CompPoint& vp, Window id)
5167{
5168 if (privateScreen.optionGetRememberVpFocus () &&
5169 (privateScreen.optionGetHsize () * privateScreen.optionGetVsize () > 1))
5170 {
5171 if (id != None)
5172 {
5173 savedViewportFocus[vp] = id;
5174 }
5175 }
5176}
5177
5178CompWindow *
5179CompScreenImpl::findViewportFocusCandidate ()
5180{
5181 if (privateScreen.optionGetRememberVpFocus () &&
5182 (privateScreen.optionGetHsize () * privateScreen.optionGetVsize () > 1))
5183 {
5184 FocusMap::iterator it = savedViewportFocus.find (privateScreen.viewPort.vp);
5185 if (it != savedViewportFocus.end ())
5186 {
5187 Window id = it->second;
5188 CompWindow *const w = findWindow (id);
5189 savedViewportFocus.erase (it);
5190
5191 if (w->defaultViewport () != privateScreen.viewPort.vp)
5192 return NULL;
5193
5194 return findWindow (id);
5195 }
5196 }
5197 return NULL;
5198}
5199
5158CompScreenImpl::~CompScreenImpl ()5200CompScreenImpl::~CompScreenImpl ()
5159{5201{
5160 privateScreen.startupSequence.removeAllSequences ();5202 privateScreen.startupSequence.removeAllSequences ();
51615203
=== modified file 'src/window.cpp'
--- src/window.cpp 2014-09-16 19:37:23 +0000
+++ src/window.cpp 2014-12-19 09:10:51 +0000
@@ -4484,6 +4484,7 @@
4484 priv->ensureWindowVisibility ();4484 priv->ensureWindowVisibility ();
4485 updateAttributes (CompStackingUpdateModeAboveFullscreen);4485 updateAttributes (CompStackingUpdateModeAboveFullscreen);
4486 moveInputFocusTo ();4486 moveInputFocusTo ();
4487 screen->saveViewportFocus (defaultViewport (), id ());
4487}4488}
44884489
4489#define PVertResizeInc (1 << 0)4490#define PVertResizeInc (1 << 0)

Subscribers

People subscribed via source and target branches