Merge lp:~3v1n0/compiz/scale-tab-iteration into lp:compiz/0.9.12

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: 4014
Merged at revision: 4015
Proposed branch: lp:~3v1n0/compiz/scale-tab-iteration
Merge into: lp:compiz/0.9.12
Prerequisite: lp:~3v1n0/compiz/scale-selection-keyboard+mouse-fix
Diff against target: 174 lines (+82/-18)
2 files modified
plugins/scale/src/privates.h (+2/-2)
plugins/scale/src/scale.cpp (+80/-16)
To merge this branch: bzr merge lp:~3v1n0/compiz/scale-tab-iteration
Reviewer Review Type Date Requested Status
Andrea Azzarone Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+292977@code.launchpad.net

Commit message

Scale: allow to iterate through windows using Tab key

To post a comment you must log in.
lp:~3v1n0/compiz/scale-tab-iteration updated
4013. By Marco Trevisan (Treviño)

Scale: allow closing selected window with Ctrl+W

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~3v1n0/compiz/scale-tab-iteration updated
4014. By Marco Trevisan (Treviño)

Scale: take care only about the half of the maximum tumbs height

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/scale/src/privates.h'
2--- plugins/scale/src/privates.h 2014-04-17 16:00:05 +0000
3+++ plugins/scale/src/privates.h 2016-04-27 09:54:19 +0000
4@@ -94,7 +94,9 @@
5 bool selectWindowAt (int x, int y, bool moveInputFocus);
6 bool selectWindowAt (int x, int y);
7
8+ void moveFocusWindow (CompWindow *);
9 void moveFocusWindow (int dx, int dy);
10+ void moveFocusWindow (int distance);
11
12 void windowRemove (CompWindow *);
13
14@@ -117,8 +119,6 @@
15 Window hoveredWindow;
16 Window previousActiveWindow;
17
18- KeyCode leftKeyCode, rightKeyCode, upKeyCode, downKeyCode;
19-
20 bool grab;
21 CompScreen::GrabHandle grabIndex;
22
23
24=== modified file 'plugins/scale/src/scale.cpp'
25--- plugins/scale/src/scale.cpp 2016-04-27 09:54:19 +0000
26+++ plugins/scale/src/scale.cpp 2016-04-27 09:54:19 +0000
27@@ -1528,6 +1528,60 @@
28 }
29
30 void
31+PrivateScaleScreen::moveFocusWindow (int distance)
32+{
33+ CompWindow *selected;
34+ CompWindow *next;
35+
36+ next = NULL;
37+ selected = screen->findWindow (selectedWindow ? selectedWindow : screen->activeWindow ());
38+ auto scaledWindows = windows;
39+
40+ /* Sort windows to respect the natural grid view */
41+ scaledWindows.sort ([] (ScaleWindow *sw1, ScaleWindow *sw2) {
42+ if (!sw1->priv->slot)
43+ return !sw2->priv->slot;
44+ if (!sw2->priv->slot)
45+ return true;
46+
47+ int cy1 = (sw1->priv->slot->y1 () + sw1->priv->slot->y2 ()) / 2;
48+ int cy2 = (sw2->priv->slot->y1 () + sw2->priv->slot->y2 ()) / 2;
49+
50+ if (abs (cy1 - cy2) < std::max (sw1->priv->slot->height (), sw2->priv->slot->height ()) / 2)
51+ {
52+ int cx1 = (sw1->priv->slot->x1 () + sw1->priv->slot->x2 ()) / 2;
53+ int cx2 = (sw2->priv->slot->x1 () + sw2->priv->slot->x2 ()) / 2;
54+ return cx1 < cx2;
55+ }
56+
57+ return cy1 < cy2;
58+ });
59+
60+ if (selected && !scaledWindows.empty())
61+ {
62+ SCALE_WINDOW (selected);
63+ auto selected_it = std::find (scaledWindows.begin (), scaledWindows.end (), sw);
64+
65+ if (selected_it != scaledWindows.end ())
66+ {
67+ std::advance (selected_it, distance);
68+
69+ if (selected_it == scaledWindows.end ())
70+ {
71+ if (distance > 0)
72+ selected_it = scaledWindows.begin ();
73+ else if (distance < 0)
74+ selected_it = std::prev (scaledWindows.end ());
75+ }
76+
77+ next = (*selected_it)->window;
78+ }
79+ }
80+
81+ moveFocusWindow (next);
82+}
83+
84+void
85 PrivateScaleScreen::moveFocusWindow (int dx,
86 int dy)
87 {
88@@ -1547,9 +1601,9 @@
89 cx = (sw->priv->slot->x1 () + sw->priv->slot->x2 ()) / 2;
90 cy = (sw->priv->slot->y1 () + sw->priv->slot->y2 ()) / 2;
91
92- foreach (CompWindow *w, screen->windows ())
93+ foreach (ScaleWindow *w, windows)
94 {
95- slot = ScaleWindow::get (w)->priv->slot;
96+ slot = w->priv->slot;
97 if (!slot)
98 continue;
99
100@@ -1566,23 +1620,29 @@
101 continue;
102
103 min = d;
104- focus = w;
105+ focus = w->window;
106 }
107 }
108 }
109 }
110
111+ moveFocusWindow (focus);
112+}
113+
114+void
115+PrivateScaleScreen::moveFocusWindow (CompWindow *focus)
116+{
117 /* move focus to the last focused window if no slot window is currently
118 focused */
119 if (!focus)
120 {
121- foreach (CompWindow *w, screen->windows ())
122+ foreach (ScaleWindow *sw, windows)
123 {
124- if (!ScaleWindow::get (w)->priv->slot)
125+ if (!sw->priv->slot)
126 continue;
127
128- if (!focus || focus->activeNum () < w->activeNum ())
129- focus = w;
130+ if (!focus || focus->activeNum () < sw->window->activeNum ())
131+ focus = sw->window;
132 }
133 }
134
135@@ -1719,14 +1779,23 @@
136 {
137 if (grabIndex)
138 {
139- if (event->xkey.keycode == leftKeyCode)
140+ KeySym keySym = XkbKeycodeToKeysym (event->xany.display,
141+ event->xkey.keycode, 0, 0);
142+ if (keySym == XK_Left)
143 moveFocusWindow (-1, 0);
144- else if (event->xkey.keycode == rightKeyCode)
145+ else if (keySym == XK_Right)
146 moveFocusWindow (1, 0);
147- else if (event->xkey.keycode == upKeyCode)
148+ else if (keySym == XK_Up)
149 moveFocusWindow (0, -1);
150- else if (event->xkey.keycode == downKeyCode)
151+ else if (keySym == XK_Down)
152 moveFocusWindow (0, 1);
153+ else if (keySym == XK_Tab)
154+ moveFocusWindow (!(event->xkey.state & ShiftMask) ? 1 : -1);
155+ else if (keySym == XK_w && (event->xkey.state & ControlMask))
156+ {
157+ if (CompWindow *selected = screen->findWindow (selectedWindow))
158+ selected->close (0);
159+ }
160 }
161 }
162 break;
163@@ -1962,11 +2031,6 @@
164 moreAdjust (false),
165 nSlots (0)
166 {
167- leftKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Left"));
168- rightKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Right"));
169- upKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Up"));
170- downKeyCode = XKeysymToKeycode (screen->dpy (), XStringToKeysym ("Down"));
171-
172 opacity = (OPAQUE * optionGetOpacity ()) / 100;
173
174 hover.setCallback (boost::bind (&PrivateScaleScreen::hoverTimeout, this));

Subscribers

People subscribed via source and target branches