~ubuntu-branches/ubuntu/precise/gnome-do/precise-backports

« back to all changes in this revision

Viewing changes to Do.Interface.Linux.Docky/src/Docky.Interface/DockWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-06-27 10:40:45 UTC
  • mfrom: (1.1.8 upstream) (0.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090627104045-7st10y1cqr6dpz37
* New upstream release
  + No longer uses a plugin repository.  Fixes many plugin-
    related issues. (LP: #343096, LP: #330025, LP #345001)
  + No longer blocks on "About Do" (LP: #361679)
  + Reacts correctly when a Composite manager is enabled/
    disabled at runtime. (LP: #346347, LP: #390150)
  + Fixes for space reserved by Docky blocking drag and 
    drop operations. (LP: #354729, LP: #347052, LP: #382843)
  + Properly sets "Hidden" key on autostart files in response to 
    "Start on login" option.  (Closes: #526023) (LP: #369988)
* debian/patches/10_application_search_path:
  + Drop; included upstream
* debian/patches/10_sk_translation_update:
  + Import sk translation update from Debian BTS.
    (Closes: #531779)
* debian/patches/11_fix_autostart_when_directory_does_not_exist:
  + Patch from upstream.  Fixes the "Start on login" option when the 
    ~/.config/autostart directory does not exist. (LP: #393729)
* debian/control:
  + Update standards version to 3.8.2; no changes required.
  + Add libtool to Build-Depends; required for autoreconf.
  + Add Recommends: on new gnome-do-docklets package.
* debian/gnome-do.1
  + Fix spelling: GNOME-Do => GNOME Do.
  + Miscelaneous lintian fixes; NAME section, escaping minus signs with \-
* debian/copyright:
  + Update for new copyright holders.
  + Minor update to DEP-5 format

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
using Cairo;
26
26
 
27
27
using Docky.Utilities;
28
 
using Docky.XLib;
29
28
 
30
29
using Do.Universe;
31
30
using Do.Platform;
 
31
using Do.Platform.Linux;
32
32
using Do.Interface;
 
33
using Do.Interface.Xlib;
33
34
using Do.Interface.CairoUtils;
34
35
using Do.Interface.AnimationBase;
35
36
 
37
38
{
38
39
        
39
40
        
40
 
        public class DockWindow : Gtk.Window, IDoWindow
 
41
        public class DockWindow : Gtk.Window, IDoWindow, IConfigurable
41
42
        {
42
43
                public static Gtk.Window Window { get; private set; }
43
44
                
47
48
                DockArea dock_area;
48
49
                Interface.DoInteropService interop_service;
49
50
                IDoController controller;
50
 
                Gdk.Rectangle current_mask;
 
51
                Gdk.Rectangle current_mask, blur_mask;
 
52
                
51
53
                uint strut_timer;
52
 
                bool is_repositioned_hidden;
53
54
                bool presented;
54
55
                int buffer_x, buffer_y;
 
56
                int buffer_width, buffer_height;
55
57
                
56
58
                public new string Name {
57
59
                        get { return "Docky"; }
58
60
                }
59
 
 
60
 
                public bool IsRepositionHidden {
61
 
                        get { return is_repositioned_hidden; }
62
 
                }
63
61
                
64
62
                public IDoController Controller {
65
63
                        get { return controller; }
79
77
                        Core.DockServices.RegisterService (interop_service);
80
78
                        
81
79
                        Core.DockServices.PainterService.RegisterPainter (new Painters.SummonModeRenderer ());
82
 
 
 
80
                        
83
81
                        RegisterEvents ();
84
82
                        Build ();
85
83
                }
87
85
                void Build ()
88
86
                {
89
87
                        AppPaintable = true;
 
88
                        AcceptFocus = false;
90
89
                        Decorated = false;
91
90
                        SkipPagerHint = true;
92
91
                        SkipTaskbarHint = true;
100
99
                        Add (dock_area);
101
100
 
102
101
                        results = new BezelGlassResults (controller, 450, HUDStyle.Classic, new BezelColors (new Cairo.Color (.1, .1, .1, .8)));
 
102
                        results.SlideFromBottom = DockPreferences.Orientation == DockOrientation.Bottom;
103
103
                        results_window = new BezelGlassWindow (results);
104
104
 
105
105
                        ShowAll ();
106
106
                        Stick ();
107
107
                }
108
 
 
 
108
                
109
109
                void RegisterEvents ()
110
110
                {
111
111
                        Realized += (o, a) => GdkWindow.SetBackPixmap (null, false);
169
169
                        
170
170
                        (cr as IDisposable).Dispose ();
171
171
                        pixmap.Dispose ();
172
 
                        
173
 
                        if (area.Height == 1) {
174
 
                                GLib.Timeout.Add (500, () => {
175
 
                                        if (current_mask.Height == 1)
176
 
                                                HideReposition ();
177
 
                                        return false;
178
 
                                });
179
 
                        } else {
180
 
                                if (is_repositioned_hidden)
181
 
                                        Reposition ();
182
 
                        }
183
172
                }
184
173
                
185
174
                protected override bool OnButtonReleaseEvent (Gdk.EventButton evnt)
221
210
                
222
211
                protected override void OnSizeAllocated (Gdk.Rectangle allocation)
223
212
                {
 
213
                        buffer_width = allocation.Width;
 
214
                        buffer_height = allocation.Height;
 
215
                        
224
216
                        base.OnSizeAllocated (allocation);
225
217
                        Reposition ();
226
218
                }
227
219
                
228
 
                void Reposition ()
 
220
                public void Reposition ()
229
221
                {
230
222
                        Gdk.Rectangle geo, main, res;
231
223
                        
232
224
                        GetSize (out main.Width, out main.Height);
233
225
                        results_window.GetSize (out res.Width, out res.Height);
234
 
                        geo = LayoutUtils.MonitorGemonetry ();
 
226
                        geo = LayoutUtils.MonitorGeometry ();
235
227
 
236
228
                        switch (DockPreferences.Orientation) {
237
229
                        case DockOrientation.Bottom:
243
235
                                results_window.Move ((geo.X + geo.Width / 2) - res.Width / 2, geo.Y + dock_area.DockHeight);
244
236
                                break;
245
237
                        }
246
 
                        Display.Sync ();
247
 
                        
248
 
                        is_repositioned_hidden = false;
249
 
                }
250
 
                
251
 
                void HideReposition ()
252
 
                {
253
 
                        Gdk.Rectangle geo, main;
254
 
                        
255
 
                        GetSize (out main.Width, out main.Height);
256
 
                        geo = LayoutUtils.MonitorGemonetry ();
257
 
 
258
 
                        switch (DockPreferences.Orientation) {
259
 
                        case DockOrientation.Bottom:
260
 
                                Move ((geo.X + geo.Width / 2) - main.Width / 2, geo.Y + geo.Height);
261
 
                                break;
262
 
                        case DockOrientation.Top:
263
 
                                Move (geo.X, geo.Y - main.Height);
264
 
                                break;
265
 
                        }
266
 
 
267
 
                        Display.Sync ();
268
 
                        
269
 
                        is_repositioned_hidden = true;
270
 
                }
271
 
                
272
 
                public void WindowHideOffset (out int x, out int y)
273
 
                {
274
 
                        x = y = 0;
275
 
                        
276
 
                        if (!is_repositioned_hidden) {
277
 
                                return;
278
 
                        }
279
 
                        
280
 
                        Gdk.Rectangle main;
281
 
                        GetSize (out main.Width, out main.Height);
282
 
                        switch (DockPreferences.Orientation) {
283
 
                        case DockOrientation.Bottom:
284
 
                                y = main.Height;
285
 
                                break;
286
 
                        case DockOrientation.Top:
287
 
                                y = 0 - main.Height;
288
 
                                break;
289
 
                        }
290
 
                }
291
 
                
 
238
                        
 
239
                        results.SlideFromBottom = DockPreferences.Orientation == DockOrientation.Bottom;
 
240
                }
292
241
                                
293
242
                public void GetBufferedPosition (out int x, out int y)
294
243
                {
298
247
                        y = buffer_y;
299
248
                }
300
249
                
 
250
                public void GetBufferedSize (out int width, out int height)
 
251
                {
 
252
                        if (buffer_width == 0 && buffer_height == 0)
 
253
                                GetSize (out buffer_width, out buffer_height);
 
254
                        width = buffer_width;
 
255
                        height = buffer_height;
 
256
                }
 
257
                
301
258
                public void DelaySetStruts ()
302
259
                {
303
260
                        if (strut_timer > 0)
308
265
                
309
266
                public bool SetStruts ()
310
267
                {
311
 
                        X11Atoms atoms = new X11Atoms (GdkWindow);
 
268
                        X11Atoms atoms = X11Atoms.Instance;
312
269
 
313
 
                        uint [] struts = dock_area.StrutRequest;
314
 
                        uint [] first_struts = new [] { struts [0], struts [1], struts [2], struts [3] };
 
270
                        IntPtr [] struts = dock_area.StrutRequest.Select (i => (IntPtr) i).ToArray ();
 
271
                        IntPtr [] first_struts = new [] { struts [0], struts [1], struts [2], struts [3] };
315
272
 
316
273
                        strut_timer = 0;
317
274
                        
318
275
                        if (!IsRealized)
319
276
                                return false;
320
277
                        Xlib.XChangeProperty (GdkWindow, atoms._NET_WM_STRUT_PARTIAL, atoms.XA_CARDINAL,
321
 
                                              (int) XLib.PropertyMode.PropModeReplace, struts);
 
278
                                              (int) PropertyMode.PropModeReplace, struts);
322
279
                        
323
280
                        Xlib.XChangeProperty (GdkWindow, atoms._NET_WM_STRUT, atoms.XA_CARDINAL, 
324
 
                                              (int) XLib.PropertyMode.PropModeReplace, first_struts);
 
281
                                              (int) PropertyMode.PropModeReplace, first_struts);
325
282
                                
326
283
                        return false;
327
284
                }
 
285
                
 
286
                public void SetBackgroundBlur (Gdk.Rectangle area)
 
287
                {
 
288
                        if (!IsRealized || blur_mask == area)
 
289
                                return;
 
290
                        
 
291
                        blur_mask = area;
 
292
                        
 
293
                        int WindowHeight = dock_area.Height;
 
294
                        X11Atoms atoms = X11Atoms.Instance;
 
295
                
 
296
                        IntPtr [] data = new IntPtr [8];
 
297
                        
 
298
                        // this is meant to tell the blur-plugin what and how to blur, somehow
 
299
                        // the y-coords are interpreted as being CenterGravity, I wonder why
 
300
                        // Kudos to macslow
 
301
                        data [0] = (IntPtr) 2;                                   // threshold
 
302
                        data [1] = (IntPtr) 0;                                   // filter
 
303
                        data [2] = (IntPtr) XGravity.NorthWestGravity;           // gravity of top-left
 
304
                        data [3] = (IntPtr) area.X;                              // x-coord of top-left
 
305
                        data [4] = (IntPtr) (WindowHeight / 2 - area.Height);    // y-coord of top-left
 
306
                        data [5] = (IntPtr) XGravity.NorthWestGravity;           // gravity of bottom-right
 
307
                        data [6] = (IntPtr) (area.X + area.Width);               // bottom-right x-coord
 
308
                        data [7] = (IntPtr) (WindowHeight / 2);                  // bottom-right y-coord
 
309
                        
 
310
                        Xlib.XChangeProperty (GdkWindow, atoms._COMPIZ_WM_WINDOW_BLUR, atoms.XA_INTEGER, (int) PropertyMode.PropModeReplace, data);
 
311
                }
328
312
 
329
313
                public void PresentWindow ()
330
314
                {
366
350
                public void Reset ()
367
351
                {
368
352
                        DockState.Instance.Clear ();
 
353
                        results.Clear ();
369
354
                        interop_service.SignalReset ();
370
355
                }
371
356
                
434
419
                        base.Dispose ();
435
420
                }
436
421
 
 
422
 
437
423
                #endregion 
 
424
 
 
425
                #region IConfigurable implementation
 
426
                public Bin GetConfiguration ()
 
427
                {
 
428
                        return new DockyConfigurationWidget ();
 
429
                }
 
430
                
 
431
                public string Description {
 
432
                        get {
 
433
                                return "Docky configuration";
 
434
                        }
 
435
                }
 
436
                
 
437
                public new string Icon {
 
438
                        get {
 
439
                                return "panel";
 
440
                        }
 
441
                }
 
442
                #endregion
438
443
        }
439
444
}