~lbrulet-8/compiz-plugins-main/fix-876591

« back to all changes in this revision

Viewing changes to debian/patches/fix-872161.patch

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2011-10-12 10:49:59 UTC
  • Revision ID: james.westby@ubuntu.com-20111012104959-sqqdj62grtdhz4ca
Tags: 1:0.9.6-0ubuntu4
* debian/patches/fix-872161.patch:
  - When grabbing a window to demaximize it after dragging it up,
    sometimes the position will not be where you expect it to be
    (LP: #872161)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
=== modified file 'src/snap.cpp'
 
2
Index: compiz-plugins-main-0.9.6/snap/src/snap.cpp
 
3
===================================================================
 
4
--- compiz-plugins-main-0.9.6.orig/snap/src/snap.cpp    2011-10-12 10:51:43.636001732 +0200
 
5
+++ compiz-plugins-main-0.9.6/snap/src/snap.cpp 2011-10-12 10:51:43.680001950 +0200
 
6
@@ -46,11 +46,14 @@
 
7
  * Wrapper functions to avoid infinite notify loops
 
8
  */
 
9
 void
 
10
-SnapWindow::move (int dx, int dy)
 
11
+SnapWindow::move (int dx, int dy, bool sync)
 
12
 {
 
13
     skipNotify = true;
 
14
     window->move (dx, dy, true);
 
15
-    screen->warpPointer (dx, dy);
 
16
+    /* warp the pointer in the case of
 
17
+     * snap release */
 
18
+    if (sync)
 
19
+       window->syncPosition ();
 
20
     skipNotify = false;
 
21
 }
 
22
 
 
23
@@ -406,16 +409,16 @@
 
24
            switch (type)
 
25
            {
 
26
            case LeftEdge:
 
27
-               move (min, 0);
 
28
+               move (min, 0, false);
 
29
                break;
 
30
            case RightEdge:
 
31
-               move (-min, 0);
 
32
+               move (-min, 0, false);
 
33
                break;
 
34
            case TopEdge:
 
35
-               move (0, min);
 
36
+               move (0, min, false);
 
37
                break;
 
38
            case BottomEdge:
 
39
-               move (0, -min);
 
40
+               move (0, -min, false);
 
41
                break;
 
42
            default:
 
43
                break;
 
44
@@ -428,17 +431,17 @@
 
45
  * Call the previous function for each of the 4 sides of the window
 
46
  */
 
47
 void
 
48
-SnapWindow::moveCheckEdges ()
 
49
+SnapWindow::moveCheckEdges (int snapDirection)
 
50
 {
 
51
     CompRect input (window->borderRect ());
 
52
     moveCheckNearestEdge (input.left (), input.top (), input.bottom (),
 
53
-                         true, RightEdge, HorizontalSnap);
 
54
+                         true, RightEdge, HorizontalSnap & snapDirection);
 
55
     moveCheckNearestEdge (input.right (), input.top (), input.bottom (),
 
56
-                         false, LeftEdge, HorizontalSnap);
 
57
+                         false, LeftEdge, HorizontalSnap & snapDirection);
 
58
     moveCheckNearestEdge (input.top (), input.left (), input.right (),
 
59
-                         true, BottomEdge, VerticalSnap);
 
60
+                         true, BottomEdge, VerticalSnap & snapDirection);
 
61
     moveCheckNearestEdge (input.bottom (), input.left (), input.right (),
 
62
-                         false, TopEdge, VerticalSnap);
 
63
+                         false, TopEdge, VerticalSnap & snapDirection);
 
64
 }
 
65
 
 
66
 // Edges checking functions (resize) -------------------------------------------
 
67
@@ -670,8 +673,29 @@
 
68
 }
 
69
 
 
70
 void
 
71
+SnapWindow::stateChangeNotify (unsigned int lastState)
 
72
+{
 
73
+    if (window->state () & CompWindowStateMaximizedHorzMask)
 
74
+    {
 
75
+       snapGeometry.setWidth (0);
 
76
+       snapGeometry.setX (0);
 
77
+       snapDirection &= VerticalSnap;
 
78
+    }
 
79
+
 
80
+    if (window->state () & CompWindowStateMaximizedVertMask)
 
81
+    {
 
82
+       snapGeometry.setHeight (0);
 
83
+       snapGeometry.setY (0);
 
84
+       snapDirection &= HorizontalSnap;
 
85
+    }
 
86
+
 
87
+    window->stateChangeNotify (lastState);
 
88
+}
 
89
+
 
90
+void
 
91
 SnapWindow::moveNotify (int dx, int dy, bool immediate)
 
