~ubuntu-branches/ubuntu/trusty/banshee/trusty-updates

« back to all changes in this revision

Viewing changes to src/Hyena/Hyena.Gui/Hyena.Gui/CompositeUtils.cs

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2013-12-22 04:11:14 UTC
  • mfrom: (1.2.25) (150.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131222041114-w19a3qe6h9ld7329
* [e46e107] Merge from Debian Experimental, remaining changes:
  - Enable and recommend SoundMenu and Disable NotificationArea by default
  - Disable boo and karma extensions
  - Move desktop file for Meego UI to /usr/share/une/applications
  - Change the url for the Amazon store redirector
  - [9b356d6] Add workaround for set_Height exception.
  - [ccbcbbd] Make Banshee translatable in Launchpad
  - [2094ee5] Bump libgpod build-dep version to 0.8.2-7~
  - [03c8cad] Set debian-branch to ubuntu/raring

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
{
36
36
    public static class CompositeUtils
37
37
    {
38
 
        [DllImport ("libgdk-win32-2.0-0.dll")]
39
 
        private static extern IntPtr gdk_screen_get_rgba_visual (IntPtr screen);
40
 
 
41
 
        [DllImport ("libgtk-win32-2.0-0.dll")]
42
 
        private static extern void gtk_widget_input_shape_combine_mask (IntPtr raw, IntPtr shape_mask,
43
 
            int offset_x, int offset_y);
44
 
 
45
 
        [DllImport ("libgdk-win32-2.0-0.dll")]
46
 
        private static extern IntPtr gdk_screen_get_rgba_colormap (IntPtr screen);
47
 
 
48
 
        public static Colormap GetRgbaColormap (Screen screen)
49
 
        {
50
 
            try {
51
 
                IntPtr raw_ret = gdk_screen_get_rgba_colormap (screen.Handle);
52
 
                Gdk.Colormap ret = GLib.Object.GetObject(raw_ret) as Gdk.Colormap;
53
 
                return ret;
54
 
            } catch {
55
 
                Gdk.Visual visual = Gdk.Visual.GetBestWithDepth (32);
56
 
                if (visual != null) {
57
 
                    Gdk.Colormap cmap = new Gdk.Colormap (visual, false);
58
 
                    return cmap;
59
 
                }
60
 
            }
61
 
 
62
 
            return null;
63
 
        }
64
 
 
65
 
        public static bool SetRgbaColormap (Widget w)
66
 
        {
67
 
            Gdk.Colormap cmap = GetRgbaColormap (w.Screen);
68
 
 
69
 
            if (cmap != null) {
70
 
                w.Colormap = cmap;
 
38
        public static bool SetRgbaVisual (Widget w)
 
39
        {
 
40
            Visual visual = w.Screen.RgbaVisual;
 
41
 
 
42
            if (visual != null) {
 
43
                w.Visual = visual;
71
44
                return true;
72
45
            }
73
46
 
74
47
            return false;
75
48
        }
76
49
 
77
 
        public static Visual GetRgbaVisual (Screen screen)
78
 
        {
79
 
            try {
80
 
                IntPtr raw_ret = gdk_screen_get_rgba_visual (screen.Handle);
81
 
                Gdk.Visual ret = GLib.Object.GetObject (raw_ret) as Gdk.Visual;
82
 
                return ret;
83
 
            } catch {
84
 
                Gdk.Visual visual = Gdk.Visual.GetBestWithDepth (32);
85
 
                if (visual != null) {
86
 
                    return visual;
87
 
                }
88
 
            }
89
 
            return null;
90
 
        }
91
 
 
92
50
        [DllImport ("libgdk-win32-2.0-0.dll")]
93
51
        private static extern void gdk_property_change (IntPtr window, IntPtr property, IntPtr type,
94
52
            int format, int mode, uint [] data, int nelements);
120
78
            }
121
79
        }
122
80
 
123
 
        [DllImport ("libgdk-win32-2.0-0.dll")]
124
 
        private static extern bool gdk_screen_is_composited (IntPtr screen);
125
 
 
126
 
        public static bool IsComposited (Screen screen)
127
 
        {
128
 
            bool composited;
129
 
            try {
130
 
                composited = gdk_screen_is_composited (screen.Handle);
131
 
            } catch (EntryPointNotFoundException) {
132
 
                Atom atom = Atom.Intern (String.Format ("_NET_WM_CM_S{0}", screen.Number), false);
133
 
                composited = Gdk.Selection.OwnerGetForDisplay (screen.Display, atom) != null;
134
 
            }
135
 
 
136
 
            // FIXME check for WINDOW_OPACITY so that we support compositing on older composite manager
137
 
            // versions before they started supporting the real check given above
138
 
            if (!composited) {
139
 
                composited = CompositeUtils.SupportsHint (screen, "_NET_WM_WINDOW_OPACITY");
140
 
            }
141
 
 
142
 
            return composited;
143
 
        }
144
 
 
145
81
        public static void SetWinOpacity (Gtk.Window win, double opacity)
146
82
        {
147
 
            CompositeUtils.ChangeProperty (win.GdkWindow,
 
83
            CompositeUtils.ChangeProperty (win.Window,
148
84
                Atom.Intern ("_NET_WM_WINDOW_OPACITY", false),
149
85
                Atom.Intern ("CARDINAL", false),
150
86
                PropMode.Replace,
151
87
                new uint [] { (uint) (0xffffffff * opacity) }
152
88
            );
153
89
        }
154
 
 
155
 
        public static void InputShapeCombineMask (Widget w, Pixmap shape_mask, int offset_x, int offset_y)
156
 
        {
157
 
            gtk_widget_input_shape_combine_mask (w.Handle, shape_mask == null ? IntPtr.Zero : shape_mask.Handle,
158
 
                offset_x, offset_y);
159
 
        }
160
90
    }
161
91
}