Merge lp:~focus-follows-mouse/ubuntu/precise/compiz/fix-883383 into lp:ubuntu/precise/compiz

Proposed by James Pharaoh
Status: Work in progress
Proposed branch: lp:~focus-follows-mouse/ubuntu/precise/compiz/fix-883383
Merge into: lp:ubuntu/precise/compiz
Diff against target: 4406 lines (+4227/-2)
19 files modified
.pc/.quilt_patches (+1/-0)
.pc/.quilt_series (+1/-0)
.pc/applied-patches (+2/-0)
.pc/fix-881329.patch/plugins/move/src/move.cpp (+756/-0)
.pc/fix-881329.patch/plugins/move/src/move.h (+135/-0)
.pc/fix-883383.patch/unity/unity_window_decorator/src/events.c (+1146/-0)
.pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.c (+443/-0)
.pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.h (+1009/-0)
.pc/fix-883383.patch/unity/unity_window_decorator/src/settings.c (+567/-0)
debian/changelog (+9/-0)
debian/patches/fix-881329.patch (+49/-0)
debian/patches/fix-883383.patch (+77/-0)
debian/patches/series (+2/-0)
plugins/move/src/move.cpp (+10/-1)
plugins/move/src/move.h (+2/-0)
unity/unity_window_decorator/src/events.c (+2/-1)
unity/unity_window_decorator/src/gtk-window-decorator.c (+2/-0)
unity/unity_window_decorator/src/gtk-window-decorator.h (+5/-0)
unity/unity_window_decorator/src/settings.c (+9/-0)
To merge this branch: bzr merge lp:~focus-follows-mouse/ubuntu/precise/compiz/fix-883383
Reviewer Review Type Date Requested Status
Sam Spilsbury Pending
Ubuntu branches Pending
Review via email: mp+80727@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi.

I'm assuming that his is the same thing as https://code.launchpad.net/~jamespharaoh/ubuntu/precise/compiz/fix-881329/+merge/80314

Could you propose this against lp:compiz-core? This is the packaging branch.

Revision history for this message
Stéphane Graber (stgraber) wrote :

Based on comment above, marking work in progress.

Unmerged revisions

254. By James Pharaoh