92
 {
 
93
+    unsigned int allowedSnapDirection = VerticalSnap | HorizontalSnap;
 
94
     SNAP_SCREEN (screen);
 
95
 
 
96
     window->moveNotify (dx, dy, immediate);
 
97
@@ -683,22 +707,31 @@
 
98
     // we have to avoid snapping but there's still some buffered moving
 
99
     if (!ss->snapping && (m_dx || m_dy))
 
100
     {
 
101
-       move (m_dx, m_dy);
 
102
+       move (m_dx, m_dy, false);
 
103
        m_dx = m_dy = 0;
 
104
        return;
 
105
     }
 
106
 
 
107
     // don't snap maximized windows
 
108
     if (window->state () & CompWindowStateMaximizedHorzMask)
 
109
+    {
 
110
+       allowedSnapDirection &= ~(VerticalSnap);
 
111
        dx = 0;
 
112
+    }
 
113
 
 
114
     if (window->state () & CompWindowStateMaximizedVertMask)
 
115
+    {
 
116
+       allowedSnapDirection &= ~(HorizontalSnap);
 
117
        dy = 0;
 
118
+    }
 
119
 
 
120
     // avoiding snap, nothing buffered
 
121
     if (!ss->snapping)
 
122
        return;
 
123
 
 
124
+    dx = snapGeometry.x () - window->geometry ().x ();
 
125
+    dy = snapGeometry.y () - window->geometry ().y ();
 
126
+
 
127
     // apply edge resistance
 
128
     if (ss->optionGetSnapTypeMask () & SnapTypeEdgeResistanceMask)
 
129
     {
 
130
@@ -707,16 +740,15 @@
 
131
        // by buffered dx - dx
 
132
        if (!snapGeometry.isEmpty () && snapDirection & HorizontalSnap)
 
133
        {
 
134
-           m_dx += dx;
 
135
+           m_dx += -dx;
 
136
            if (m_dx < ss->optionGetResistanceDistance ()
 
137
                && m_dx > -ss->optionGetResistanceDistance ())
 
138
            {
 
139
-               dx = snapGeometry.x () - window->geometry ().x ();
 
140
-               move (dx, 0);
 
141
+               move (dx, 0, false);
 
142
            }
 
143
            else
 
144
            {
 
145
-               move (m_dx - dx, 0);
 
146
+               move (m_dx - dx, 0, true);
 
147
                m_dx = 0;
 
148
                snapDirection &= VerticalSnap;
 
149
            }
 
150
@@ -724,16 +756,15 @@
 
151
        // Same for vertical snapping and dy
 
152
        if (!snapGeometry.isEmpty () && snapDirection & VerticalSnap)
 
153
        {
 
154
-           m_dy += dy;
 
155
+           m_dy += -dy;
 
156
            if (m_dy < ss->optionGetResistanceDistance ()
 
157
                && m_dy > -ss->optionGetResistanceDistance ())
 
158
            {
 
159
-               dy = snapGeometry.y () - window->geometry ().y ();
 
160
-               move (0, dy);
 
161
+               move (0, dy, false);
 
162
            }
 
163
            else
 
164
            {
 
165
-               move (0, m_dy - dy);
 
166
+               move (0, m_dy - dy, true);
 
167
                m_dy = 0;
 
168
                snapDirection &= HorizontalSnap;
 
169
            }
 
170
@@ -745,7 +776,7 @@
 
171
     // If we don't already snap vertically and horizontally,
 
172
     // check edges status
 
173
     if (snapDirection != (VerticalSnap | HorizontalSnap))
 
174
-       moveCheckEdges ();
 
175
+       moveCheckEdges (allowedSnapDirection);
 
176
 }
 
177
 
 
178
 /*
 
179
Index: compiz-plugins-main-0.9.6/snap/src/snap.h
 
180
===================================================================
 
181
--- compiz-plugins-main-0.9.6.orig/snap/src/snap.h      2011-10-12 10:51:43.528001206 +0200
 
182
+++ compiz-plugins-main-0.9.6/snap/src/snap.h   2011-10-12 10:51:43.680001950 +0200
 
183
@@ -109,6 +109,7 @@
 
184
        void resizeNotify (int dx, int dy, int dwidth, int dheight);
 
185
        void moveNotify (int dx, int dy, bool immediate);
 
186
        void grabNotify (int x, int y, unsigned int state, unsigned int mask);
 
187
+       void stateChangeNotify (unsigned int lastState);
 
188
        void ungrabNotify ();
 
189
 
 
190
     private:
 
191
@@ -134,7 +135,7 @@
 
192
        bool skipNotify;
 
193
 
 
194
 
 
195
-       void move (int dx, int dy);
 
196
+       void move (int dx, int dy, bool sync);
 
197
        void resize (int dx, int dy, int dwidth, int dheight);
 
198
 
 
199
        void addEdge (Window id, int position, int start, int end,
 
200
@@ -146,7 +147,7 @@
 
201
        void moveCheckNearestEdge (int position, int start, int end,
 
202
                                   bool before, EdgeType type,
 
203
                                   int snapDirection);
 
204
-       void moveCheckEdges ();
 
205
+       void moveCheckEdges (int snapDirection);
 
206
        void resizeCheckNearestEdge (int position, int start, int end,
 
207
                                     bool before, EdgeType type,
 
208
                                     int snapDirection);