* debian/patches/fix-883383.patch:
  - Drag title bar should not raise if raise-on-click is disabled (LP: #883383)

253. By James Pharaoh

* debian/patches/fix-881329.patch:
  - Alt+click should raise with raise-on-click disabled (LP: #881329)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.pc/.quilt_patches'
--- .pc/.quilt_patches 1970-01-01 00:00:00 +0000
+++ .pc/.quilt_patches 2011-10-29 09:07:25 +0000
@@ -0,0 +1,1 @@
1debian/patches
02
=== added file '.pc/.quilt_series'
--- .pc/.quilt_series 1970-01-01 00:00:00 +0000
+++ .pc/.quilt_series 2011-10-29 09:07:25 +0000
@@ -0,0 +1,1 @@
1series
02
=== modified file '.pc/applied-patches'
--- .pc/applied-patches 2011-10-12 10:44:49 +0000
+++ .pc/applied-patches 2011-10-29 09:07:25 +0000
@@ -12,3 +12,5 @@
12fix-832150.patch12fix-832150.patch
13fix-864478.patch13fix-864478.patch
14fix-864330.patch14fix-864330.patch
15fix-881329.patch
16fix-883383.patch
1517
=== added directory '.pc/fix-881329.patch'
=== added file '.pc/fix-881329.patch/.timestamp'
=== added directory '.pc/fix-881329.patch/plugins'
=== added directory '.pc/fix-881329.patch/plugins/move'
=== added directory '.pc/fix-881329.patch/plugins/move/src'
=== added file '.pc/fix-881329.patch/plugins/move/src/move.cpp'
--- .pc/fix-881329.patch/plugins/move/src/move.cpp 1970-01-01 00:00:00 +0000
+++ .pc/fix-881329.patch/plugins/move/src/move.cpp 2011-10-29 09:07:25 +0000
@@ -0,0 +1,756 @@
1/*
2 * Copyright © 2005 Novell, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Novell, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Novell, Inc. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Author: David Reveman <davidr@novell.com>
24 */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29
30#include <X11/cursorfont.h>
31
32#include <core/atoms.h>
33#include "move.h"
34
35COMPIZ_PLUGIN_20090315 (move, MovePluginVTable)
36
37static bool
38moveInitiate (CompAction *action,
39 CompAction::State state,
40 CompOption::Vector &options)
41{
42 CompWindow *w;
43 Window xid;
44
45 MOVE_SCREEN (screen);
46
47 xid = CompOption::getIntOptionNamed (options, "window");
48
49 w = screen->findWindow (xid);
50 if (w && (w->actions () & CompWindowActionMoveMask))
51 {
52 CompRect workArea;
53 unsigned int mods;
54 int x, y, button;
55 bool sourceExternalApp;
56
57 CompScreen *s = screen;
58
59 mods = CompOption::getIntOptionNamed (options, "modifiers", 0);
60
61 x = CompOption::getIntOptionNamed (options, "x", w->geometry ().x () +
62 (w->size ().width () / 2));
63 y = CompOption::getIntOptionNamed (options, "y", w->geometry ().y () +
64 (w->size ().height () / 2));
65
66 button = CompOption::getIntOptionNamed (options, "button", -1);
67
68 if (s->otherGrabExist ("move", NULL))
69 return false;
70
71 if (ms->w)
72 return false;
73
74 if (w->type () & (CompWindowTypeDesktopMask |
75 CompWindowTypeDockMask |
76 CompWindowTypeFullscreenMask))
77 return false;
78
79 if (w->overrideRedirect ())
80 return false;
81
82 if (state & CompAction::StateInitButton)
83 action->setState (action->state () | CompAction::StateTermButton);
84
85 if (ms->region)
86 {
87 XDestroyRegion (ms->region);
88 ms->region = NULL;
89 }
90
91 ms->status = RectangleOut;
92
93 ms->savedX = w->serverGeometry ().x ();
94 ms->savedY = w->serverGeometry ().y ();
95
96 ms->x = 0;
97 ms->y = 0;
98
99 lastPointerX = x;
100 lastPointerY = y;
101
102 sourceExternalApp =
103 CompOption::getBoolOptionNamed (options, "external", false);
104 ms->yConstrained = sourceExternalApp && ms->optionGetConstrainY ();
105
106 ms->origState = w->state ();
107
108 workArea = s->getWorkareaForOutput (w->outputDevice ());
109
110 ms->snapBackY = w->serverGeometry ().y () - workArea.y ();
111 ms->snapOffY = y - workArea.y ();
112
113 if (!ms->grab)
114 ms->grab = s->pushGrab (ms->moveCursor, "move");
115
116 if (ms->grab)
117 {
118 unsigned int grabMask = CompWindowGrabMoveMask |
119 CompWindowGrabButtonMask;
120
121 if (sourceExternalApp)
122 grabMask |= CompWindowGrabExternalAppMask;
123
124 ms->w = w;
125
126 ms->releaseButton = button;
127
128 w->grabNotify (x, y, mods, grabMask);
129
130 /* Click raise happens implicitly on buttons 1, 2 and 3 so don't
131 * restack this window again if the action buttonbinding was from
132 * one of those buttons */
133 if (screen->getOption ("raise_on_click")->value ().b () &&
134 button != Button1 && button != Button2 && button != Button3)
135 w->updateAttributes (CompStackingUpdateModeAboveFullscreen);
136
137 if (state & CompAction::StateInitKey)
138 {
139 int xRoot, yRoot;
140
141 xRoot = w->geometry ().x () + (w->size ().width () / 2);
142 yRoot = w->geometry ().y () + (w->size ().height () / 2);
143
144 s->warpPointer (xRoot - pointerX, yRoot - pointerY);
145 }
146
147 if (ms->moveOpacity != OPAQUE)
148 {
149 MOVE_WINDOW (w);
150
151 if (mw->cWindow)
152 mw->cWindow->addDamage ();
153 if (mw->gWindow)
154 mw->gWindow->glPaintSetEnabled (mw, true);
155 }
156 }
157 }
158
159 return false;
160}
161
162static bool
163moveTerminate (CompAction *action,
164 CompAction::State state,
165 CompOption::Vector &options)
166{
167 MOVE_SCREEN (screen);
168
169 if (ms->w)
170 {
171 if (state & CompAction::StateCancel)
172 ms->w->move (ms->savedX - ms->w->geometry ().x (),
173 ms->savedY - ms->w->geometry ().y (), false);
174
175 ms->w->syncPosition ();
176
177 /* update window attributes as window constraints may have
178 changed - needed e.g. if a maximized window was moved
179 to another output device */
180 ms->w->updateAttributes (CompStackingUpdateModeNone);
181
182 ms->w->ungrabNotify ();
183
184 if (ms->grab)
185 {
186 screen->removeGrab (ms->grab, NULL);
187 ms->grab = NULL;
188 }
189
190 if (ms->moveOpacity != OPAQUE)
191 {
192 MOVE_WINDOW (ms->w);
193
194 if (mw->cWindow)
195 mw->cWindow->addDamage ();
196 if (mw->gWindow)
197 mw->gWindow->glPaintSetEnabled (mw, false);
198 }
199
200 ms->w = 0;
201 ms->releaseButton = 0;
202 }
203
204 action->setState (action->state () & ~(CompAction::StateTermKey |
205 CompAction::StateTermButton));
206
207 return false;
208}
209
210/* creates a region containing top and bottom struts. only struts that are
211 outside the screen workarea are considered. */
212static Region
213moveGetYConstrainRegion (CompScreen *s)
214{
215 CompWindow *w;
216 Region region;
217 REGION r;
218 CompRect workArea;
219 BoxRec extents;
220 unsigned int i;
221
222 region = XCreateRegion ();
223 if (!region)
224 return NULL;
225
226 r.rects = &r.extents;
227 r.numRects = r.size = 1;
228
229 r.extents.x1 = MINSHORT;
230 r.extents.y1 = 0;
231 r.extents.x2 = 0;
232 r.extents.y2 = s->height ();
233
234 XUnionRegion (&r, region, region);
235
236 r.extents.x1 = s->width ();
237 r.extents.x2 = MAXSHORT;
238
239 XUnionRegion (&r, region, region);
240
241 for (i = 0; i < s->outputDevs ().size (); i++)
242 {
243 XUnionRegion (s->outputDevs ()[i].region (), region, region);
244
245 workArea = s->getWorkareaForOutput (i);
246 extents = s->outputDevs ()[i].region ()->extents;
247
248 foreach (w, s->windows ())
249 {
250 if (!w->mapNum ())
251 continue;
252
253 if (w->struts ())
254 {
255 r.extents.x1 = w->struts ()->top.x;
256 r.extents.y1 = w->struts ()->top.y;
257 r.extents.x2 = r.extents.x1 + w->struts ()->top.width;
258 r.extents.y2 = r.extents.y1 + w->struts ()->top.height;
259
260 if (r.extents.x1 < extents.x1)
261 r.extents.x1 = extents.x1;
262 if (r.extents.x2 > extents.x2)
263 r.extents.x2 = extents.x2;
264 if (r.extents.y1 < extents.y1)
265 r.extents.y1 = extents.y1;
266 if (r.extents.y2 > extents.y2)
267 r.extents.y2 = extents.y2;
268
269 if (r.extents.x1 < r.extents.x2 && r.extents.y1 < r.extents.y2)
270 {
271 if (r.extents.y2 <= workArea.y ())
272 XSubtractRegion (region, &r, region);
273 }
274
275 r.extents.x1 = w->struts ()->bottom.x;
276 r.extents.y1 = w->struts ()->bottom.y;
277 r.extents.x2 = r.extents.x1 + w->struts ()->bottom.width;
278 r.extents.y2 = r.extents.y1 + w->struts ()->bottom.height;
279
280 if (r.extents.x1 < extents.x1)
281 r.extents.x1 = extents.x1;
282 if (r.extents.x2 > extents.x2)
283 r.extents.x2 = extents.x2;
284 if (r.extents.y1 < extents.y1)
285 r.extents.y1 = extents.y1;
286 if (r.extents.y2 > extents.y2)
287 r.extents.y2 = extents.y2;
288
289 if (r.extents.x1 < r.extents.x2 && r.extents.y1 < r.extents.y2)
290 {
291 if (r.extents.y1 >= workArea.bottom ())
292 XSubtractRegion (region, &r, region);
293 }
294 }
295 }
296 }
297
298 return region;
299}
300
301static void
302moveHandleMotionEvent (CompScreen *s,
303 int xRoot,
304 int yRoot)
305{
306 MOVE_SCREEN (s);
307
308 if (ms->grab)
309 {
310 int dx, dy;
311 int wX, wY;
312 int wWidth, wHeight;
313 CompWindow *w;
314
315 w = ms->w;
316
317 wX = w->geometry ().x ();
318 wY = w->geometry ().y ();
319 wWidth = w->geometry ().width () +
320 w->geometry ().border () * 2;
321 wHeight = w->geometry ().height () +
322 w->geometry ().border () * 2;
323
324 ms->x += xRoot - lastPointerX;
325 ms->y += yRoot - lastPointerY;
326
327 if (w->type () & CompWindowTypeFullscreenMask)
328 {
329 dx = dy = 0;
330 }
331 else
332 {
333 CompRect workArea;
334 int min, max;
335
336 dx = ms->x;
337 dy = ms->y;
338
339 workArea = s->getWorkareaForOutput (w->outputDevice ());
340
341 if (ms->yConstrained)
342 {
343 if (!ms->region)
344 ms->region = moveGetYConstrainRegion (s);
345
346 /* make sure that the top border extents or the top row of
347 pixels are within what is currently our valid screen
348 region */
349 if (ms->region)
350 {
351 int x, y, width, height;
352 int status;
353
354 x = wX + dx - w->border ().left;
355 y = wY + dy - w->border ().top;
356 width = wWidth + w->border ().left + w->border ().right;
357 height = w->border ().top ? w->border ().top : 1;
358
359 status = XRectInRegion (ms->region, x, y,
360 (unsigned int) width,
361 (unsigned int) height);
362
363 /* only constrain movement if previous position was valid */
364 if (ms->status == RectangleIn)
365 {
366 int xStatus = status;
367
368 while (dx && xStatus != RectangleIn)
369 {
370 xStatus = XRectInRegion (ms->region,
371 x, y - dy,
372 (unsigned int) width,
373 (unsigned int) height);
374
375 if (xStatus != RectangleIn)
376 dx += (dx < 0) ? 1 : -1;
377
378 x = wX + dx - w->border ().left;
379 }
380
381 while (dy && status != RectangleIn)
382 {
383 status = XRectInRegion (ms->region,
384 x, y,
385 (unsigned int) width,
386 (unsigned int) height);
387
388 if (status != RectangleIn)
389 dy += (dy < 0) ? 1 : -1;
390
391 y = wY + dy - w->border ().top;
392 }
393 }
394 else
395 {
396 ms->status = status;
397 }
398 }
399 }
400
401 if (ms->optionGetSnapoffMaximized ())
402 {
403 if (w->state () & CompWindowStateMaximizedVertMask)
404 {
405 if (abs (yRoot - workArea.y () - ms->snapOffY) >= SNAP_OFF)
406 {
407 if (!s->otherGrabExist ("move", NULL))
408 {
409 int width = w->serverGeometry ().width ();
410
411 w->saveMask () |= CWX | CWY;
412
413 if (w->saveMask ()& CWWidth)
414 width = w->saveWc ().width;
415
416 w->saveWc ().x = xRoot - (width >> 1);
417 w->saveWc ().y = yRoot + (w->border ().top >> 1);
418
419 ms->x = ms->y = 0;
420
421 w->maximize (0);
422
423 ms->snapOffY = ms->snapBackY;
424
425 return;
426 }
427 }
428 }
429 else if (ms->origState & CompWindowStateMaximizedVertMask)
430 {
431 if (abs (yRoot - workArea.y () - ms->snapBackY) < SNAP_BACK)
432 {
433 if (!s->otherGrabExist ("move", NULL))
434 {
435 int wy;
436
437 /* update server position before maximizing
438 window again so that it is maximized on
439 correct output */
440 w->syncPosition ();
441
442 w->maximize (ms->origState);
443
444 wy = workArea.y () + (w->border ().top >> 1);
445 wy += w->sizeHints ().height_inc >> 1;
446
447 s->warpPointer (0, wy - pointerY);
448
449 return;
450 }
451 }
452 }
453 }
454
455 if (w->state () & CompWindowStateMaximizedVertMask)
456 {
457 min = workArea.y () + w->border ().top;
458 max = workArea.bottom () - w->border ().bottom - wHeight;
459
460 if (wY + dy < min)
461 dy = min - wY;
462 else if (wY + dy > max)
463 dy = max - wY;
464 }
465
466 if (w->state () & CompWindowStateMaximizedHorzMask)
467 {
468 if (wX > (int) s->width () ||
469 wX + w->size ().width () < 0)
470 return;
471
472 if (wX + wWidth < 0)
473 return;
474
475 min = workArea.x () + w->border ().left;
476 max = workArea.right () - w->border ().right - wWidth;
477
478 if (wX + dx < min)
479 dx = min - wX;
480 else if (wX + dx > max)
481 dx = max - wX;
482 }
483 }
484
485 if (dx || dy)
486 {
487 w->move (wX + dx - w->geometry ().x (),
488 wY + dy - w->geometry ().y (), false);
489
490 if (ms->optionGetLazyPositioning () &&
491 ms->hasCompositing &&
492 !MoveWindow::get (ms->w)->mLocked)
493 {
494 /* FIXME: This form of lazy positioning is broken and should
495 be replaced asap. Current code exists just to avoid a
496 major performance regression in the 0.5.2 release. */
497 w->serverGeometry ().setX (w->geometry ().x ());
498 w->serverGeometry ().setY (w->geometry ().y ());
499 }
500 else
501 {
502 w->syncPosition ();
503 }
504
505 ms->x -= dx;
506 ms->y -= dy;
507 }
508 }
509}
510
511/* FIXME: This is a hack to prevent a race condition
512 * when core is processing ConfigureNotify events. It
513 * MUST be removed after 0.9.6 when we can break ABI
514 * and do lazy positioning correctly ! */
515
516void
517MoveScreen::handleCompizEvent (const char *plugin, const char *event, CompOption::Vector &options)
518{
519 if (w)
520 {
521 if (std::string ("core") == std::string (plugin))
522 {
523 if (std::string ("lock_position") == std::string (event))
524 {
525 Window xid = CompOption::getIntOptionNamed (options, "window", 0);
526 int lock = CompOption::getIntOptionNamed (options, "active", 0);
527
528 if (xid == ROOTPARENT (w))
529 MoveWindow::get (w)->mLocked = lock ? true : false;
530 }
531 }
532 }
533
534 screen->handleCompizEvent (plugin, event, options);
535}
536
537void
538MoveScreen::handleEvent (XEvent *event)
539{
540 switch (event->type) {
541 case ButtonPress:
542 case ButtonRelease:
543 if (event->xbutton.root == screen->root ())
544 {
545 if (grab)
546 {
547 if (releaseButton == -1 ||
548 releaseButton == (int) event->xbutton.button)
549 {
550 moveTerminate (&optionGetInitiateButton (),
551 CompAction::StateTermButton,
552 noOptions);
553 }
554 }
555 }
556 break;
557 case KeyPress:
558 if (event->xkey.root == screen->root ())
559 {
560 if (grab)
561 {
562 unsigned int i;
563
564 for (i = 0; i < NUM_KEYS; i++)
565 {
566 if (event->xkey.keycode == key[i])
567 {
568 XWarpPointer (screen->dpy (), None, None,
569 0, 0, 0, 0,
570 mKeys[i].dx * KEY_MOVE_INC,
571 mKeys[i].dy * KEY_MOVE_INC);
572 break;
573 }
574 }
575 }
576 }
577 break;
578 case MotionNotify:
579 if (event->xmotion.root == screen->root ())
580 moveHandleMotionEvent (screen, pointerX, pointerY);
581 break;
582 case EnterNotify:
583 case LeaveNotify:
584 if (event->xcrossing.root == screen->root ())
585 moveHandleMotionEvent (screen, pointerX, pointerY);
586 break;
587 case ClientMessage:
588 if (event->xclient.message_type == Atoms::wmMoveResize)
589 {
590 CompWindow *w;
591 unsigned long type = (unsigned long) event->xclient.data.l[2];
592
593 MOVE_SCREEN (screen);
594
595 if (type == WmMoveResizeMove ||
596 type == WmMoveResizeMoveKeyboard)
597 {
598 w = screen->findWindow (event->xclient.window);
599 if (w)
600 {
601 CompOption::Vector o;
602
603 o.push_back (CompOption ("window", CompOption::TypeInt));
604 o[0].value ().set ((int) event->xclient.window);
605
606 o.push_back (CompOption ("external",
607 CompOption::TypeBool));
608 o[1].value ().set (true);
609
610 if (event->xclient.data.l[2] == WmMoveResizeMoveKeyboard)
611 {
612 moveInitiate (&optionGetInitiateKey (),
613 CompAction::StateInitKey, o);
614 }
615 else
616 {
617
618 /* TODO: not only button 1 */
619 if (pointerMods & Button1Mask)
620 {
621 o.push_back (CompOption ("modifiers", CompOption::TypeInt));
622 o[2].value ().set ((int) pointerMods);
623
624 o.push_back (CompOption ("x", CompOption::TypeInt));
625 o[3].value ().set ((int) event->xclient.data.l[0]);
626
627 o.push_back (CompOption ("y", CompOption::TypeInt));
628 o[4].value ().set ((int) event->xclient.data.l[1]);
629
630 o.push_back (CompOption ("button", CompOption::TypeInt));
631 o[5].value ().set ((int) (event->xclient.data.l[3] ?
632 event->xclient.data.l[3] : -1));
633
634 moveInitiate (&optionGetInitiateButton (),
635 CompAction::StateInitButton, o);
636
637 moveHandleMotionEvent (screen, pointerX, pointerY);
638 }
639 }
640 }
641 }
642 else if (ms->w && type == WmMoveResizeCancel)
643 {
644 if (ms->w->id () == event->xclient.window)
645 {
646 moveTerminate (&optionGetInitiateButton (),
647 CompAction::StateCancel, noOptions);
648 moveTerminate (&optionGetInitiateKey (),
649 CompAction::StateCancel, noOptions);
650
651 }
652 }
653 }
654 break;
655 case DestroyNotify:
656 if (w && w->id () == event->xdestroywindow.window)
657 {
658 moveTerminate (&optionGetInitiateButton (), 0, noOptions);
659 moveTerminate (&optionGetInitiateKey (), 0, noOptions);
660 }
661 break;
662 case UnmapNotify:
663 if (w && w->id () == event->xunmap.window)
664 {
665 moveTerminate (&optionGetInitiateButton (), 0, noOptions);
666 moveTerminate (&optionGetInitiateKey (), 0, noOptions);
667 }
668 default:
669 break;
670 }
671
672 screen->handleEvent (event);
673}
674
675bool
676MoveWindow::glPaint (const GLWindowPaintAttrib &attrib,
677 const GLMatrix &transform,
678 const CompRegion &region,
679 unsigned int mask)
680{
681 GLWindowPaintAttrib sAttrib = attrib;
682 bool status;
683
684 MOVE_SCREEN (screen);
685
686 if (ms->grab)
687 {
688 if (ms->w == window && ms->moveOpacity != OPAQUE)
689 {
690 /* modify opacity of windows that are not active */
691 sAttrib.opacity = (sAttrib.opacity * ms->moveOpacity) >> 16;
692 }
693 }
694
695 status = gWindow->glPaint (sAttrib, transform, region, mask);
696
697 return status;
698}
699
700void
701MoveScreen::updateOpacity ()
702{
703 moveOpacity = (optionGetOpacity () * OPAQUE) / 100;
704}
705
706MoveScreen::MoveScreen (CompScreen *screen) :
707 PluginClassHandler<MoveScreen,CompScreen> (screen),
708 w (0),
709 region (NULL),
710 status (RectangleOut),
711 releaseButton (0),
712 grab (NULL),
713 hasCompositing (false),
714 yConstrained (false)
715{
716
717 updateOpacity ();
718
719 for (unsigned int i = 0; i < NUM_KEYS; i++)
720 key[i] = XKeysymToKeycode (screen->dpy (),
721 XStringToKeysym (mKeys[i].name));
722
723 moveCursor = XCreateFontCursor (screen->dpy (), XC_fleur);
724 if (CompositeScreen::get (screen))
725 hasCompositing =
726 CompositeScreen::get (screen)->compositingActive ();
727
728 optionSetOpacityNotify (boost::bind (&MoveScreen::updateOpacity, this));
729
730 optionSetInitiateButtonInitiate (moveInitiate);
731 optionSetInitiateButtonTerminate (moveTerminate);
732
733 optionSetInitiateKeyInitiate (moveInitiate);
734 optionSetInitiateKeyTerminate (moveTerminate);
735
736 ScreenInterface::setHandler (screen);
737}
738
739MoveScreen::~MoveScreen ()
740{
741 if (region)
742 XDestroyRegion (region);
743
744 if (moveCursor)
745 XFreeCursor (screen->dpy (), moveCursor);
746}
747
748bool
749MovePluginVTable::init ()
750{
751 if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION))
752 return false;
753
754 return true;
755}
756
0757
=== added file '.pc/fix-881329.patch/plugins/move/src/move.h'
--- .pc/fix-881329.patch/plugins/move/src/move.h 1970-01-01 00:00:00 +0000
+++ .pc/fix-881329.patch/plugins/move/src/move.h 2011-10-29 09:07:25 +0000
@@ -0,0 +1,135 @@
1/*
2 * Copyright © 2005 Novell, Inc.
3 *
4 * Permission to use, copy, modify, distribute, and sell this software
5 * and its documentation for any purpose is hereby granted without
6 * fee, provided that the above copyright notice appear in all copies
7 * and that both that copyright notice and this permission notice
8 * appear in supporting documentation, and that the name of
9 * Novell, Inc. not be used in advertising or publicity pertaining to
10 * distribution of the software without specific, written prior permission.
11 * Novell, Inc. makes no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
13 * implied warranty.
14 *
15 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 * Author: David Reveman <davidr@novell.com>
24 */
25
26#include <core/core.h>
27#include <core/pluginclasshandler.h>
28
29#include <composite/composite.h>
30#include <opengl/opengl.h>
31
32#include "move_options.h"
33
34#define NUM_KEYS (sizeof (mKeys) / sizeof (mKeys[0]))
35
36#define KEY_MOVE_INC 24
37
38#define SNAP_BACK 20
39#define SNAP_OFF 100
40
41struct _MoveKeys {
42 const char *name;
43 int dx;
44 int dy;
45} mKeys[] = {
46 { "Left", -1, 0 },
47 { "Right", 1, 0 },
48 { "Up", 0, -1 },
49 { "Down", 0, 1 }
50};
51
52class MoveScreen :
53 public ScreenInterface,
54 public PluginClassHandler<MoveScreen,CompScreen>,
55 public MoveOptions
56{
57 public:
58 MoveScreen (CompScreen *screen);
59 ~MoveScreen ();
60
61 void updateOpacity ();
62
63 void handleEvent (XEvent *);
64 void handleCompizEvent (const char *plugin,
65 const char *event,
66 CompOption::Vector &options);
67
68 CompWindow *w;
69 int savedX;
70 int savedY;
71 int x;
72 int y;
73 Region region;
74 int status;
75 KeyCode key[NUM_KEYS];
76
77 int releaseButton;
78
79 GLushort moveOpacity;
80
81 CompScreen::GrabHandle grab;
82
83 Cursor moveCursor;
84
85 unsigned int origState;
86
87 int snapOffY;
88 int snapBackY;
89
90 bool hasCompositing;
91
92 bool yConstrained;
93};
94
95class MoveWindow :
96 public GLWindowInterface,
97 public PluginClassHandler<MoveWindow,CompWindow>
98{
99 public:
100 MoveWindow (CompWindow *window) :
101 PluginClassHandler<MoveWindow,CompWindow> (window),
102 window (window),
103 gWindow (GLWindow::get (window)),
104 cWindow (CompositeWindow::get (window)),
105 mLocked (false)
106 {
107 if (gWindow)
108 GLWindowInterface::setHandler (gWindow, false);
109 };
110
111 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
112 const CompRegion &, unsigned int);
113
114 CompWindow *window;
115 GLWindow *gWindow;
116 CompositeWindow *cWindow;
117
118 bool mLocked;
119};
120
121#define MOVE_SCREEN(s) \
122 MoveScreen *ms = MoveScreen::get (s)
123
124#define MOVE_WINDOW(w) \
125 MoveWindow *mw = MoveWindow::get (w)
126
127
128class MovePluginVTable :
129 public CompPlugin::VTableForScreenAndWindow<MoveScreen, MoveWindow>
130{
131 public:
132
133 bool init ();
134};
135
0136
=== added directory '.pc/fix-883383.patch'
=== added file '.pc/fix-883383.patch/.timestamp'
=== added directory '.pc/fix-883383.patch/unity'
=== added directory '.pc/fix-883383.patch/unity/unity_window_decorator'
=== added directory '.pc/fix-883383.patch/unity/unity_window_decorator/src'
=== added file '.pc/fix-883383.patch/unity/unity_window_decorator/src/events.c'
--- .pc/fix-883383.patch/unity/unity_window_decorator/src/events.c 1970-01-01 00:00:00 +0000
+++ .pc/fix-883383.patch/unity/unity_window_decorator/src/events.c 2011-10-29 09:07:25 +0000
@@ -0,0 +1,1146 @@
1#include "gtk-window-decorator.h"
2
3void
4move_resize_window (WnckWindow *win,
5 int direction,
6 decor_event *gtkwd_event)
7{
8 Display *xdisplay;
9 GdkDisplay *gdkdisplay;
10 GdkScreen *screen;
11 Window xroot;
12 XEvent ev;
13
14 gdkdisplay = gdk_display_get_default ();
15 xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
16 screen = gdk_display_get_default_screen (gdkdisplay);
17 xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));
18
19 if (action_menu_mapped)
20 {
21 gtk_object_destroy (GTK_OBJECT (action_menu));
22 action_menu_mapped = FALSE;
23 action_menu = NULL;
24 return;
25 }
26
27 ev.xclient.type = ClientMessage;
28 ev.xclient.display = xdisplay;
29
30 ev.xclient.serial = 0;
31 ev.xclient.send_event = TRUE;
32
33 ev.xclient.window = wnck_window_get_xid (win);
34 ev.xclient.message_type = wm_move_resize_atom;
35 ev.xclient.format = 32;
36
37 ev.xclient.data.l[0] = gtkwd_event->x_root;
38 ev.xclient.data.l[1] = gtkwd_event->y_root;
39 ev.xclient.data.l[2] = direction;
40 ev.xclient.data.l[3] = gtkwd_event->button;
41 ev.xclient.data.l[4] = 1;
42
43 XUngrabPointer (xdisplay, gtkwd_event->time);
44 XUngrabKeyboard (xdisplay, gtkwd_event->time);
45
46 XSendEvent (xdisplay, xroot, FALSE,
47 SubstructureRedirectMask | SubstructureNotifyMask,
48 &ev);
49
50 XSync (xdisplay, FALSE);
51}
52
53void
54common_button_event (WnckWindow *win,
55 decor_event *gtkwd_event,
56 decor_event_type gtkwd_type,
57 int button,
58 int max)
59{
60 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
61 guint state = d->button_states[button];
62
63 if (d->frame_window && gtkwd_type == GEnterNotify)
64 {
65 GdkCursor* cursor;
66 cursor = gdk_cursor_new (GDK_LEFT_PTR);
67 gdk_window_set_cursor (d->frame_window, cursor);
68 gdk_cursor_unref (cursor);
69 }
70
71 switch (gtkwd_type) {
72 case GButtonPress:
73 if (gtkwd_event->button <= max)
74 d->button_states[button] |= PRESSED_EVENT_WINDOW;
75 break;
76 case GButtonRelease:
77 if (gtkwd_event->button <= max)
78 d->button_states[button] &= ~PRESSED_EVENT_WINDOW;
79 break;
80 case GEnterNotify:
81 d->button_states[button] |= IN_EVENT_WINDOW;
82 break;
83 case GLeaveNotify:
84 d->button_states[button] &= ~IN_EVENT_WINDOW;
85 break;
86 default:
87 break;
88 }
89
90 if (state != d->button_states[button])
91 queue_decor_draw (d);
92}
93
94#define BUTTON_EVENT_ACTION_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW)
95
96void
97close_button_event (WnckWindow *win,
98 decor_event *gtkwd_event,
99 decor_event_type gtkwd_type)
100{
101 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
102 guint state = d->button_states[BUTTON_CLOSE];
103
104 common_button_event (win, gtkwd_event, gtkwd_type,
105 BUTTON_CLOSE, 1);
106
107 switch (gtkwd_type) {
108 case GButtonRelease:
109 if (gtkwd_event->button == 1)
110 if (state == BUTTON_EVENT_ACTION_STATE)
111 wnck_window_close (win, gtkwd_event->time);
112 break;
113 default:
114 break;
115 }
116}
117
118void
119max_button_event (WnckWindow *win,
120 decor_event *gtkwd_event,
121 decor_event_type gtkwd_type)
122{
123 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
124 guint state = d->button_states[BUTTON_MAX];
125
126 if (wnck_window_is_maximized (win))
127 common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX,
128 3);
129 else
130 common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX,
131 3);
132
133 switch (gtkwd_type) {
134 case GButtonRelease:
135 if (gtkwd_event->button <= 3)
136 {
137 if (state == BUTTON_EVENT_ACTION_STATE)
138 {
139 if (gtkwd_event->button == 2)
140 {
141 if (wnck_window_is_maximized_vertically (win))
142 wnck_window_unmaximize_vertically (win);
143 else
144 wnck_window_maximize_vertically (win);
145 }
146 else if (gtkwd_event->button == 3)
147 {
148 if (wnck_window_is_maximized_horizontally (win))
149 wnck_window_unmaximize_horizontally (win);
150 else
151 wnck_window_maximize_horizontally (win);
152 }
153 else
154 {
155 if (wnck_window_is_maximized (win))
156 wnck_window_unmaximize (win);
157 else
158 wnck_window_maximize (win);
159 }
160 }
161 }
162 break;
163 default:
164 break;
165 }
166}
167
168void
169min_button_event (WnckWindow *win,
170 decor_event *gtkwd_event,
171 decor_event_type gtkwd_type)
172{
173 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
174 guint state = d->button_states[BUTTON_MIN];
175
176 common_button_event (win, gtkwd_event, gtkwd_type,
177 BUTTON_MIN, 1);
178
179 switch (gtkwd_type) {
180 case GButtonRelease:
181 if (gtkwd_event->button == 1)
182 if (state == BUTTON_EVENT_ACTION_STATE)
183 wnck_window_minimize (win);
184 break;
185 default:
186 break;
187 }
188}
189
190void
191menu_button_event (WnckWindow *win,
192 decor_event *gtkwd_event,
193 decor_event_type gtkwd_type)
194{
195
196 common_button_event (win, gtkwd_event, gtkwd_type,
197 BUTTON_MENU, 1);
198
199 switch (gtkwd_type) {
200 case GButtonPress:
201 if (gtkwd_event->button == 1)
202 action_menu_map (win,
203 gtkwd_event->button,
204 gtkwd_event->time);
205 break;
206 default:
207 break;
208 }
209}
210
211void
212shade_button_event (WnckWindow *win,
213 decor_event *gtkwd_event,
214 decor_event_type gtkwd_type)
215{
216 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
217 guint state = d->button_states[BUTTON_SHADE];
218
219 common_button_event (win, gtkwd_event, gtkwd_type,
220 BUTTON_SHADE, 1);
221
222 switch (gtkwd_type) {
223 case GButtonRelease:
224 if (gtkwd_event->button == 1)
225 {
226 if (state == BUTTON_EVENT_ACTION_STATE)
227 wnck_window_shade (win);
228 }
229 break;
230 default:
231 break;
232 }
233}
234
235void
236above_button_event (WnckWindow *win,
237 decor_event *gtkwd_event,
238 decor_event_type gtkwd_type)
239{
240 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
241 guint state = d->button_states[BUTTON_ABOVE];
242
243 common_button_event (win, gtkwd_event, gtkwd_type,
244 BUTTON_ABOVE, 1);
245
246 switch (gtkwd_type) {
247 case GButtonRelease:
248 if (gtkwd_event->button == 1)
249 if (state == BUTTON_EVENT_ACTION_STATE)
250#ifdef HAVE_LIBWNCK_2_18_1
251 wnck_window_make_above (win);
252#endif
253 break;
254 default:
255 break;
256 }
257}
258
259void
260stick_button_event (WnckWindow *win,
261 decor_event *gtkwd_event,
262 decor_event_type gtkwd_type)
263{
264 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
265 guint state = d->button_states[BUTTON_STICK];
266
267 common_button_event (win, gtkwd_event, gtkwd_type,
268 BUTTON_STICK, 1);
269
270 switch (gtkwd_type) {
271 case GButtonRelease:
272 if (gtkwd_event->button == 1)
273 if (state == BUTTON_EVENT_ACTION_STATE)
274 wnck_window_stick (win);
275 break;
276 default:
277 break;
278 }
279}
280
281void
282unshade_button_event (WnckWindow *win,
283 decor_event *gtkwd_event,
284 decor_event_type gtkwd_type)
285{
286 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
287 guint state = d->button_states[BUTTON_UNSHADE];
288
289 common_button_event (win, gtkwd_event, gtkwd_type,
290 BUTTON_UNSHADE, 1);
291
292 switch (gtkwd_type) {
293 case GButtonRelease:
294 if (gtkwd_event->button == 1)
295 if (state == BUTTON_EVENT_ACTION_STATE)
296 wnck_window_unshade (win);
297 break;
298 default:
299 break;
300 }
301}
302
303void
304unabove_button_event (WnckWindow *win,
305 decor_event *gtkwd_event,
306 decor_event_type gtkwd_type)
307{
308 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
309 guint state = d->button_states[BUTTON_UNABOVE];
310
311 common_button_event (win, gtkwd_event, gtkwd_type,
312 BUTTON_UNABOVE, 1);
313
314 switch (gtkwd_type) {
315 case GButtonRelease:
316 if (gtkwd_event->button == 1)
317 if (state == BUTTON_EVENT_ACTION_STATE)
318#ifdef HAVE_LIBWNCK_2_18_1
319 wnck_window_unmake_above (win);
320#endif
321 break;
322 default:
323 break;
324 }
325}
326
327void
328unstick_button_event (WnckWindow *win,
329 decor_event *gtkwd_event,
330 decor_event_type gtkwd_type)
331{
332 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
333 guint state = d->button_states[BUTTON_UNSTICK];
334
335 common_button_event (win, gtkwd_event, gtkwd_type,
336 BUTTON_UNSTICK, 1);
337
338 switch (gtkwd_type) {
339 case GButtonRelease:
340 if (gtkwd_event->button == 1)
341 if (state == BUTTON_EVENT_ACTION_STATE)
342 wnck_window_unstick (win);
343 break;
344 default:
345 break;
346 }
347}
348
349void
350handle_title_button_event (WnckWindow *win,
351 int action,
352 decor_event *gtkwd_event)
353{
354 switch (action) {
355 case CLICK_ACTION_SHADE:
356 if (wnck_window_is_shaded (win))
357 wnck_window_unshade (win);
358 else
359 wnck_window_shade (win);
360 break;
361 case CLICK_ACTION_MAXIMIZE:
362 if (wnck_window_is_maximized (win))
363 wnck_window_unmaximize (win);
364 else
365 wnck_window_maximize (win);
366 break;
367 case CLICK_ACTION_MINIMIZE:
368 if (!wnck_window_is_minimized (win))
369 wnck_window_minimize (win);
370 break;
371 case CLICK_ACTION_RAISE:
372 restack_window (win, Above);
373 break;
374 case CLICK_ACTION_LOWER:
375 restack_window (win, Below);
376 break;
377 case CLICK_ACTION_MENU:
378 action_menu_map (win, gtkwd_event->button, gtkwd_event->time);
379 break;
380 }
381}
382
383void
384handle_mouse_wheel_title_event (WnckWindow *win,
385 unsigned int button)
386{
387 switch (wheel_action) {
388 case WHEEL_ACTION_SHADE:
389 if (button == 4)
390 {
391 if (!wnck_window_is_shaded (win))
392 wnck_window_shade (win);
393 }
394 else if (button == 5)
395 {
396 if (wnck_window_is_shaded (win))
397 wnck_window_unshade (win);
398 }
399 break;
400 default:
401 break;
402 }
403}
404
405void
406title_event (WnckWindow *win,
407 decor_event *gtkwd_event,
408 decor_event_type gtkwd_type)
409{
410 static int last_button_num = 0;
411 static Window last_button_xwindow = None;
412 static Time last_button_time = 0;
413 static int last_button_x = 0;
414 static int last_button_y = 0;
415
416 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
417
418 if (d->frame_window && gtkwd_type == GEnterNotify)
419 {
420 GdkCursor* cursor = gdk_cursor_new (GDK_LEFT_PTR);
421 gdk_window_set_cursor (d->frame_window, cursor);
422 gdk_cursor_unref (cursor);
423 }
424
425 if (gtkwd_type != GButtonPress)
426 return;
427
428 if (gtkwd_event->button == 1)
429 {
430 if (gtkwd_event->button == last_button_num &&
431 gtkwd_event->window == last_button_xwindow &&
432 gtkwd_event->time < last_button_time + double_click_timeout &&
433 dist (gtkwd_event->x, gtkwd_event->y,
434 last_button_x, last_button_y) < DOUBLE_CLICK_DISTANCE)
435 {
436 handle_title_button_event (win, double_click_action,
437 gtkwd_event);
438
439 last_button_num = 0;
440 last_button_xwindow = None;
441 last_button_time = 0;
442 last_button_x = 0;
443 last_button_y = 0;
444 }
445 else
446 {
447 last_button_num = gtkwd_event->button;
448 last_button_xwindow = gtkwd_event->window;
449 last_button_time = gtkwd_event->time;
450 last_button_x = gtkwd_event->x;
451 last_button_y = gtkwd_event->y;
452
453 restack_window (win, Above);
454
455 move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event);
456 }
457 }
458 else if (gtkwd_event->button == 2)
459 {
460 handle_title_button_event (win, middle_click_action,
461 gtkwd_event);
462 }
463 else if (gtkwd_event->button == 3)
464 {
465 handle_title_button_event (win, right_click_action,
466 gtkwd_event);
467 }
468 else if (gtkwd_event->button == 4 ||
469 gtkwd_event->button == 5)
470 {
471 handle_mouse_wheel_title_event (win, gtkwd_event->button);
472 }
473}
474
475void
476frame_common_event (WnckWindow *win,
477 int direction,
478 decor_event *gtkwd_event,
479 decor_event_type gtkwd_type)
480{
481
482 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
483
484 if (d->frame_window && gtkwd_type == GEnterNotify)
485 {
486 GdkCursor *cursor = NULL;
487
488 switch (direction)
489 {
490 case WM_MOVERESIZE_SIZE_TOPLEFT:
491 cursor = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
492 break;
493 case WM_MOVERESIZE_SIZE_LEFT:
494 cursor = gdk_cursor_new (GDK_LEFT_SIDE);
495 break;
496 case WM_MOVERESIZE_SIZE_BOTTOMLEFT:
497 cursor = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
498 break;
499 case WM_MOVERESIZE_SIZE_BOTTOM:
500 cursor = gdk_cursor_new (GDK_BOTTOM_SIDE);
501 break;
502 case WM_MOVERESIZE_SIZE_BOTTOMRIGHT:
503 cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
504 break;
505 case WM_MOVERESIZE_SIZE_RIGHT:
506 cursor = gdk_cursor_new (GDK_RIGHT_SIDE);
507 break;
508 case WM_MOVERESIZE_SIZE_TOPRIGHT:
509 cursor = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
510 break;
511 case WM_MOVERESIZE_SIZE_TOP:
512 cursor = gdk_cursor_new (GDK_TOP_SIDE);
513 break;
514 default:
515 break;
516 }
517
518 if (cursor)
519 {
520 gdk_window_set_cursor (d->frame_window, cursor);
521 gdk_cursor_unref (cursor);
522 }
523 }
524
525 if (gtkwd_type != GButtonPress)
526 return;
527
528 switch (gtkwd_event->button) {
529 case 1:
530 move_resize_window (win, direction, gtkwd_event);
531 restack_window (win, Above);
532 break;
533 case 2:
534 handle_title_button_event (win, middle_click_action,
535 gtkwd_event);
536 break;
537 case 3:
538 handle_title_button_event (win, right_click_action,
539 gtkwd_event);
540 break;
541 }
542}
543
544void
545top_left_event (WnckWindow *win,
546 decor_event *gtkwd_event,
547 decor_event_type gtkwd_type)
548{
549 frame_common_event (win, WM_MOVERESIZE_SIZE_TOPLEFT,
550 gtkwd_event, gtkwd_type);
551}
552
553void
554top_event (WnckWindow *win,
555 decor_event *gtkwd_event,
556 decor_event_type gtkwd_type)
557{
558 frame_common_event (win, WM_MOVERESIZE_SIZE_TOP,
559 gtkwd_event, gtkwd_type);
560}
561
562void
563top_right_event (WnckWindow *win,
564 decor_event *gtkwd_event,
565 decor_event_type gtkwd_type)
566{
567 frame_common_event (win, WM_MOVERESIZE_SIZE_TOPRIGHT,
568 gtkwd_event, gtkwd_type);
569}
570
571void
572left_event (WnckWindow *win,
573 decor_event *gtkwd_event,
574 decor_event_type gtkwd_type)
575{
576 frame_common_event (win, WM_MOVERESIZE_SIZE_LEFT,
577 gtkwd_event, gtkwd_type);
578}
579
580void
581right_event (WnckWindow *win,
582 decor_event *gtkwd_event,
583 decor_event_type gtkwd_type)
584{
585 frame_common_event (win, WM_MOVERESIZE_SIZE_RIGHT,
586 gtkwd_event, gtkwd_type);
587}
588
589void
590bottom_left_event (WnckWindow *win,
591 decor_event *gtkwd_event,
592 decor_event_type gtkwd_type)
593{
594 frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMLEFT,
595 gtkwd_event, gtkwd_type);
596}
597
598void
599bottom_event (WnckWindow *win,
600 decor_event *gtkwd_event,
601 decor_event_type gtkwd_type)
602{
603 frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOM,
604 gtkwd_event, gtkwd_type);
605}
606
607void
608bottom_right_event (WnckWindow *win,
609 decor_event *gtkwd_event,
610 decor_event_type gtkwd_type)
611{
612 frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMRIGHT,
613 gtkwd_event, gtkwd_type);
614}
615
616void
617frame_window_realized (GtkWidget *widget,
618 gpointer data)
619{
620 decor_t *d = (decor_t *) data;
621
622 if (d)
623 {
624 GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window);
625 gdk_window_reparent (gdk_frame_window, d->frame_window, 0, 0);
626 gdk_window_lower (gdk_frame_window);
627
628 }
629}
630
631event_callback
632find_event_callback_for_point (decor_t *d,
633 int x,
634 int y,
635 Bool *enter,
636 Bool *leave,
637 BoxPtr *entered_box)
638{
639 int i, j;
640 BoxPtr box;
641
642 for (i = 0; i < BUTTON_NUM; i++)
643 {
644 box = &d->button_windows[i].pos;
645 if (x >= box->x1 && x <= box->x2 &&
646 y >= box->y1 && y <= box->y2)
647 {
648 if (d->last_pos_entered != box)
649 {
650 if (enter)
651 *enter = TRUE;
652 if (leave && d->last_pos_entered)
653 *leave = TRUE;
654 if (entered_box)
655 *entered_box = box;
656 }
657 return d->button_windows[i].callback;
658 }
659 }
660
661 for (i = 0; i < 3; i++)
662 {
663 for (j = 0; j < 3; j++)
664 {
665 box = &d->event_windows[i][j].pos;
666 if (x >= box->x1 && x <= box->x2 &&
667 y >= box->y1 && y <= box->y2)
668 {
669 if (d->last_pos_entered != box)
670 {
671 if (enter)
672 *enter = TRUE;
673 if (leave && d->last_pos_entered)
674 *leave = TRUE;
675 if (entered_box)
676 *entered_box = box;
677 }
678 return d->event_windows[i][j].callback;
679 }
680 }
681 }
682
683 return NULL;
684}
685
686event_callback
687find_leave_event_callback (decor_t *d)
688{
689 int i, j;
690
691 for (i = 0; i < BUTTON_NUM; i++)
692 {
693 if (d->last_pos_entered == &d->button_windows[i].pos)
694 return d->button_windows[i].callback;
695 }
696
697 for (i = 0; i < 3; i++)
698 {
699 for (j = 0; j < 3; j++)
700 {
701 if (d->last_pos_entered == &d->event_windows[i][j].pos)
702 return d->event_windows[i][j].callback;
703 }
704 }
705
706 return NULL;
707}
708
709void
710frame_handle_button_press (GtkWidget *widget,
711 GdkEventButton *event,
712 gpointer user_data)
713{
714 decor_t *d = (decor_t *) user_data;
715
716 if (d)
717 {
718 /* Check to see where the event happened and fill out an appropriate
719 * struct
720 */
721 event_callback cb;
722
723 cb = find_event_callback_for_point (d, event->x, event->y,
724 NULL, NULL, NULL);
725
726 if (cb && d->decorated)
727 {
728 decor_event gtkwd_event;
729
730 gtkwd_event.window = GDK_WINDOW_XID (d->frame_window);
731 gtkwd_event.button = event->button;
732 gtkwd_event.x = event->x;
733 gtkwd_event.y = event->y;
734 gtkwd_event.x_root = event->x_root;
735 gtkwd_event.y_root = event->y_root;
736 gtkwd_event.time = event->time;
737
738 (*cb) (d->win, &gtkwd_event, GButtonPress);
739 }
740 }
741}
742
743void
744frame_handle_button_release (GtkWidget *widget,
745 GdkEventButton *event,
746 gpointer user_data)
747{
748 decor_t *d = (decor_t *) user_data;
749
750 if (d)
751 {
752 event_callback cb;
753
754 cb = find_event_callback_for_point (d, event->x, event->y,
755 NULL, NULL, NULL);
756
757 if (cb && d->decorated)
758 {
759 decor_event gtkwd_event;
760
761 gtkwd_event.window = GDK_WINDOW_XID (d->frame_window);
762 gtkwd_event.button = event->button;
763 gtkwd_event.x = event->x;
764 gtkwd_event.y = event->y;
765 gtkwd_event.x_root = event->x_root;
766 gtkwd_event.y_root = event->y_root;
767 gtkwd_event.time = event->time;
768
769 (*cb) (d->win, &gtkwd_event, GButtonRelease);
770 }
771 }
772}
773
774void
775frame_handle_motion (GtkWidget *widget,
776 GdkEventMotion *event,
777 gpointer user_data)
778{
779 decor_t *d = (decor_t *) user_data;
780
781 if (d)
782 {
783 event_callback cb = NULL;
784 Bool send_enter = FALSE;
785 Bool send_leave = FALSE;
786 BoxPtr entered_box;
787
788 cb = find_event_callback_for_point (d, event->x, event->y,
789 &send_enter, &send_leave,
790 &entered_box);
791
792 if (cb && d->decorated)
793 {
794 decor_event gtkwd_event;
795
796 gtkwd_event.window = GDK_WINDOW_XID (d->frame_window);
797 gtkwd_event.x = event->x;
798 gtkwd_event.y = event->y;
799 gtkwd_event.x_root = event->x_root;
800 gtkwd_event.y_root = event->y_root;
801 gtkwd_event.time = event->time;
802
803 if (send_enter)
804 (*cb) (d->win, &gtkwd_event, GEnterNotify);
805
806 if (send_leave)
807 {
808 event_callback leave_cb;
809
810 leave_cb = find_leave_event_callback (d);
811
812 if (leave_cb)
813 (*leave_cb) (d->win, &gtkwd_event, GLeaveNotify);
814
815 }
816
817 if (send_enter)
818 d->last_pos_entered = entered_box;
819 }
820 else if (d->last_pos_entered && d->decorated)
821 {
822 /* We are not in an event / button window but last_pos_entered
823 * is still set, so send a GLeaveNotify to last_pos_entered
824 * and set it to NULL
825 */
826
827 event_callback leave_cb;
828
829 leave_cb = find_leave_event_callback (d);
830
831 if (leave_cb)
832 {
833 decor_event gtkwd_event;
834
835 gtkwd_event.window = GDK_WINDOW_XID (d->frame_window);
836 gtkwd_event.x = event->x;
837 gtkwd_event.y = event->y;
838 gtkwd_event.x_root = event->x_root;
839 gtkwd_event.y_root = event->y_root;
840 gtkwd_event.time = event->time;
841
842 (*leave_cb) (d->win, &gtkwd_event, GLeaveNotify);
843 }
844
845 d->last_pos_entered = NULL;
846 }
847 }
848}
849
850GdkFilterReturn
851event_filter_func (GdkXEvent *gdkxevent,
852 GdkEvent *event,
853 gpointer data)
854{
855 Display *xdisplay;
856 GdkDisplay *gdkdisplay;
857 XEvent *xevent = gdkxevent;
858 gulong xid = 0;
859 Window select = 0;
860
861 gdkdisplay = gdk_display_get_default ();
862 xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
863
864 switch (xevent->type) {
865 case CreateNotify:
866 {
867 if (!wnck_window_get (xevent->xcreatewindow.window))
868 {
869 GdkWindow *toplevel = create_foreign_window (xevent->xcreatewindow.window);
870
871 if (toplevel)
872 {
873 gdk_window_set_events (toplevel,
874 gdk_window_get_events (toplevel) |
875 GDK_PROPERTY_CHANGE_MASK);
876
877 /* check if the window is a switcher and update accordingly */
878
879 if (get_window_prop (xevent->xcreatewindow.window, select_window_atom, &select))
880 update_switcher_window (xevent->xcreatewindow.window, select);
881 }
882 }
883 }
884 break;
885 case ButtonPress:
886 case ButtonRelease:
887 xid = (gulong)
888 g_hash_table_lookup (frame_table,
889 GINT_TO_POINTER (xevent->xbutton.window));
890 break;
891 case EnterNotify:
892 case LeaveNotify:
893 xid = (gulong)
894 g_hash_table_lookup (frame_table,
895 GINT_TO_POINTER (xevent->xcrossing.window));
896 break;
897 case MotionNotify:
898 xid = (gulong)
899 g_hash_table_lookup (frame_table,
900 GINT_TO_POINTER (xevent->xmotion.window));
901 break;
902 case PropertyNotify:
903 if (xevent->xproperty.atom == frame_input_window_atom)
904 {
905 WnckWindow *win;
906
907 xid = xevent->xproperty.window;
908
909 win = wnck_window_get (xid);
910 if (win)
911 {
912 Window frame;
913
914 if (!get_window_prop (xid, select_window_atom, &select))
915 {
916 if (get_window_prop (xid, frame_input_window_atom, &frame))
917 add_frame_window (win, frame, FALSE);
918 else
919 remove_frame_window (win);
920 }
921 }
922 }
923 if (xevent->xproperty.atom == frame_output_window_atom)
924 {
925 WnckWindow *win;
926
927 xid = xevent->xproperty.window;
928
929 win = wnck_window_get (xid);
930 if (win)
931 {
932 Window frame;
933
934 if (!get_window_prop (xid, select_window_atom, &select))
935 {
936 if (get_window_prop (xid, frame_output_window_atom, &frame))
937 add_frame_window (win, frame, TRUE);
938 else
939 remove_frame_window (win);
940 }
941 }
942 }
943 else if (xevent->xproperty.atom == compiz_shadow_info_atom ||
944 xevent->xproperty.atom == compiz_shadow_color_atom)
945 {
946 GdkScreen *g_screen = gdk_display_get_default_screen (gdkdisplay);
947 Window root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (g_screen));
948 WnckScreen *screen;
949
950 screen = wnck_screen_get_for_root (root);
951
952 if (screen)
953 {
954 shadow_property_changed (screen);
955 }
956 }
957 else if (xevent->xproperty.atom == mwm_hints_atom)
958 {
959 WnckWindow *win;
960
961 xid = xevent->xproperty.window;
962
963 win = wnck_window_get (xid);
964 if (win)
965 {
966 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
967 gboolean decorated = FALSE;
968
969 if (get_mwm_prop (xid) & (MWM_DECOR_ALL | MWM_DECOR_TITLE))
970 decorated = TRUE;
971
972 if (decorated != d->decorated)
973 {
974 d->decorated = decorated;
975 if (decorated)
976 {
977 d->context = NULL;
978 d->width = d->height = 0;
979
980 update_window_decoration_size (win);
981 update_event_windows (win);
982 }
983 else
984 {
985 gdk_error_trap_push ();
986 XDeleteProperty (xdisplay, xid, win_decor_atom);
987 gdk_display_sync (gdk_display_get_default ());
988 gdk_error_trap_pop ();
989 }
990 }
991 }
992 }
993 else if (xevent->xproperty.atom == select_window_atom)
994 {
995 Window select;
996
997 if (get_window_prop (xevent->xproperty.window, select_window_atom, &select))
998 update_switcher_window (xevent->xproperty.window, select);
999 }
1000 break;
1001 case DestroyNotify:
1002 {
1003 g_hash_table_remove (frame_table,
1004 GINT_TO_POINTER (xevent->xproperty.window));
1005
1006 break;
1007 }
1008 case ClientMessage:
1009 if (xevent->xclient.message_type == toolkit_action_atom)
1010 {
1011 long action;
1012
1013 action = xevent->xclient.data.l[0];
1014 if (action == toolkit_action_window_menu_atom)
1015 {
1016 WnckWindow *win;
1017
1018 win = wnck_window_get (xevent->xclient.window);
1019 if (win)
1020 {
1021 action_menu_map (win,
1022 xevent->xclient.data.l[2],
1023 xevent->xclient.data.l[1]);
1024 }
1025 }
1026 else if (action == toolkit_action_force_quit_dialog_atom)
1027 {
1028 WnckWindow *win;
1029
1030 win = wnck_window_get (xevent->xclient.window);
1031 if (win)
1032 {
1033 if (xevent->xclient.data.l[2])
1034 show_force_quit_dialog (win,
1035 xevent->xclient.data.l[1]);
1036 else
1037 hide_force_quit_dialog (win);
1038 }
1039 }
1040 }
1041 default:
1042 break;
1043 }
1044
1045 if (xid)
1046 {
1047 WnckWindow *win;
1048
1049 win = wnck_window_get (xid);
1050 if (win)
1051 {
1052 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
1053
1054 if (d->decorated)
1055 {
1056 gint i, j;
1057 event_callback cb = NULL;
1058 Window w = xevent->xany.window;
1059
1060 for (i = 0; i < 3; i++)
1061 for (j = 0; j < 3; j++)
1062 if (d->event_windows[i][j].window == w)
1063 cb = d->event_windows[i][j].callback;
1064
1065 if (!cb)
1066 {
1067 for (i = 0; i < BUTTON_NUM; i++)
1068 if (d->button_windows[i].window == w)
1069 cb = d->button_windows[i].callback;
1070 }
1071
1072 if (cb)
1073 {
1074 decor_event gtkwd_event;
1075 decor_event_type gtkwd_type;
1076
1077 gtkwd_event.window = w;
1078
1079 switch (xevent->type)
1080 {
1081 case ButtonPress:
1082 case ButtonRelease:
1083 if (xevent->type == ButtonPress)
1084 gtkwd_type = GButtonPress;
1085 else
1086 gtkwd_type = GButtonRelease;
1087 gtkwd_event.button = xevent->xbutton.button;
1088 gtkwd_event.x = xevent->xbutton.x;
1089 gtkwd_event.y = xevent->xbutton.y;
1090 gtkwd_event.x_root = xevent->xbutton.x_root;
1091 gtkwd_event.y_root = xevent->xbutton.y_root;
1092 gtkwd_event.time = xevent->xbutton.time;
1093 break;
1094 case EnterNotify:
1095 case LeaveNotify:
1096 if (xevent->type == EnterNotify)
1097 gtkwd_type = GEnterNotify;
1098 else
1099 gtkwd_type = GLeaveNotify;
1100 gtkwd_event.x = xevent->xcrossing.x;
1101 gtkwd_event.y = xevent->xcrossing.y;
1102 gtkwd_event.x_root = xevent->xcrossing.x_root;
1103 gtkwd_event.y_root = xevent->xcrossing.y_root;
1104 gtkwd_event.time = xevent->xcrossing.time;
1105 break;
1106 default:
1107 cb = NULL;
1108 break;
1109 }
1110 if (cb)
1111 (*cb) (win, &gtkwd_event, gtkwd_type);
1112 }
1113 }
1114 }
1115 }
1116
1117 return GDK_FILTER_CONTINUE;
1118}
1119
1120GdkFilterReturn
1121selection_event_filter_func (GdkXEvent *gdkxevent,
1122 GdkEvent *event,
1123 gpointer data)
1124{
1125 Display *xdisplay;
1126 GdkDisplay *gdkdisplay;
1127 XEvent *xevent = gdkxevent;
1128 int status;
1129
1130 gdkdisplay = gdk_display_get_default ();
1131 xdisplay = GDK_DISPLAY_XDISPLAY (gdkdisplay);
1132
1133 switch (xevent->type) {
1134 case SelectionRequest:
1135 decor_handle_selection_request (xdisplay, xevent, dm_sn_timestamp);
1136 break;
1137 case SelectionClear:
1138 status = decor_handle_selection_clear (xdisplay, xevent, 0);
1139 if (status == DECOR_SELECTION_GIVE_UP)
1140 exit (0);
1141 default:
1142 break;
1143 }
1144
1145 return GDK_FILTER_CONTINUE;
1146}
01147
=== added file '.pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.c'
--- .pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.c 1970-01-01 00:00:00 +0000
+++ .pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.c 2011-10-29 09:07:25 +0000
@@ -0,0 +1,443 @@
1/*
2 * Copyright © 2006 Novell, Inc.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 *
19 * Author: David Reveman <davidr@novell.com>
20 */
21
22#include "gtk-window-decorator.h"
23
24gboolean minimal = FALSE;
25
26double decoration_alpha = 0.5;
27
28#define SWITCHER_SPACE 40
29
30decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
31decor_extents_t _win_extents = { 6, 6, 6, 6 };
32decor_extents_t _max_win_extents = { 6, 6, 4, 6 };
33decor_extents_t _default_win_extents = { 6, 6, 6, 6 };
34decor_extents_t _switcher_extents = { 6, 6, 6, 6 + SWITCHER_SPACE };
35
36int titlebar_height = 17;
37int max_titlebar_height = 17;
38
39decor_context_t window_active_context = {
40 { 0, 0, 0, 0 },
41 6, 6, 4, 6,
42 0, 0, 0, 0
43};
44
45decor_context_t max_window_active_context = {
46 { 0, 0, 0, 0 },
47 6, 6, 4, 6,
48 0, 0, 0, 0
49};
50
51decor_context_t window_inactive_context = {
52 { 0, 0, 0, 0 },
53 6, 6, 4, 6,
54 0, 0, 0, 0
55};
56
57decor_context_t max_window_inactive_context = {
58 { 0, 0, 0, 0 },
59 6, 6, 4, 6,
60 0, 0, 0, 0
61};
62
63decor_context_t window_context_no_shadow = {
64 { 0, 0, 0, 0 },
65 6, 6, 4, 6,
66 0, 0, 0, 0
67};
68
69decor_context_t max_window_context_no_shadow = {
70 { 0, 0, 0, 0 },
71 6, 6, 4, 6,
72 0, 0, 0, 0
73};
74
75decor_context_t switcher_context = {
76 { 0, 0, 0, 0 },
77 6, 6, 6, 6 + SWITCHER_SPACE,
78 0, 0, 0, 0
79};
80
81decor_context_t shadow_context = {
82 { 0, 0, 0, 0 },
83 0, 0, 0, 0,
84 0, 0, 0, 0,
85};
86
87gdouble shadow_radius = SHADOW_RADIUS;
88gdouble shadow_opacity = SHADOW_OPACITY;
89gushort shadow_color[3] = {
90 SHADOW_COLOR_RED,
91 SHADOW_COLOR_GREEN,
92 SHADOW_COLOR_BLUE
93};
94gint shadow_offset_x = SHADOW_OFFSET_X;
95gint shadow_offset_y = SHADOW_OFFSET_Y;
96
97guint cmdline_options = 0;
98
99decor_shadow_t *no_border_shadow = NULL;
100decor_shadow_t *border_active_shadow = NULL;
101decor_shadow_t *border_inactive_shadow = NULL;
102decor_shadow_t *max_border_active_shadow = NULL;
103decor_shadow_t *max_border_inactive_shadow = NULL;
104decor_shadow_t *border_no_shadow = NULL;
105decor_shadow_t *max_border_no_shadow = NULL;
106decor_shadow_t *switcher_shadow = NULL;
107
108GdkPixmap *decor_normal_pixmap = NULL;
109GdkPixmap *decor_active_pixmap = NULL;
110
111Atom frame_input_window_atom;
112Atom frame_output_window_atom;
113Atom win_decor_atom;
114Atom win_blur_decor_atom;
115Atom wm_move_resize_atom;
116Atom restack_window_atom;
117Atom select_window_atom;
118Atom mwm_hints_atom;
119Atom switcher_fg_atom;
120
121Atom compiz_shadow_info_atom;
122Atom compiz_shadow_color_atom;
123
124Atom toolkit_action_atom;
125Atom toolkit_action_window_menu_atom;
126Atom toolkit_action_force_quit_dialog_atom;
127
128Time dm_sn_timestamp;
129
130struct _cursor cursor[3][3] = {
131 { C (top_left_corner), C (top_side), C (top_right_corner) },
132 { C (left_side), C (left_ptr), C (right_side) },
133 { C (bottom_left_corner), C (bottom_side), C (bottom_right_corner) }
134};
135
136struct _pos pos[3][3] = {
137 {
138 { 0, 0, 10, 21, 0, 0, 0, 0, 0, 1 },
139 { 10, 0, -8, 6, 0, 0, 1, 0, 0, 1 },
140 { 2, 0, 10, 21, 1, 0, 0, 0, 0, 1 }
141 }, {
142 { 0, 10, 6, 11, 0, 0, 0, 1, 1, 0 },
143 { 6, 6, 0, 15, 0, 0, 1, 0, 0, 1 },
144 { 6, 10, 6, 11, 1, 0, 0, 1, 1, 0 }
145 }, {
146 { 0, 17, 10, 10, 0, 1, 0, 0, 1, 0 },
147 { 10, 21, -8, 6, 0, 1, 1, 0, 1, 0 },
148 { 2, 17, 10, 10, 1, 1, 0, 0, 1, 0 }
149 }
150}, bpos[] = {
151 { 0, 6, 16, 16, 1, 0, 0, 0, 0, 0 },
152 { 0, 6, 16, 16, 1, 0, 0, 0, 0, 0 },
153 { 0, 6, 16, 16, 1, 0, 0, 0, 0, 0 },
154 { 6, 2, 16, 16, 0, 0, 0, 0, 0, 0 }
155};
156
157char *program_name;
158
159GtkWidget *style_window_rgba;
160GtkWidget *style_window_rgb;
161GtkWidget *switcher_label;
162
163GHashTable *frame_table;
164GtkWidget *action_menu = NULL;
165gboolean action_menu_mapped = FALSE;
166decor_color_t _title_color[2];
167PangoContext *pango_context;
168gint double_click_timeout = 250;
169
170GSList *draw_list = NULL;
171guint draw_idle_id = 0;
172
173PangoFontDescription *titlebar_font = NULL;
174gboolean use_system_font = FALSE;
175gint text_height;
176
177gint blur_type = BLUR_TYPE_NONE;
178
179GdkPixmap *switcher_pixmap = NULL;
180GdkPixmap *switcher_buffer_pixmap = NULL;
181gint switcher_width;
182gint switcher_height;
183Window switcher_selected_window = None;
184decor_t *switcher_window = NULL;
185
186XRenderPictFormat *xformat_rgba;
187XRenderPictFormat *xformat_rgb;
188
189int
190main (int argc, char *argv[])
191{
192 GdkDisplay *gdkdisplay;
193 Display *xdisplay;
194 GdkScreen *gdkscreen;
195 WnckScreen *screen;
196 gint i, j, status;
197 unsigned int nchildren;
198 Window root_ret, parent_ret;
199 Window *children = NULL;
200 gboolean replace = FALSE;
201
202#ifdef USE_METACITY
203 char *meta_theme = NULL;
204#endif
205
206 program_name = argv[0];
207
208 gtk_init (&argc, &argv);
209
210 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
211 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
212 textdomain (GETTEXT_PACKAGE);
213
214 for (i = 0; i < argc; i++)
215 {
216 if (strcmp (argv[i], "--minimal") == 0)
217 {
218 minimal = TRUE;
219 }
220 else if (strcmp (argv[i], "--replace") == 0)
221 {
222 replace = TRUE;
223 }
224 else if (strcmp (argv[i], "--blur") == 0)
225 {
226 if (argc > ++i)
227 {
228 if (strcmp (argv[i], "titlebar") == 0)
229 blur_type = BLUR_TYPE_TITLEBAR;
230 else if (strcmp (argv[i], "all") == 0)
231 blur_type = BLUR_TYPE_ALL;
232 }
233 cmdline_options |= CMDLINE_BLUR;
234 }
235
236#ifdef USE_METACITY
237 else if (strcmp (argv[i], "--opacity") == 0)
238 {
239 if (argc > ++i)
240 meta_opacity = atof (argv[i]);
241 cmdline_options |= CMDLINE_OPACITY;
242 }
243 else if (strcmp (argv[i], "--no-opacity-shade") == 0)
244 {
245 meta_shade_opacity = FALSE;
246 cmdline_options |= CMDLINE_OPACITY_SHADE;
247 }
248 else if (strcmp (argv[i], "--active-opacity") == 0)
249 {
250 if (argc > ++i)
251 meta_active_opacity = atof (argv[i]);
252 cmdline_options |= CMDLINE_ACTIVE_OPACITY;
253 }
254 else if (strcmp (argv[i], "--no-active-opacity-shade") == 0)
255 {
256 meta_active_shade_opacity = FALSE;
257 cmdline_options |= CMDLINE_ACTIVE_OPACITY_SHADE;
258 }
259 else if (strcmp (argv[i], "--metacity-theme") == 0)
260 {
261 if (argc > ++i)
262 meta_theme = argv[i];
263 cmdline_options |= CMDLINE_THEME;
264 }
265#endif
266
267 else if (strcmp (argv[i], "--help") == 0)
268 {
269 fprintf (stderr, "%s "
270 "[--minimal] "
271 "[--replace] "
272 "[--blur none|titlebar|all] "
273
274#ifdef USE_METACITY
275 "[--opacity OPACITY] "
276 "[--no-opacity-shade] "
277 "[--active-opacity OPACITY] "
278 "[--no-active-opacity-shade] "
279 "[--metacity-theme THEME] "
280#endif
281
282 "[--help]"
283
284 "\n", program_name);
285 return 0;
286 }
287 }
288
289 theme_draw_window_decoration = draw_window_decoration;
290 theme_calc_decoration_size = calc_decoration_size;
291 theme_update_border_extents = update_border_extents;
292 theme_get_event_window_position = get_event_window_position;
293 theme_get_button_position = get_button_position;
294 theme_update_shadow = cairo_update_shadow;
295 theme_get_shadow = get_shadow;
296 theme_get_border_extents = get_border_extents;
297
298#ifdef USE_METACITY
299 if (meta_theme)
300 {
301 meta_theme_set_current (meta_theme, TRUE);
302 if (meta_theme_get_current ())
303 {
304 theme_draw_window_decoration = meta_draw_window_decoration;
305 theme_calc_decoration_size = meta_calc_decoration_size;
306 theme_update_border_extents = meta_update_border_extents;
307 theme_get_event_window_position = meta_get_event_window_position;
308 theme_get_button_position = meta_get_button_position;
309 theme_update_shadow = meta_update_shadow;
310 theme_get_shadow = meta_get_shadow;
311 theme_get_border_extents = meta_get_border_extents;
312 }
313 }
314#endif
315
316 gdkdisplay = gdk_display_get_default ();
317 xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
318 gdkscreen = gdk_display_get_default_screen (gdkdisplay);
319
320 frame_input_window_atom = XInternAtom (xdisplay,
321 DECOR_INPUT_FRAME_ATOM_NAME, FALSE);
322 frame_output_window_atom = XInternAtom (xdisplay,
323 DECOR_OUTPUT_FRAME_ATOM_NAME, FALSE);
324
325 win_decor_atom = XInternAtom (xdisplay, DECOR_WINDOW_ATOM_NAME, FALSE);
326 win_blur_decor_atom = XInternAtom (xdisplay, DECOR_BLUR_ATOM_NAME, FALSE);
327 wm_move_resize_atom = XInternAtom (xdisplay, "_NET_WM_MOVERESIZE", FALSE);
328 restack_window_atom = XInternAtom (xdisplay, "_NET_RESTACK_WINDOW", FALSE);
329 select_window_atom = XInternAtom (xdisplay, DECOR_SWITCH_WINDOW_ATOM_NAME,
330 FALSE);
331 mwm_hints_atom = XInternAtom (xdisplay, "_MOTIF_WM_HINTS", FALSE);
332 switcher_fg_atom = XInternAtom (xdisplay,
333 DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME,
334 FALSE);
335
336 compiz_shadow_info_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", FALSE);
337 compiz_shadow_color_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", FALSE);
338
339 toolkit_action_atom =
340 XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", FALSE);
341 toolkit_action_window_menu_atom =
342 XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", FALSE);
343 toolkit_action_force_quit_dialog_atom =
344 XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG",
345 FALSE);
346
347 status = decor_acquire_dm_session (xdisplay,
348 gdk_screen_get_number (gdkscreen),
349 "gwd", replace, &dm_sn_timestamp);
350 if (status != DECOR_ACQUIRE_STATUS_SUCCESS)
351 {
352 if (status == DECOR_ACQUIRE_STATUS_FAILED)
353 {
354 fprintf (stderr,
355 "%s: Could not acquire decoration manager "
356 "selection on screen %d display \"%s\"\n",
357 program_name, gdk_screen_get_number (gdkscreen),
358 DisplayString (xdisplay));
359 }
360 else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING)
361 {
362 fprintf (stderr,
363 "%s: Screen %d on display \"%s\" already "
364 "has a decoration manager; try using the "
365 "--replace option to replace the current "
366 "decoration manager.\n",
367 program_name, gdk_screen_get_number (gdkscreen),
368 DisplayString (xdisplay));
369 }
370
371 return 1;
372 }
373
374 for (i = 0; i < 3; i++)
375 {
376 for (j = 0; j < 3; j++)
377 {
378 if (cursor[i][j].shape != XC_left_ptr)
379 cursor[i][j].cursor =
380 XCreateFontCursor (xdisplay, cursor[i][j].shape);
381 }
382 }
383
384 xformat_rgba = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
385 xformat_rgb = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);
386
387 frame_table = g_hash_table_new (NULL, NULL);
388
389 screen = wnck_screen_get_default ();
390 wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
391
392 gdk_window_add_filter (NULL,
393 selection_event_filter_func,
394 NULL);
395
396 if (!minimal)
397 {
398 GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ());
399
400 gdk_window_add_filter (NULL,
401 event_filter_func,
402 NULL);
403
404 XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (),
405 &root_ret, &parent_ret, &children, &nchildren);
406
407 for (i = 0; i < nchildren; i++)
408 {
409 GdkWindow *toplevel = create_foreign_window (children[i]);
410
411 /* Need property notify on all windows */
412
413 gdk_window_set_events (toplevel,
414 gdk_window_get_events (toplevel) |
415 GDK_PROPERTY_CHANGE_MASK);
416 }
417
418 /* Need MapNotify on new windows */
419 gdk_window_set_events (root, gdk_window_get_events (root) |
420 GDK_STRUCTURE_MASK |
421 GDK_PROPERTY_CHANGE_MASK |
422 GDK_VISIBILITY_NOTIFY_MASK |
423 GDK_SUBSTRUCTURE_MASK);
424
425 connect_screen (screen);
426 }
427
428 if (!init_settings (screen))
429 {
430 fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]);
431 return 1;
432 }
433
434 decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen),
435 WINDOW_DECORATION_TYPE_PIXMAP |
436 WINDOW_DECORATION_TYPE_WINDOW);
437
438 update_default_decorations (gdkscreen);
439
440 gtk_main ();
441
442 return 0;
443}
0444
=== added file '.pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.h'
--- .pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.h 1970-01-01 00:00:00 +0000
+++ .pc/fix-883383.patch/unity/unity_window_decorator/src/gtk-window-decorator.h 2011-10-29 09:07:25 +0000
@@ -0,0 +1,1009 @@
1#ifndef _GTK_WINDOW_DECORATOR_H
2#define _GTK_WINDOW_DECORATOR_H
3#ifdef HAVE_CONFIG_H
4#include <config.h>
5#endif
6
7#include <decoration.h>
8
9#include <X11/Xlib.h>
10#include <X11/Xatom.h>
11#include <X11/cursorfont.h>
12#include <X11/extensions/Xrender.h>
13#include <X11/Xregion.h>
14
15#ifdef HAVE_GTK_2_24
16
17#ifndef GDK_DISABLE_DEPRECATED
18#define GDK_DISABLE_DEPRECATED
19#endif
20
21#define create_foreign_window(xid) \
22 gdk_x11_foreign_new_for_display (gdk_display_get_default (), \
23 xid);
24#else
25
26#define create_foreign_window(xid) \
27 gdk_window_foreign_new (xid)
28
29#ifdef GTK_DISABLE_DEPRECATED
30#undef GTK_DISABLE_DEPRECATED
31#endif
32
33#endif
34
35#include <gtk/gtk.h>
36#include <gdk/gdkx.h>
37#include <gdk/gdk.h>
38
39#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
40#include <gconf/gconf-client.h>
41#endif
42
43#ifdef USE_DBUS_GLIB
44#define DBUS_API_SUBJECT_TO_CHANGE
45#include <dbus/dbus.h>
46#include <dbus/dbus-glib-lowlevel.h>
47#endif
48
49#define WNCK_I_KNOW_THIS_IS_UNSTABLE
50#include <libwnck/libwnck.h>
51#include <libwnck/window-action-menu.h>
52
53#ifndef HAVE_LIBWNCK_2_19_4
54#define wnck_window_get_client_window_geometry wnck_window_get_geometry
55#endif
56
57#include <cairo.h>
58#include <cairo-xlib.h>
59
60#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 1, 0)
61#define CAIRO_EXTEND_PAD CAIRO_EXTEND_NONE
62#endif
63
64#include <pango/pango-context.h>
65#include <pango/pangocairo.h>
66
67#include <string.h>
68#include <stdlib.h>
69#include <math.h>
70#include <limits.h>
71#include <unistd.h>
72#include <sys/types.h>
73#include <signal.h>
74
75#include <libintl.h>
76#define _(x) gettext (x)
77#define N_(x) x
78
79#ifdef USE_METACITY
80#include <metacity-private/theme.h>
81#endif
82
83#define METACITY_GCONF_DIR "/apps/metacity/general"
84
85#define COMPIZ_USE_SYSTEM_FONT_KEY \
86METACITY_GCONF_DIR "/titlebar_uses_system_font"
87
88#define COMPIZ_TITLEBAR_FONT_KEY \
89METACITY_GCONF_DIR "/titlebar_font"
90
91#define COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY \
92METACITY_GCONF_DIR "/action_double_click_titlebar"
93
94#define COMPIZ_MIDDLE_CLICK_TITLEBAR_KEY \
95METACITY_GCONF_DIR "/action_middle_click_titlebar"
96
97#define COMPIZ_RIGHT_CLICK_TITLEBAR_KEY \
98METACITY_GCONF_DIR "/action_right_click_titlebar"
99
100#define COMPIZ_GCONF_DIR1 "/apps/compiz/plugins/decoration/allscreens/options"
101
102#define COMPIZ_SHADOW_RADIUS_KEY \
103COMPIZ_GCONF_DIR1 "/shadow_radius"
104
105#define COMPIZ_SHADOW_OPACITY_KEY \
106COMPIZ_GCONF_DIR1 "/shadow_opacity"
107
108#define COMPIZ_SHADOW_COLOR_KEY \
109COMPIZ_GCONF_DIR1 "/shadow_color"
110
111#define COMPIZ_SHADOW_OFFSET_X_KEY \
112COMPIZ_GCONF_DIR1 "/shadow_x_offset"
113
114#define COMPIZ_SHADOW_OFFSET_Y_KEY \
115COMPIZ_GCONF_DIR1 "/shadow_y_offset"
116
117#define META_THEME_KEY \
118METACITY_GCONF_DIR "/theme"
119
120#define META_BUTTON_LAYOUT_KEY \
121METACITY_GCONF_DIR "/button_layout"
122
123#define GCONF_DIR "/apps/gwd"
124
125#define USE_META_THEME_KEY \
126GCONF_DIR "/use_metacity_theme"
127
128#define META_THEME_OPACITY_KEY \
129GCONF_DIR "/metacity_theme_opacity"
130
131#define META_THEME_SHADE_OPACITY_KEY \
132GCONF_DIR "/metacity_theme_shade_opacity"
133
134#define META_THEME_ACTIVE_OPACITY_KEY \
135GCONF_DIR "/metacity_theme_active_opacity"
136
137#define META_THEME_ACTIVE_SHADE_OPACITY_KEY \
138GCONF_DIR "/metacity_theme_active_shade_opacity"
139
140#define BLUR_TYPE_KEY \
141GCONF_DIR "/blur_type"
142
143#define WHEEL_ACTION_KEY \
144GCONF_DIR "/mouse_wheel_action"
145
146#define DBUS_DEST "org.freedesktop.compiz"
147#define DBUS_PATH "/org/freedesktop/compiz/decor/screen0"
148#define DBUS_INTERFACE "org.freedesktop.compiz"
149#define DBUS_METHOD_GET "get"
150
151#define STROKE_ALPHA 0.6
152
153#define ICON_SPACE 20
154
155#define DOUBLE_CLICK_DISTANCE 8.0
156
157#define WM_MOVERESIZE_SIZE_TOPLEFT 0
158#define WM_MOVERESIZE_SIZE_TOP 1
159#define WM_MOVERESIZE_SIZE_TOPRIGHT 2
160#define WM_MOVERESIZE_SIZE_RIGHT 3
161#define WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
162#define WM_MOVERESIZE_SIZE_BOTTOM 5
163#define WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
164#define WM_MOVERESIZE_SIZE_LEFT 7
165#define WM_MOVERESIZE_MOVE 8
166#define WM_MOVERESIZE_SIZE_KEYBOARD 9
167#define WM_MOVERESIZE_MOVE_KEYBOARD 10
168
169#define SHADOW_RADIUS 8.0
170#define SHADOW_OPACITY 0.5
171#define SHADOW_OFFSET_X 1
172#define SHADOW_OFFSET_Y 1
173#define SHADOW_COLOR_RED 0x0000
174#define SHADOW_COLOR_GREEN 0x0000
175#define SHADOW_COLOR_BLUE 0x0000
176
177#define SHADOW_TYPE_ACTIVE_NORMAL 1
178#define SHADOW_TYPE_ACTIVE_MAX 2
179#define SHADOW_TYPE_INACTIVE_NORMAL 3
180#define SHADOW_TYPE_INACTIVE_MAX 4
181
182#define META_OPACITY 0.75
183#define META_SHADE_OPACITY TRUE
184#define META_ACTIVE_OPACITY 1.0
185#define META_ACTIVE_SHADE_OPACITY TRUE
186
187#define META_MAXIMIZED (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | \
188WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)
189
190#define CMDLINE_OPACITY (1 << 0)
191#define CMDLINE_OPACITY_SHADE (1 << 1)
192#define CMDLINE_ACTIVE_OPACITY (1 << 2)
193#define CMDLINE_ACTIVE_OPACITY_SHADE (1 << 3)
194#define CMDLINE_BLUR (1 << 4)
195#define CMDLINE_THEME (1 << 5)
196
197#define MWM_HINTS_DECORATIONS (1L << 1)
198
199#define MWM_DECOR_ALL (1L << 0)
200#define MWM_DECOR_BORDER (1L << 1)
201#define MWM_DECOR_HANDLE (1L << 2)
202#define MWM_DECOR_TITLE (1L << 3)
203#define MWM_DECOR_MENU (1L << 4)
204#define MWM_DECOR_MINIMIZE (1L << 5)
205#define MWM_DECOR_MAXIMIZE (1L << 6)
206
207#define PROP_MOTIF_WM_HINT_ELEMENTS 3
208
209/* to save some memory, value is specific to current decorations */
210#define TRANSLUCENT_CORNER_SIZE 3
211
212typedef struct {
213unsigned long flags;
214unsigned long functions;
215unsigned long decorations;
216} MwmHints;
217
218enum {
219 CLICK_ACTION_NONE,
220 CLICK_ACTION_SHADE,
221 CLICK_ACTION_MAXIMIZE,
222 CLICK_ACTION_MINIMIZE,
223 CLICK_ACTION_RAISE,
224 CLICK_ACTION_LOWER,
225 CLICK_ACTION_MENU
226};
227
228enum {
229 WHEEL_ACTION_NONE,
230 WHEEL_ACTION_SHADE
231};
232
233#define DOUBLE_CLICK_ACTION_DEFAULT CLICK_ACTION_MAXIMIZE
234#define MIDDLE_CLICK_ACTION_DEFAULT CLICK_ACTION_LOWER
235#define RIGHT_CLICK_ACTION_DEFAULT CLICK_ACTION_MENU
236#define WHEEL_ACTION_DEFAULT WHEEL_ACTION_NONE
237
238int double_click_action;
239int middle_click_action;
240int right_click_action;
241int wheel_action;
242
243extern gboolean minimal;
244extern double decoration_alpha;
245
246#define SWITCHER_SPACE 40
247
248extern decor_extents_t _shadow_extents;
249extern decor_extents_t _win_extents;
250extern decor_extents_t _max_win_extents;
251extern decor_extents_t _default_win_extents;
252extern decor_extents_t _switcher_extents;
253
254extern int titlebar_height;
255extern int max_titlebar_height;
256
257extern decor_context_t window_active_context;
258extern decor_context_t window_inactive_context;
259extern decor_context_t window_context_no_shadow;
260extern decor_context_t max_window_active_context;
261extern decor_context_t max_window_inactive_context;
262extern decor_context_t max_window_context_no_shadow;
263extern decor_context_t switcher_context;
264extern decor_context_t shadow_context;
265
266extern gdouble shadow_radius;
267extern gdouble shadow_opacity;
268extern gushort shadow_color[3];
269extern gint shadow_offset_x;
270extern gint shadow_offset_y;
271
272#ifdef USE_METACITY
273extern double meta_opacity;
274extern gboolean meta_shade_opacity;
275extern double meta_active_opacity;
276extern gboolean meta_active_shade_opacity;
277
278extern gboolean meta_button_layout_set;
279extern MetaButtonLayout meta_button_layout;
280#endif
281
282extern guint cmdline_options;
283
284extern decor_shadow_t *no_border_shadow;
285extern decor_shadow_t *border_active_shadow;
286extern decor_shadow_t *border_inactive_shadow;
287extern decor_shadow_t *border_no_shadow;
288extern decor_shadow_t *max_border_active_shadow;
289extern decor_shadow_t *max_border_inactive_shadow;
290extern decor_shadow_t *max_border_no_shadow;
291extern decor_shadow_t *switcher_shadow;
292
293extern GdkPixmap *decor_normal_pixmap;
294extern GdkPixmap *decor_active_pixmap;
295
296extern Atom frame_input_window_atom;
297extern Atom frame_output_window_atom;
298extern Atom win_decor_atom;
299extern Atom win_blur_decor_atom;
300extern Atom wm_move_resize_atom;
301extern Atom restack_window_atom;
302extern Atom select_window_atom;
303extern Atom mwm_hints_atom;
304extern Atom switcher_fg_atom;
305
306extern Atom toolkit_action_atom;
307extern Atom toolkit_action_window_menu_atom;
308extern Atom toolkit_action_force_quit_dialog_atom;
309
310extern Time dm_sn_timestamp;
311
312#define C(name) { 0, XC_ ## name }
313
314struct _cursor {
315 Cursor cursor;
316 unsigned int shape;
317};
318
319extern struct _cursor cursor[3][3];
320
321#define BUTTON_CLOSE 0
322#define BUTTON_MAX 1
323#define BUTTON_MIN 2
324#define BUTTON_MENU 3
325#define BUTTON_SHADE 4
326#define BUTTON_ABOVE 5
327#define BUTTON_STICK 6
328#define BUTTON_UNSHADE 7
329#define BUTTON_UNABOVE 8
330#define BUTTON_UNSTICK 9
331#define BUTTON_NUM 10
332
333struct _pos {
334 int x, y, w, h;
335 int xw, yh, ww, hh, yth, hth;
336};
337
338extern struct _pos pos[3][3], bpos[];
339
340typedef struct _decor_color {
341 double r;
342 double g;
343 double b;
344} decor_color_t;
345
346
347#define IN_EVENT_WINDOW (1 << 0)
348#define PRESSED_EVENT_WINDOW (1 << 1)
349
350typedef struct _decor_event {
351 guint time;
352 guint window;
353 guint x;
354 guint y;
355 guint x_root;
356 guint y_root;
357 guint button;
358} decor_event;
359
360typedef enum _decor_event_type {
361 GButtonPress = 1,
362 GButtonRelease,
363 GEnterNotify,
364 GLeaveNotify,
365 GMotionNotify
366} decor_event_type;
367
368typedef void (*event_callback) (WnckWindow *win,
369 decor_event *gtkwd_event,
370 decor_event_type gtkwd_type);
371
372typedef struct {
373 Window window;
374 Box pos;
375 event_callback callback;
376} event_window;
377
378typedef struct _decor {
379 WnckWindow *win;
380 event_window event_windows[3][3];
381 event_window button_windows[BUTTON_NUM];
382 Box *last_pos_entered;
383 guint button_states[BUTTON_NUM];
384 GdkPixmap *pixmap;
385 GdkPixmap *buffer_pixmap;
386 GdkWindow *frame_window;
387 GtkWidget *decor_window;
388 GtkWidget *decor_event_box;
389 GtkWidget *decor_image;
390 cairo_t *cr;
391 decor_layout_t border_layout;
392 decor_context_t *context;
393 decor_shadow_t *shadow;
394 Picture picture;
395 gint button_width;
396 gint width;
397 gint height;
398 gint client_width;
399 gint client_height;
400 gboolean decorated;
401 gboolean active;
402 PangoLayout *layout;
403 gchar *name;
404 cairo_pattern_t *icon;
405 GdkPixmap *icon_pixmap;
406 GdkPixbuf *icon_pixbuf;
407 WnckWindowState state;
408 WnckWindowActions actions;
409 XID prop_xid;
410 GtkWidget *force_quit_dialog;
411 GSList *transient_windows;
412 WnckWindow *transient_parent;
413 Bool created;
414 void (*draw) (struct _decor *d);
415} decor_t;
416
417void (*theme_draw_window_decoration) (decor_t *d);
418gboolean (*theme_calc_decoration_size) (decor_t *d,
419 int client_width,
420 int client_height,
421 int text_width,
422 int *width,
423 int *height);
424void (*theme_update_border_extents) (gint text_height);
425void (*theme_get_event_window_position) (decor_t *d,
426 gint i,
427 gint j,
428 gint width,
429 gint height,
430 gint *x,
431 gint *y,
432 gint *w,
433 gint *h);
434gboolean (*theme_get_button_position) (decor_t *d,
435 gint i,
436 gint width,
437 gint height,
438 gint *x,
439 gint *y,
440 gint *w,
441 gint *h);
442
443decor_shadow_t * (*theme_update_shadow) (gint shadow_type);
444
445void (*theme_get_shadow) (decor_t *d,
446 gint shadow_type);
447
448void (*theme_get_border_extents) (decor_extents_t *extents,
449 decor_extents_t *frame_extents,
450 decor_extents_t *extents_max,
451 decor_extents_t *frame_extents_max);
452
453extern char *program_name;
454
455extern GtkWidget *style_window_rgba;
456extern GtkWidget *style_window_rgb;
457extern GtkWidget *switcher_label;
458
459extern GHashTable *frame_table;
460extern GtkWidget *action_menu;
461extern gboolean action_menu_mapped;
462extern decor_color_t _title_color[2];
463extern PangoContext *pango_context;
464extern gint double_click_timeout;
465
466extern GSList *draw_list;
467extern guint draw_idle_id;
468
469extern PangoFontDescription *titlebar_font;
470extern gboolean use_system_font;
471extern gint text_height;
472
473#define BLUR_TYPE_NONE 0
474#define BLUR_TYPE_TITLEBAR 1
475#define BLUR_TYPE_ALL 2
476
477extern gint blur_type;
478
479extern GdkPixmap *switcher_pixmap;
480extern GdkPixmap *switcher_buffer_pixmap;
481extern gint switcher_width;
482extern gint switcher_height;
483extern Window switcher_selected_window;
484extern decor_t *switcher_window;
485
486extern XRenderPictFormat *xformat_rgba;
487extern XRenderPictFormat *xformat_rgb;
488
489extern Atom compiz_shadow_info_atom;
490extern Atom compiz_shadow_color_atom;
491
492/* gtk-window-decorator.c */
493
494double
495dist (double x1, double y1,
496 double x2, double y2);
497
498/* decorator.c */
499
500gboolean
501update_window_decoration_size (WnckWindow *win);
502
503void
504update_window_decoration_name (WnckWindow *win);
505
506gint
507max_window_name_width (WnckWindow *win);
508
509void
510update_default_decorations (GdkScreen *screen);
511
512void
513update_window_decoration_state (WnckWindow *win);
514
515void
516update_window_decoration_actions (WnckWindow *win);
517
518void
519update_window_decoration_icon (WnckWindow *win);
520
521void
522update_event_windows (WnckWindow *win);
523
524int
525update_shadow (void);
526
527void
528shadow_property_changed (WnckScreen *screen);
529
530void
531update_titlebar_font (void);
532
533void
534update_window_decoration_name (WnckWindow *win);
535
536void
537update_window_decoration (WnckWindow *win);
538
539void
540queue_decor_draw (decor_t *d);
541
542void
543copy_to_front_buffer (decor_t *d);
544
545void
546draw_border_shape (Display *xdisplay,
547 Pixmap pixmap,
548 Picture picture,
549 int width,
550 int height,
551 decor_context_t *c,
552 void *closure);
553
554
555/* wnck.c*/
556
557void
558decorations_changed (WnckScreen *screen);
559
560void
561connect_screen (WnckScreen *screen);
562
563void
564add_frame_window (WnckWindow *win,
565 Window frame,
566 Bool mode);
567
568void
569remove_frame_window (WnckWindow *win);
570
571void
572restack_window (WnckWindow *win,
573 int stack_mode);
574
575void connect_window (WnckWindow *win);
576
577/* blur.c */
578
579void
580decor_update_blur_property (decor_t *d,
581 int width,
582 int height,
583 Region top_region,
584 int top_offset,
585 Region bottom_region,
586 int bottom_offset,
587 Region left_region,
588 int left_offset,
589 Region right_region,
590 int right_offset);
591
592/* decorprops.c */
593
594void
595decor_update_window_property (decor_t *d);
596
597void
598decor_update_switcher_property (decor_t *d);
599
600/* cairo.c */
601
602#define CORNER_TOPLEFT (1 << 0)
603#define CORNER_TOPRIGHT (1 << 1)
604#define CORNER_BOTTOMRIGHT (1 << 2)
605#define CORNER_BOTTOMLEFT (1 << 3)
606
607#define SHADE_LEFT (1 << 0)
608#define SHADE_RIGHT (1 << 1)
609#define SHADE_TOP (1 << 2)
610#define SHADE_BOTTOM (1 << 3)
611
612void
613draw_shadow_background (decor_t *d,
614 cairo_t *cr,
615 decor_shadow_t *s,
616 decor_context_t *c);
617
618void
619draw_window_decoration (decor_t *d);
620
621void
622fill_rounded_rectangle (cairo_t *cr,
623 double x,
624 double y,
625 double w,
626 double h,
627 double radius,
628 int corner,
629 decor_color_t *c0,
630 double alpha0,
631 decor_color_t *c1,
632 double alpha1,
633 int gravity);
634
635void
636rounded_rectangle (cairo_t *cr,
637 double x,
638 double y,
639 double w,
640 double h,
641 double radius,
642 int corner);
643
644gboolean
645calc_decoration_size (decor_t *d,
646 gint w,
647 gint h,
648 gint name_width,
649 gint *width,
650 gint *height);
651
652void
653update_border_extents (gint text_height);
654
655void
656get_border_extents (decor_extents_t *extents,
657 decor_extents_t *frame_extents,
658 decor_extents_t *extents_max,
659 decor_extents_t *frame_extents_max);
660
661gboolean
662get_button_position (decor_t *d,
663 gint i,
664 gint width,
665 gint height,
666 gint *x,
667 gint *y,
668 gint *w,
669 gint *h);
670
671void
672get_event_window_position (decor_t *d,
673 gint i,
674 gint j,
675 gint width,
676 gint height,
677 gint *x,
678 gint *y,
679 gint *w,
680 gint *h);
681
682decor_shadow_t *
683cairo_update_shadow (gint shadow_type);
684
685void
686get_shadow (decor_t *, gint shadow_type);
687
688/* gdk.c */
689
690void
691gdk_cairo_set_source_color_alpha (cairo_t *cr,
692 GdkColor *color,
693 double alpha);
694
695inline GdkWindow *
696create_gdk_window (Window xframe);
697
698GdkColormap *
699get_colormap_for_drawable (GdkDrawable *d);
700
701XRenderPictFormat *
702get_format_for_drawable (decor_t *d, GdkDrawable *drawable);
703
704GdkPixmap *
705create_pixmap (int w,
706 int h,
707 int depth);
708
709GdkPixmap *
710pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, int depth);
711
712/* metacity.c */
713#ifdef USE_METACITY
714void
715meta_draw_window_decoration (decor_t *d);
716
717void
718meta_get_decoration_geometry (decor_t *d,
719 MetaTheme *theme,
720 MetaFrameFlags *flags,
721 MetaFrameGeometry *fgeom,
722 MetaButtonLayout *button_layout,
723 GdkRectangle *clip);
724
725void
726meta_calc_button_size (decor_t *d);
727
728gboolean
729meta_calc_decoration_size (decor_t *d,
730 gint w,
731 gint h,
732 gint name_width,
733 gint *width,
734 gint *height);
735
736gboolean
737meta_get_button_position (decor_t *d,
738 gint i,
739 gint width,
740 gint height,
741 gint *x,
742 gint *y,
743 gint *w,
744 gint *h);
745
746gboolean
747meta_button_present (MetaButtonLayout *button_layout,
748 MetaButtonFunction function);
749
750void
751meta_get_event_window_position (decor_t *d,
752 gint i,
753 gint j,
754 gint width,
755 gint height,
756 gint *x,
757 gint *y,
758 gint *w,
759 gint *h);
760void
761meta_update_border_extents (gint text_height);
762
763void
764meta_get_border_extents (decor_extents_t *extents,
765 decor_extents_t *frame_extents,
766 decor_extents_t *extents_max,
767 decor_extents_t *frame_extents_max);
768
769void
770meta_update_button_layout (const char *value);
771
772decor_shadow_t *
773meta_update_shadow (gint shadow_type);
774
775void
776meta_get_shadow (decor_t *, gint shadow_type);
777
778#endif
779/* switcher.c */
780
781#define SWITCHER_ALPHA 0xa0a0
782
783void
784draw_switcher_decoration (decor_t *d);
785
786gboolean
787update_switcher_window (Window popup,
788 Window selected);
789
790decor_t *
791switcher_window_opened (Window popup, Window selected);
792
793void
794switcher_window_closed ();
795
796/* events.c */
797
798void
799move_resize_window (WnckWindow *win,
800 int direction,
801 decor_event *gtkwd_event);
802
803void
804common_button_event (WnckWindow *win,
805 decor_event *gtkwd_event,
806 decor_event_type gtkwd_type,
807 int button,
808 int max);
809
810void
811close_button_event (WnckWindow *win,
812 decor_event *gtkwd_event,
813 decor_event_type gtkwd_type);
814
815void
816max_button_event (WnckWindow *win,
817 decor_event *gtkwd_event,
818 decor_event_type gtkwd_type);
819
820void
821min_button_event (WnckWindow *win,
822 decor_event *gtkwd_event,
823 decor_event_type gtkwd_type);
824
825void
826menu_button_event (WnckWindow *win,
827 decor_event *gtkwd_event,
828 decor_event_type gtkwd_type);
829
830void
831shade_button_event (WnckWindow *win,
832 decor_event *gtkwd_event,
833 decor_event_type gtkwd_type);
834
835void
836above_button_event (WnckWindow *win,
837 decor_event *gtkwd_event,
838 decor_event_type gtkwd_type);
839
840void
841stick_button_event (WnckWindow *win,
842 decor_event *gtkwd_event,
843 decor_event_type gtkwd_type);
844void
845unshade_button_event (WnckWindow *win,
846 decor_event *gtkwd_event,
847 decor_event_type gtkwd_type);
848
849void
850unabove_button_event (WnckWindow *win,
851 decor_event *gtkwd_event,
852 decor_event_type gtkwd_type);
853
854void
855unstick_button_event (WnckWindow *win,
856 decor_event *gtkwd_event,
857 decor_event_type gtkwd_type);
858
859void
860handle_title_button_event (WnckWindow *win,
861 int action,
862 decor_event *gtkwd_event);
863
864void
865handle_mouse_wheel_title_event (WnckWindow *win,
866 unsigned int button);
867
868void
869title_event (WnckWindow *win,
870 decor_event *gtkwd_event,
871 decor_event_type gtkwd_type);
872
873void
874frame_common_event (WnckWindow *win,
875 int direction,
876 decor_event *gtkwd_event,
877 decor_event_type gtkwd_type);
878
879void
880top_left_event (WnckWindow *win,
881 decor_event *gtkwd_event,
882 decor_event_type gtkwd_type);
883
884void
885top_event (WnckWindow *win,
886 decor_event *gtkwd_event,
887 decor_event_type gtkwd_type);
888
889void
890top_right_event (WnckWindow *win,
891 decor_event *gtkwd_event,
892 decor_event_type gtkwd_type);
893
894void
895left_event (WnckWindow *win,
896 decor_event *gtkwd_event,
897 decor_event_type gtkwd_type);
898void
899right_event (WnckWindow *win,
900 decor_event *gtkwd_event,
901 decor_event_type gtkwd_type);
902
903void
904bottom_left_event (WnckWindow *win,
905 decor_event *gtkwd_event,
906 decor_event_type gtkwd_type);
907
908void
909bottom_event (WnckWindow *win,
910 decor_event *gtkwd_event,
911 decor_event_type gtkwd_type);
912void
913bottom_right_event (WnckWindow *win,
914 decor_event *gtkwd_event,
915 decor_event_type gtkwd_type);
916
917void
918frame_window_realized (GtkWidget *widget,
919 gpointer data);
920
921event_callback
922find_event_callback_for_point (decor_t *d,
923 int x,
924 int y,
925 Bool *enter,
926 Bool *leave,
927 BoxPtr *entered_box);
928
929event_callback
930find_leave_event_callback (decor_t *d);
931
932void
933frame_handle_button_press (GtkWidget *widget,
934 GdkEventButton *event,
935 gpointer user_data);
936
937void
938frame_handle_button_release (GtkWidget *widget,
939 GdkEventButton *event,
940 gpointer user_data);
941
942void
943frame_handle_motion (GtkWidget *widget,
944 GdkEventMotion *event,
945 gpointer user_data);
946
947GdkFilterReturn
948selection_event_filter_func (GdkXEvent *gdkxevent,
949 GdkEvent *event,
950 gpointer data);
951
952GdkFilterReturn
953event_filter_func (GdkXEvent *gdkxevent,
954 GdkEvent *event,
955 gpointer data);
956
957/* forcequit.c */
958
959void
960show_force_quit_dialog (WnckWindow *win,
961 Time timestamp);
962
963void
964hide_force_quit_dialog (WnckWindow *win);
965
966/* actionmenu.c */
967
968void
969action_menu_map (WnckWindow *win,
970 long button,
971 Time time);
972
973/* util.c */
974
975double
976square (double x);
977
978double
979dist (double x1, double y1,
980 double x2, double y2);
981
982void
983shade (const decor_color_t *a,
984 decor_color_t *b,
985 float k);
986
987gboolean
988get_window_prop (Window xwindow,
989 Atom atom,
990 Window *val);
991
992unsigned int
993get_mwm_prop (Window xwindow);
994
995
996/* style.c */
997
998void
999update_style (GtkWidget *widget);
1000
1001void
1002style_changed (GtkWidget *widget);
1003
1004/* settings.c */
1005
1006gboolean
1007init_settings (WnckScreen *screen);
1008
1009#endif
01010
=== added file '.pc/fix-883383.patch/unity/unity_window_decorator/src/settings.c'
--- .pc/fix-883383.patch/unity/unity_window_decorator/src/settings.c 1970-01-01 00:00:00 +0000
+++ .pc/fix-883383.patch/unity/unity_window_decorator/src/settings.c 2011-10-29 09:07:25 +0000
@@ -0,0 +1,567 @@
1#include "gtk-window-decorator.h"
2
3/* TODO: Trash all of this and use a window property
4 * instead - much much cleaner!
5 */
6
7void
8shadow_property_changed (WnckScreen *s)
9{
10 GdkDisplay *display = gdk_display_get_default ();
11 Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
12 GdkScreen *screen = gdk_display_get_default_screen (display);
13 Window root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));
14 Atom actual;
15 int result, format;
16 unsigned long n, left;
17 unsigned char *prop_data;
18 gboolean changed = FALSE;
19 XTextProperty shadow_color_xtp;
20
21 result = XGetWindowProperty (xdisplay, root, compiz_shadow_info_atom,
22 0, 32768, 0, XA_INTEGER, &actual,
23 &format, &n, &left, &prop_data);
24
25 if (result != Success)
26 return;
27
28 if (n == 4)
29 {
30 long *data = (long *) prop_data;
31 gdouble radius = data[0];
32 gdouble opacity = data[1];
33 gint x_off = data[2];
34 gint y_off = data[3];
35
36 /* Radius and Opacity are multiplied by 1000 to keep precision,
37 * divide by that much to get our real radius and opacity
38 */
39 radius /= 1000;
40 opacity /= 1000;
41
42 changed = radius != shadow_radius ||
43 opacity != shadow_opacity ||
44 x_off != shadow_offset_x ||
45 y_off != shadow_offset_y;
46
47 shadow_radius = (gdouble) MAX (0.0, MIN (radius, 48.0));
48 shadow_opacity = (gdouble) MAX (0.0, MIN (opacity, 6.0));
49 shadow_offset_x = (gint) MAX (-16, MIN (x_off, 16));
50 shadow_offset_y = (gint) MAX (-16, MIN (y_off, 16));
51 }
52
53 XFree (prop_data);
54
55 result = XGetTextProperty (xdisplay, root, &shadow_color_xtp,
56 compiz_shadow_color_atom);
57
58 if (shadow_color_xtp.value)
59 {
60 int ret_count = 0;
61 char **t_data = NULL;
62
63 XTextPropertyToStringList (&shadow_color_xtp, &t_data, &ret_count);
64
65 if (ret_count == 1)
66 {
67 int c[4];
68
69 if (sscanf (t_data[0], "#%2x%2x%2x%2x",
70 &c[0], &c[1], &c[2], &c[3]) == 4)
71 {
72 shadow_color[0] = c[0] << 8 | c[0];
73 shadow_color[1] = c[1] << 8 | c[1];
74 shadow_color[2] = c[2] << 8 | c[2];
75 changed = TRUE;
76 }
77 }
78
79 XFree (shadow_color_xtp.value);
80 if (t_data)
81 XFreeStringList (t_data);
82 }
83
84 if (changed)
85 decorations_changed (s);
86}
87
88#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
89static gboolean
90blur_settings_changed (GConfClient *client)
91{
92 gchar *type;
93 int new_type = blur_type;
94
95 if (cmdline_options & CMDLINE_BLUR)
96 return FALSE;
97
98 type = gconf_client_get_string (client,
99 BLUR_TYPE_KEY,
100 NULL);
101
102 if (type)
103 {
104 if (strcmp (type, "titlebar") == 0)
105 new_type = BLUR_TYPE_TITLEBAR;
106 else if (strcmp (type, "all") == 0)
107 new_type = BLUR_TYPE_ALL;
108 else if (strcmp (type, "none") == 0)
109 new_type = BLUR_TYPE_NONE;
110
111 g_free (type);
112 }
113
114 if (new_type != blur_type)
115 {
116 blur_type = new_type;
117 return TRUE;
118 }
119
120 return FALSE;
121}
122
123static gboolean
124theme_changed (GConfClient *client)
125{
126
127#ifdef USE_METACITY
128 gboolean use_meta_theme;
129
130 if (cmdline_options & CMDLINE_THEME)
131 return FALSE;
132
133 use_meta_theme = gconf_client_get_bool (client,
134 USE_META_THEME_KEY,
135 NULL);
136
137 if (use_meta_theme)
138 {
139 gchar *theme;
140
141 theme = gconf_client_get_string (client,
142 META_THEME_KEY,
143 NULL);
144
145 if (theme)
146 {
147 meta_theme_set_current (theme, TRUE);
148 if (!meta_theme_get_current ())
149 use_meta_theme = FALSE;
150
151 g_free (theme);
152 }
153 else
154 {
155 use_meta_theme = FALSE;
156 }
157 }
158
159 if (use_meta_theme)
160 {
161 theme_draw_window_decoration = meta_draw_window_decoration;
162 theme_calc_decoration_size = meta_calc_decoration_size;
163 theme_update_border_extents = meta_update_border_extents;
164 theme_get_event_window_position = meta_get_event_window_position;
165 theme_get_button_position = meta_get_button_position;
166 theme_update_shadow = meta_update_shadow;
167 theme_get_shadow = meta_get_shadow;
168 theme_get_border_extents = meta_get_border_extents;
169 }
170 else
171 {
172 theme_draw_window_decoration = draw_window_decoration;
173 theme_calc_decoration_size = calc_decoration_size;
174 theme_update_border_extents = update_border_extents;
175 theme_get_event_window_position = get_event_window_position;
176 theme_get_button_position = get_button_position;
177 theme_update_shadow = cairo_update_shadow;
178 theme_get_shadow = get_shadow;
179 theme_get_border_extents = get_border_extents;
180 }
181
182 return TRUE;
183#else
184 theme_draw_window_decoration = draw_window_decoration;
185 theme_calc_decoration_size = calc_decoration_size;
186 theme_update_border_extents = update_border_extents;
187 theme_get_event_window_position = get_event_window_position;
188 theme_get_button_position = get_button_position;
189 theme_get_border_extents = get_border_extents;
190
191 return FALSE;
192#endif
193
194}
195
196static gboolean
197theme_opacity_changed (GConfClient *client)
198{
199
200#ifdef USE_METACITY
201 gboolean shade_opacity, changed = FALSE;
202 gdouble opacity;
203
204 opacity = gconf_client_get_float (client,
205 META_THEME_OPACITY_KEY,
206 NULL);
207
208 if (!(cmdline_options & CMDLINE_OPACITY) &&
209 opacity != meta_opacity)
210 {
211 meta_opacity = opacity;
212 changed = TRUE;
213 }
214
215 if (opacity < 1.0)
216 {
217 shade_opacity = gconf_client_get_bool (client,
218 META_THEME_SHADE_OPACITY_KEY,
219 NULL);
220
221 if (!(cmdline_options & CMDLINE_OPACITY_SHADE) &&
222 shade_opacity != meta_shade_opacity)
223 {
224 meta_shade_opacity = shade_opacity;
225 changed = TRUE;
226 }
227 }
228
229 opacity = gconf_client_get_float (client,
230 META_THEME_ACTIVE_OPACITY_KEY,
231 NULL);
232
233 if (!(cmdline_options & CMDLINE_ACTIVE_OPACITY) &&
234 opacity != meta_active_opacity)
235 {
236 meta_active_opacity = opacity;
237 changed = TRUE;
238 }
239
240 if (opacity < 1.0)
241 {
242 shade_opacity =
243 gconf_client_get_bool (client,
244 META_THEME_ACTIVE_SHADE_OPACITY_KEY,
245 NULL);
246
247 if (!(cmdline_options & CMDLINE_ACTIVE_OPACITY_SHADE) &&
248 shade_opacity != meta_active_shade_opacity)
249 {
250 meta_active_shade_opacity = shade_opacity;
251 changed = TRUE;
252 }
253 }
254
255 return changed;
256#else
257 return FALSE;
258#endif
259
260}
261
262static gboolean
263button_layout_changed (GConfClient *client)
264{
265
266#ifdef USE_METACITY
267 gchar *button_layout;
268
269 button_layout = gconf_client_get_string (client,
270 META_BUTTON_LAYOUT_KEY,
271 NULL);
272
273 if (button_layout)
274 {
275 meta_update_button_layout (button_layout);
276
277 meta_button_layout_set = TRUE;
278
279 g_free (button_layout);
280
281 return TRUE;
282 }
283
284 if (meta_button_layout_set)
285 {
286 meta_button_layout_set = FALSE;
287 return TRUE;
288 }
289#endif
290
291 return FALSE;
292}
293
294static void
295titlebar_font_changed (GConfClient *client)
296{
297 gchar *str;
298
299 str = gconf_client_get_string (client,
300 COMPIZ_TITLEBAR_FONT_KEY,
301 NULL);
302 if (!str)
303 str = g_strdup ("Sans Bold 12");
304
305 if (titlebar_font)
306 pango_font_description_free (titlebar_font);
307
308 titlebar_font = pango_font_description_from_string (str);
309
310 g_free (str);
311}
312
313static void
314titlebar_click_action_changed (GConfClient *client,
315 const gchar *key,
316 int *action_value,
317 int default_value)
318{
319 gchar *action;
320
321 *action_value = default_value;
322
323 action = gconf_client_get_string (client, key, NULL);
324 if (action)
325 {
326 if (strcmp (action, "toggle_shade") == 0)
327 *action_value = CLICK_ACTION_SHADE;
328 else if (strcmp (action, "toggle_maximize") == 0)
329 *action_value = CLICK_ACTION_MAXIMIZE;
330 else if (strcmp (action, "minimize") == 0)
331 *action_value = CLICK_ACTION_MINIMIZE;
332 else if (strcmp (action, "raise") == 0)
333 *action_value = CLICK_ACTION_RAISE;
334 else if (strcmp (action, "lower") == 0)
335 *action_value = CLICK_ACTION_LOWER;
336 else if (strcmp (action, "menu") == 0)
337 *action_value = CLICK_ACTION_MENU;
338 else if (strcmp (action, "none") == 0)
339 *action_value = CLICK_ACTION_NONE;
340
341 g_free (action);
342 }
343}
344
345static void
346wheel_action_changed (GConfClient *client)
347{
348 gchar *action;
349
350 wheel_action = WHEEL_ACTION_DEFAULT;
351
352 action = gconf_client_get_string (client, WHEEL_ACTION_KEY, NULL);
353 if (action)
354 {
355 if (strcmp (action, "shade") == 0)
356 wheel_action = WHEEL_ACTION_SHADE;
357 else if (strcmp (action, "none") == 0)
358 wheel_action = WHEEL_ACTION_NONE;
359
360 g_free (action);
361 }
362}
363
364static void
365value_changed (GConfClient *client,
366 const gchar *key,
367 GConfValue *value,
368 void *data)
369{
370 gboolean changed = FALSE;
371
372 if (strcmp (key, COMPIZ_USE_SYSTEM_FONT_KEY) == 0)
373 {
374 if (gconf_client_get_bool (client,
375 COMPIZ_USE_SYSTEM_FONT_KEY,
376 NULL) != use_system_font)
377 {
378 use_system_font = !use_system_font;
379 changed = TRUE;
380 }
381 }
382 else if (strcmp (key, COMPIZ_TITLEBAR_FONT_KEY) == 0)
383 {
384 titlebar_font_changed (client);
385 changed = !use_system_font;
386 }
387 else if (strcmp (key, COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY) == 0)
388 {
389 titlebar_click_action_changed (client, key,
390 &double_click_action,
391 DOUBLE_CLICK_ACTION_DEFAULT);
392 }
393 else if (strcmp (key, COMPIZ_MIDDLE_CLICK_TITLEBAR_KEY) == 0)
394 {
395 titlebar_click_action_changed (client, key,
396 &middle_click_action,
397 MIDDLE_CLICK_ACTION_DEFAULT);
398 }
399 else if (strcmp (key, COMPIZ_RIGHT_CLICK_TITLEBAR_KEY) == 0)
400 {
401 titlebar_click_action_changed (client, key,
402 &right_click_action,
403 RIGHT_CLICK_ACTION_DEFAULT);
404 }
405 else if (strcmp (key, WHEEL_ACTION_KEY) == 0)
406 {
407 wheel_action_changed (client);
408 }
409 else if (strcmp (key, BLUR_TYPE_KEY) == 0)
410 {
411 if (blur_settings_changed (client))
412 changed = TRUE;
413 }
414 else if (strcmp (key, USE_META_THEME_KEY) == 0 ||
415 strcmp (key, META_THEME_KEY) == 0)
416 {
417 if (theme_changed (client))
418 changed = TRUE;
419 }
420 else if (strcmp (key, META_BUTTON_LAYOUT_KEY) == 0)
421 {
422 if (button_layout_changed (client))
423 changed = TRUE;
424 }
425 else if (strcmp (key, META_THEME_OPACITY_KEY) == 0 ||
426 strcmp (key, META_THEME_SHADE_OPACITY_KEY) == 0 ||
427 strcmp (key, META_THEME_ACTIVE_OPACITY_KEY) == 0 ||
428 strcmp (key, META_THEME_ACTIVE_SHADE_OPACITY_KEY) == 0)
429 {
430 if (theme_opacity_changed (client))
431 changed = TRUE;
432 }
433
434 if (changed)
435 decorations_changed (data);
436}
437#endif
438
439gboolean
440init_settings (WnckScreen *screen)
441{
442 GtkSettings *settings;
443 GdkScreen *gdkscreen;
444 GdkColormap *colormap;
445 AtkObject *switcher_label_obj;
446
447#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
448 GConfClient *gconf;
449
450 gconf = gconf_client_get_default ();
451
452 gconf_client_add_dir (gconf,
453 GCONF_DIR,
454 GCONF_CLIENT_PRELOAD_ONELEVEL,
455 NULL);
456
457 gconf_client_add_dir (gconf,
458 METACITY_GCONF_DIR,
459 GCONF_CLIENT_PRELOAD_ONELEVEL,
460 NULL);
461
462 g_signal_connect (G_OBJECT (gconf),
463 "value_changed",
464 G_CALLBACK (value_changed),
465 screen);
466#endif
467
468 style_window_rgba = gtk_window_new (GTK_WINDOW_POPUP);
469
470 gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
471 colormap = gdk_screen_get_rgba_colormap (gdkscreen);
472 if (colormap)
473 gtk_widget_set_colormap (style_window_rgba, colormap);
474
475 gtk_widget_realize (style_window_rgba);
476
477 switcher_label = gtk_label_new ("");
478 switcher_label_obj = gtk_widget_get_accessible (switcher_label);
479 atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
480 gtk_container_add (GTK_CONTAINER (style_window_rgba), switcher_label);
481
482 gtk_widget_set_size_request (style_window_rgba, 0, 0);
483 gtk_window_move (GTK_WINDOW (style_window_rgba), -100, -100);
484 gtk_widget_show_all (style_window_rgba);
485
486 g_signal_connect_object (style_window_rgba, "style-set",
487 G_CALLBACK (style_changed),
488 0, 0);
489
490 settings = gtk_widget_get_settings (style_window_rgba);
491
492 g_object_get (G_OBJECT (settings), "gtk-double-click-time",
493 &double_click_timeout, NULL);
494
495 pango_context = gtk_widget_create_pango_context (style_window_rgba);
496
497 style_window_rgb = gtk_window_new (GTK_WINDOW_POPUP);
498
499 gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
500 colormap = gdk_screen_get_rgb_colormap (gdkscreen);
501 if (colormap)
502 gtk_widget_set_colormap (style_window_rgb, colormap);
503
504 gtk_widget_realize (style_window_rgb);
505
506 switcher_label = gtk_label_new ("");
507 switcher_label_obj = gtk_widget_get_accessible (switcher_label);
508 atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
509 gtk_container_add (GTK_CONTAINER (style_window_rgb), switcher_label);
510
511 gtk_widget_set_size_request (style_window_rgb, 0, 0);
512 gtk_window_move (GTK_WINDOW (style_window_rgb), -100, -100);
513 gtk_widget_show_all (style_window_rgb);
514
515 g_signal_connect_object (style_window_rgb, "style-set",
516 G_CALLBACK (style_changed),
517 0, 0);
518
519 settings = gtk_widget_get_settings (style_window_rgb);
520
521 g_object_get (G_OBJECT (settings), "gtk-double-click-time",
522 &double_click_timeout, NULL);
523
524 pango_context = gtk_widget_create_pango_context (style_window_rgb);
525
526#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
527 use_system_font = gconf_client_get_bool (gconf,
528 COMPIZ_USE_SYSTEM_FONT_KEY,
529 NULL);
530 theme_changed (gconf);
531 theme_opacity_changed (gconf);
532 button_layout_changed (gconf);
533#endif
534
535 update_style (style_window_rgba);
536 update_style (style_window_rgb);
537#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
538 titlebar_font_changed (gconf);
539#endif
540
541 update_titlebar_font ();
542
543#ifdef USE_GCONF_UNITY_WINDOW_DECORATOR
544 titlebar_click_action_changed (gconf,
545 COMPIZ_DOUBLE_CLICK_TITLEBAR_KEY,
546 &double_click_action,
547 DOUBLE_CLICK_ACTION_DEFAULT);
548 titlebar_click_action_changed (gconf,
549 COMPIZ_MIDDLE_CLICK_TITLEBAR_KEY,
550 &middle_click_action,
551 MIDDLE_CLICK_ACTION_DEFAULT);
552 titlebar_click_action_changed (gconf,
553 COMPIZ_RIGHT_CLICK_TITLEBAR_KEY,
554 &right_click_action,
555 RIGHT_CLICK_ACTION_DEFAULT);
556 wheel_action_changed (gconf);
557 blur_settings_changed (gconf);
558#endif
559
560 (*theme_update_border_extents) (text_height);
561
562 shadow_property_changed (screen);
563
564 update_shadow ();
565
566 return TRUE;
567}
0568
=== modified file 'debian/changelog'
--- debian/changelog 2011-10-12 10:44:49 +0000
+++ debian/changelog 2011-10-29 09:07:25 +0000
@@ -1,3 +1,12 @@
1compiz (1:0.9.6+bzr20110929-0ubuntu6) precise; urgency=low
2
3 * debian/patches/fix-881329.patch:
4 - Alt+click should raise with raise-on-click disabled (LP: #881329)
5 * debian/patches/fix-883383.patch:
6 - Drag title bar should not raise if raise-on-click is disabled (LP: #883383)
7
8 -- James Pharaoh <james@phsys.co.uk> Tue, 25 Oct 2011 12:07:03 +0200
9
1compiz (1:0.9.6+bzr20110929-0ubuntu5) oneiric-proposed; urgency=low10compiz (1:0.9.6+bzr20110929-0ubuntu5) oneiric-proposed; urgency=low
211
3 * debian/patches/fix-864330.patch:12 * debian/patches/fix-864330.patch:
413
=== added file 'debian/patches/fix-881329.patch'
--- debian/patches/fix-881329.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/fix-881329.patch 2011-10-29 09:07:25 +0000
@@ -0,0 +1,49 @@
1Index: fix-881329/plugins/move/src/move.cpp
2===================================================================
3--- fix-881329.orig/plugins/move/src/move.cpp 2011-10-25 11:55:52.191836766 +0200
4+++ fix-881329/plugins/move/src/move.cpp 2011-10-25 11:56:01.683903132 +0200
5@@ -153,6 +153,8 @@
6 if (mw->gWindow)
7 mw->gWindow->glPaintSetEnabled (mw, true);
8 }
9+
10+ ms->hasMoved = false;
11 }
12 }
13
14@@ -177,7 +179,12 @@
15 /* update window attributes as window constraints may have
16 changed - needed e.g. if a maximized window was moved
17 to another output device */
18- ms->w->updateAttributes (CompStackingUpdateModeNone);
19+ /* also raise on alt-click when raise on click is disabled */
20+ bool raiseOnClick = screen->getOption ("raise_on_click")->value ().b ();
21+ if (! raiseOnClick && ! ms->hasMoved)
22+ ms->w->updateAttributes (CompStackingUpdateModeAboveFullscreen);
23+ else
24+ ms->w->updateAttributes (CompStackingUpdateModeNone);
25
26 ms->w->ungrabNotify ();
27
28@@ -504,6 +511,8 @@
29
30 ms->x -= dx;
31 ms->y -= dy;
32+
33+ ms->hasMoved = true;
34 }
35 }
36 }
37Index: fix-881329/plugins/move/src/move.h
38===================================================================
39--- fix-881329.orig/plugins/move/src/move.h 2011-10-25 11:55:52.215836933 +0200
40+++ fix-881329/plugins/move/src/move.h 2011-10-25 11:56:01.683903132 +0200
41@@ -90,6 +90,8 @@
42 bool hasCompositing;
43
44 bool yConstrained;
45+
46+ bool hasMoved;
47 };
48
49 class MoveWindow :
050
=== added file 'debian/patches/fix-883383.patch'
--- debian/patches/fix-883383.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/fix-883383.patch 2011-10-29 09:07:25 +0000
@@ -0,0 +1,77 @@
1Index: fix-883383/unity/unity_window_decorator/src/events.c
2===================================================================
3--- fix-883383.orig/unity/unity_window_decorator/src/events.c 2011-10-29 10:22:29.079644323 +0200
4+++ fix-883383/unity/unity_window_decorator/src/events.c 2011-10-29 10:22:31.631675000 +0200
5@@ -450,7 +450,8 @@
6 last_button_x = gtkwd_event->x;
7 last_button_y = gtkwd_event->y;
8
9- restack_window (win, Above);
10+ if (raise_on_click)
11+ restack_window (win, Above);
12
13 move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event);
14 }
15Index: fix-883383/unity/unity_window_decorator/src/gtk-window-decorator.c
16===================================================================
17--- fix-883383.orig/unity/unity_window_decorator/src/gtk-window-decorator.c 2011-10-29 10:22:29.099644474 +0200
18+++ fix-883383/unity/unity_window_decorator/src/gtk-window-decorator.c 2011-10-29 10:22:31.631675000 +0200
19@@ -25,6 +25,8 @@
20
21 double decoration_alpha = 0.5;
22
23+gboolean raise_on_click = TRUE;
24+
25 #define SWITCHER_SPACE 40
26
27 decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
28Index: fix-883383/unity/unity_window_decorator/src/gtk-window-decorator.h
29===================================================================
30--- fix-883383.orig/unity/unity_window_decorator/src/gtk-window-decorator.h 2011-10-29 10:22:29.123644654 +0200
31+++ fix-883383/unity/unity_window_decorator/src/gtk-window-decorator.h 2011-10-29 10:22:31.631675000 +0200
32@@ -97,6 +97,9 @@
33 #define COMPIZ_RIGHT_CLICK_TITLEBAR_KEY \
34 METACITY_GCONF_DIR "/action_right_click_titlebar"
35
36+#define COMPIZ_RAISE_ON_CLICK_KEY \
37+METACITY_GCONF_DIR "/raise_on_click"
38+
39 #define COMPIZ_GCONF_DIR1 "/apps/compiz/plugins/decoration/allscreens/options"
40
41 #define COMPIZ_SHADOW_RADIUS_KEY \
42@@ -243,6 +246,8 @@
43 extern gboolean minimal;
44 extern double decoration_alpha;
45
46+extern gboolean raise_on_click;
47+
48 #define SWITCHER_SPACE 40
49
50 extern decor_extents_t _shadow_extents;
51Index: fix-883383/unity/unity_window_decorator/src/settings.c
52===================================================================
53--- fix-883383.orig/unity/unity_window_decorator/src/settings.c 2011-10-29 10:22:29.151644865 +0200
54+++ fix-883383/unity/unity_window_decorator/src/settings.c 2011-10-29 10:22:31.631675000 +0200
55@@ -402,6 +402,12 @@
56 &right_click_action,
57 RIGHT_CLICK_ACTION_DEFAULT);
58 }
59+ else if (strcmp (key, COMPIZ_RAISE_ON_CLICK_KEY) == 0)
60+ {
61+ raise_on_click = gconf_client_get_bool (client,
62+ COMPIZ_RAISE_ON_CLICK_KEY,
63+ NULL);
64+ }
65 else if (strcmp (key, WHEEL_ACTION_KEY) == 0)
66 {
67 wheel_action_changed (client);
68@@ -555,6 +561,9 @@
69 RIGHT_CLICK_ACTION_DEFAULT);
70 wheel_action_changed (gconf);
71 blur_settings_changed (gconf);
72+ raise_on_click = gconf_client_get_bool (gconf,
73+ COMPIZ_RAISE_ON_CLICK_KEY,
74+ NULL);
75 #endif
76
77 (*theme_update_border_extents) (text_height);
078
=== modified file 'debian/patches/series'
--- debian/patches/series 2011-10-12 10:44:49 +0000
+++ debian/patches/series 2011-10-29 09:07:25 +0000
@@ -12,3 +12,5 @@
12fix-832150.patch12fix-832150.patch
13fix-864478.patch13fix-864478.patch
14fix-864330.patch14fix-864330.patch
15fix-881329.patch
16fix-883383.patch
1517
=== modified file 'plugins/move/src/move.cpp'
--- plugins/move/src/move.cpp 2011-10-12 10:44:49 +0000
+++ plugins/move/src/move.cpp 2011-10-29 09:07:25 +0000
@@ -153,6 +153,8 @@
153 if (mw->gWindow)153 if (mw->gWindow)
154 mw->gWindow->glPaintSetEnabled (mw, true);154 mw->gWindow->glPaintSetEnabled (mw, true);
155 }155 }
156
157 ms->hasMoved = false;
156 }158 }
157 }159 }
158160
@@ -177,7 +179,12 @@
177 /* update window attributes as window constraints may have179 /* update window attributes as window constraints may have
178 changed - needed e.g. if a maximized window was moved180 changed - needed e.g. if a maximized window was moved
179 to another output device */181 to another output device */
180 ms->w->updateAttributes (CompStackingUpdateModeNone);182 /* also raise on alt-click when raise on click is disabled */
183 bool raiseOnClick = screen->getOption ("raise_on_click")->value ().b ();
184 if (! raiseOnClick && ! ms->hasMoved)
185 ms->w->updateAttributes (CompStackingUpdateModeAboveFullscreen);
186 else
187 ms->w->updateAttributes (CompStackingUpdateModeNone);
181188
182 ms->w->ungrabNotify ();189 ms->w->ungrabNotify ();
183190
@@ -504,6 +511,8 @@
504511
505 ms->x -= dx;512 ms->x -= dx;
506 ms->y -= dy;513 ms->y -= dy;
514
515 ms->hasMoved = true;
507 }516 }
508 }517 }
509}518}
510519
=== modified file 'plugins/move/src/move.h'
--- plugins/move/src/move.h 2011-09-28 14:15:21 +0000
+++ plugins/move/src/move.h 2011-10-29 09:07:25 +0000
@@ -90,6 +90,8 @@
90 bool hasCompositing;90 bool hasCompositing;
9191
92 bool yConstrained;92 bool yConstrained;
93
94 bool hasMoved;
93};95};
9496
95class MoveWindow :97class MoveWindow :
9698
=== modified file 'unity/unity_window_decorator/src/events.c'
--- unity/unity_window_decorator/src/events.c 2011-09-28 14:15:21 +0000
+++ unity/unity_window_decorator/src/events.c 2011-10-29 09:07:25 +0000
@@ -450,7 +450,8 @@
450 last_button_x = gtkwd_event->x;450 last_button_x = gtkwd_event->x;
451 last_button_y = gtkwd_event->y;451 last_button_y = gtkwd_event->y;
452452
453 restack_window (win, Above);453 if (raise_on_click)
454 restack_window (win, Above);
454455
455 move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event);456 move_resize_window (win, WM_MOVERESIZE_MOVE, gtkwd_event);
456 }457 }
457458
=== modified file 'unity/unity_window_decorator/src/gtk-window-decorator.c'
--- unity/unity_window_decorator/src/gtk-window-decorator.c 2011-08-23 18:19:11 +0000
+++ unity/unity_window_decorator/src/gtk-window-decorator.c 2011-10-29 09:07:25 +0000
@@ -25,6 +25,8 @@
2525
26double decoration_alpha = 0.5;26double decoration_alpha = 0.5;
2727
28gboolean raise_on_click = TRUE;
29
28#define SWITCHER_SPACE 4030#define SWITCHER_SPACE 40
2931
30decor_extents_t _shadow_extents = { 0, 0, 0, 0 };32decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
3133
=== modified file 'unity/unity_window_decorator/src/gtk-window-decorator.h'
--- unity/unity_window_decorator/src/gtk-window-decorator.h 2011-08-23 18:19:11 +0000
+++ unity/unity_window_decorator/src/gtk-window-decorator.h 2011-10-29 09:07:25 +0000
@@ -97,6 +97,9 @@
97#define COMPIZ_RIGHT_CLICK_TITLEBAR_KEY \97#define COMPIZ_RIGHT_CLICK_TITLEBAR_KEY \
98METACITY_GCONF_DIR "/action_right_click_titlebar"98METACITY_GCONF_DIR "/action_right_click_titlebar"
9999
100#define COMPIZ_RAISE_ON_CLICK_KEY \
101METACITY_GCONF_DIR "/raise_on_click"
102
100#define COMPIZ_GCONF_DIR1 "/apps/compiz/plugins/decoration/allscreens/options"103#define COMPIZ_GCONF_DIR1 "/apps/compiz/plugins/decoration/allscreens/options"
101104
102#define COMPIZ_SHADOW_RADIUS_KEY \105#define COMPIZ_SHADOW_RADIUS_KEY \
@@ -243,6 +246,8 @@
243extern gboolean minimal;246extern gboolean minimal;
244extern double decoration_alpha;247extern double decoration_alpha;
245248
249extern gboolean raise_on_click;
250
246#define SWITCHER_SPACE 40251#define SWITCHER_SPACE 40
247252
248extern decor_extents_t _shadow_extents;253extern decor_extents_t _shadow_extents;
249254
=== modified file 'unity/unity_window_decorator/src/settings.c'
--- unity/unity_window_decorator/src/settings.c 2011-08-23 18:19:11 +0000
+++ unity/unity_window_decorator/src/settings.c 2011-10-29 09:07:25 +0000
@@ -402,6 +402,12 @@
402 &right_click_action,402 &right_click_action,
403 RIGHT_CLICK_ACTION_DEFAULT);403 RIGHT_CLICK_ACTION_DEFAULT);
404 }404 }
405 else if (strcmp (key, COMPIZ_RAISE_ON_CLICK_KEY) == 0)
406 {
407 raise_on_click = gconf_client_get_bool (client,
408 COMPIZ_RAISE_ON_CLICK_KEY,
409 NULL);
410 }
405 else if (strcmp (key, WHEEL_ACTION_KEY) == 0)411 else if (strcmp (key, WHEEL_ACTION_KEY) == 0)
406 {412 {
407 wheel_action_changed (client);413 wheel_action_changed (client);
@@ -555,6 +561,9 @@
555 RIGHT_CLICK_ACTION_DEFAULT);561 RIGHT_CLICK_ACTION_DEFAULT);
556 wheel_action_changed (gconf);562 wheel_action_changed (gconf);
557 blur_settings_changed (gconf);563 blur_settings_changed (gconf);
564 raise_on_click = gconf_client_get_bool (gconf,
565 COMPIZ_RAISE_ON_CLICK_KEY,
566 NULL);
558#endif567#endif
559568
560 (*theme_update_border_extents) (text_height);569 (*theme_update_border_extents) (text_height);

Subscribers

People subscribed via source and target branches