public static Pango.Context ContextGetForScreen(Gdk.Screen screen)
        {
            IntPtr raw_ret = gdk_pango_context_get_for_screen(screen == null ? IntPtr.Zero : screen.Handle);

            Pango.Context ret = GLib.Object.GetObject(raw_ret) as Pango.Context;
            return(ret);
        }
Beispiel #2
0
        public void GetPointer(Gdk.Screen screen, out int x, out int y, out Gdk.ModifierType mask)
        {
            int mask_as_int;

            gdk_display_get_pointer(Handle, screen.Handle, out x, out y, out mask_as_int);
            mask = (Gdk.ModifierType)mask_as_int;
        }
Beispiel #3
0
        public static bool AlternativeDialogButtonOrder(Gdk.Screen screen)
        {
            bool raw_ret = gtk_alternative_dialog_button_order(screen == null ? IntPtr.Zero : screen.Handle);
            bool ret     = raw_ret;

            return(ret);
        }
Beispiel #4
0
        public static Gtk.IconTheme GetForScreen(Gdk.Screen screen)
        {
            IntPtr raw_ret = gtk_icon_theme_get_for_screen(screen == null ? IntPtr.Zero : screen.Handle);

            Gtk.IconTheme ret = GLib.Object.GetObject(raw_ret) as Gtk.IconTheme;
            return(ret);
        }
		public override Gdk.Rectangle GetUsableMonitorGeometry (Gdk.Screen screen, int monitor_id)
		{
			Gdk.Rectangle geometry = screen.GetMonitorGeometry (monitor_id);
			List<MonitorInfo> screens = new List<MonitorInfo> ();

			EnumDisplayMonitors (IntPtr.Zero, IntPtr.Zero, delegate (IntPtr hmonitor, IntPtr hdc, IntPtr prect, IntPtr user_data) {
				var info = new MonitorInfo ();

				info.Size = Marshal.SizeOf (info);

				GetMonitorInfoA (hmonitor, ref info);

				// In order to keep the order the same as Gtk, we need to put the primary monitor at the beginning.
				if ((info.Flags & MonitorInfoFlagsPrimary) != 0)
					screens.Insert (0, info);
				else
					screens.Add (info);

				return 1;
			}, IntPtr.Zero);

			MonitorInfo monitor = screens[monitor_id];
			Rect visible = monitor.VisibleFrame;
			Rect frame = monitor.Frame;

			// Rebase the VisibleFrame off of Gtk's idea of this monitor's geometry (since they use different coordinate systems)
			int x = geometry.X + (visible.Left - frame.Left);
			int width = visible.Width;

			int y = geometry.Y + (visible.Top - frame.Top);
			int height = visible.Height;

			return new Gdk.Rectangle (x, y, width, height);
		}
Beispiel #6
0
        public static Gdk.Screen GetScreen(Gdk.Event evnt)
        {
            IntPtr raw_ret = gdk_event_get_screen(evnt == null ? IntPtr.Zero : evnt.Handle);

            Gdk.Screen ret = GLib.Object.GetObject(raw_ret) as Gdk.Screen;
            return(ret);
        }
Beispiel #7
0
        public bool MenuOpensUpward()
        {
            bool open_upwards = false;
            int  val          = 0;

            Gdk.Screen screen = null;
#if WIN32 || MAC
            int x;
            tray.TomboyTrayMenu.Screen.Display.GetPointer(out x, out val);
            screen = tray.TomboyTrayMenu.Screen;
#else
            Gdk.Rectangle   area;
            Gtk.Orientation orientation;
            GetGeometry(out screen, out area, out orientation);
            val = area.Y;
#endif

            Gtk.Requisition menu_req = tray.TomboyTrayMenu.SizeRequest();
            if (val + menu_req.Height >= screen.Height)
            {
                open_upwards = true;
            }

            return(open_upwards);
        }
Beispiel #8
0
        void InvokeNative(Gdk.Screen screen, Gdk.Color colors, int n_colors)
        {
            IntPtr native_colors = GLib.Marshaller.StructureToPtrAlloc(colors);

            native_cb(screen == null ? IntPtr.Zero : screen.Handle, native_colors, n_colors);
            Marshal.FreeHGlobal(native_colors);
        }
Beispiel #9
0
        public static Gtk.Settings GetForScreen(Gdk.Screen screen)
        {
            IntPtr raw_ret = gtk_settings_get_for_screen(screen == null ? IntPtr.Zero : screen.Handle);

            Gtk.Settings ret = GLib.Object.GetObject(raw_ret) as Gtk.Settings;
            return(ret);
        }
Beispiel #10
0
 public virtual void OpenUrl(string url, Gdk.Screen screen)
 {
     try {
         System.Diagnostics.Process.Start(url);
     } catch (Exception e) {
         Logger.Error("Error opening url [{0}]:\n{1}", url, e.ToString());
     }
 }
Beispiel #11
0
        static Gdk.Rectangle MacGetUsableMonitorGeometry(Gdk.Screen screen, int monitor)
        {
            IntPtr array = objc_msgSend_IntPtr(cls_NSScreen, sel_screens);
            IntPtr iter  = objc_msgSend_IntPtr(array, sel_objectEnumerator);

            Gdk.Rectangle geometry = screen.GetMonitorGeometry(0);
            RectangleF    visible, frame;
            IntPtr        scrn;
            int           i = 0;

            while ((scrn = objc_msgSend_IntPtr(iter, sel_nextObject)) != IntPtr.Zero && i < monitor)
            {
                i++;
            }

            if (scrn == IntPtr.Zero)
            {
                return(screen.GetMonitorGeometry(monitor));
            }

            objc_msgSend_RectangleF(out visible, scrn, sel_visibleFrame);
            objc_msgSend_RectangleF(out frame, scrn, sel_frame);

            // Note: Frame and VisibleFrame rectangles are relative to monitor 0, but we need absolute
            // coordinates.
            visible.X += geometry.X;
            visible.Y += geometry.Y;
            frame.X   += geometry.X;
            frame.Y   += geometry.Y;

            // VisibleFrame.Y is the height of the Dock if it is at the bottom of the screen, so in order
            // to get the menu height, we just figure out the difference between the visibleFrame height
            // and the actual frame height, then subtract the Dock height.
            //
            // We need to swap the Y offset with the menu height because our callers expect the Y offset
            // to be from the top of the screen, not from the bottom of the screen.
            float x, y, width, height;

            if (visible.Height < frame.Height)
            {
                float dockHeight    = visible.Y;
                float menubarHeight = (frame.Height - visible.Height) - dockHeight;

                height = frame.Height - menubarHeight - dockHeight;
                y      = menubarHeight;
            }
            else
            {
                height = frame.Height;
                y      = frame.Y;
            }

            // Takes care of the possibility of the Dock being positioned on the left or right edge of the screen.
            width = System.Math.Min(visible.Width, frame.Width);
            x     = System.Math.Max(visible.X, frame.X);

            return(new Gdk.Rectangle((int)x, (int)y, (int)width, (int)height));
        }
Beispiel #12
0
        public void GetPointer(out Gdk.Screen screen, out int x, out int y, out Gdk.ModifierType mask)
        {
            IntPtr screen_handle;
            int    mask_as_int;

            gdk_display_get_pointer(Handle, out screen_handle, out x, out y, out mask_as_int);
            screen = (Gdk.Screen)GLib.Object.GetObject(screen_handle);
            mask   = (Gdk.ModifierType)mask_as_int;
        }
Beispiel #13
0
        public static Gdk.Rectangle GetUsableMonitorGeometry(this Gdk.Screen screen, int monitor)
        {
            if (Platform.IsMac)
            {
                return(MacGetUsableMonitorGeometry(screen, monitor));
            }

            return(screen.GetMonitorGeometry(monitor));
        }
        private void ConfigureWindow()
        {
            Gdk.Screen screen  = Screen;
            int        monitor = screen.GetMonitorAtWindow(parent.GdkWindow);

            Gdk.Rectangle bounds = screen.GetMonitorGeometry(monitor);
            Move(bounds.X, 0);
            SetDefaultSize(bounds.Width, bounds.Height);
        }
Beispiel #15
0
        public static Profile GetScreenProfile(Gdk.Screen screen)
        {
            IntPtr profile = f_screen_get_profile(screen.Handle);

            if (profile == IntPtr.Zero)
            {
                return(null);
            }

            return(new Profile(profile));
        }
Beispiel #16
0
        public static Profile GetScreenProfile(Gdk.Screen screen)
        {
            IntPtr profile = NativeMethods.FScreenGetProfile(screen.Handle);

            if (profile == IntPtr.Zero)
            {
                return(null);
            }

            return(new Profile(profile));
        }
Beispiel #17
0
 private void UnitializeKeys()
 {
     for (int i = 0; i < Gdk.Display.Default.NScreens; i++)
     {
         Gdk.Screen screen = Gdk.Display.Default.GetScreen(i);
         foreach (int keycode in keycode_list)
         {
             UngrabKey(screen.RootWindow, keycode);
         }
         screen.RootWindow.RemoveFilter(FilterKey);
     }
 }
Beispiel #18
0
        private void SolveWindowPosition(Gtk.Window parent)
        {
            int          x, y, cw, ch, pw, ph, px, py;
            PositionMode wp = (ShellObject as Window).PositionMode;

            //if center parent and parent is null, center screen instead
            if (parent == null && wp == PositionMode.CenterParent)
            {
                wp = PositionMode.CenterScreen;
            }


            switch (wp)
            {
            case PositionMode.Manual:
                //HACK: we have to move the window to the position it already is for some stupid gtk-reason
                //an GetPosition doesnt work (in windows at least)
                int wx, wy, w, h, d;
                window.GdkWindow.GetGeometry(out wx, out wy, out w, out h, out d);
                Margin m = GetDecorationSize();
                window.Move(wx - m.Left, wy - m.Top);
                return;     //done already

            case PositionMode.CenterParent:
                parent.GetSize(out pw, out ph);
                parent.GetPosition(out px, out py);
                window.GetSize(out cw, out ch);
                var c = window.WindowPosition;
                x = px + pw / 2 - cw / 2;
                y = py + ph / 2 - ch / 2;
                window.Move(x, y);
                break;

            case PositionMode.CenterScreen:
                Gdk.Screen scr = window.Screen;     // ?? Gdk.Screen.Default
                window.GetSize(out cw, out ch);
                x = scr.Width / 2 - cw / 2;
                y = scr.Height / 2 - ch / 2;
                window.Move(x, y);
                break;

            case PositionMode.MouseCursor:
                Gdk.Screen scr2 = window.Screen;
                scr2.Display.GetPointer(out x, out y);
                window.Move(x, y);
                break;

            default:
                throw new Exception("GtkSharp driver does not know how to position screen at " + wp.ToString());
            }
        }
        public static unsafe bool UrlShowOnScreen(string url, Gdk.Screen screen)
        {
            IntPtr native_url = GLib.Marshaller.StringToPtrGStrdup(url);
            IntPtr error      = IntPtr.Zero;
            bool   raw_ret    = gnome_url_show_on_screen(native_url, screen == null ? IntPtr.Zero : screen.Handle, out error);
            bool   ret        = raw_ret;

            GLib.Marshaller.Free(native_url);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(ret);
        }
Beispiel #20
0
        public static unsafe bool DisplayUriOnScreen(string help_uri, Gdk.Screen screen)
        {
            IntPtr native_help_uri = GLib.Marshaller.StringToPtrGStrdup(help_uri);
            IntPtr error           = IntPtr.Zero;
            bool   raw_ret         = gnome_help_display_uri_on_screen(native_help_uri, screen == null ? IntPtr.Zero : screen.Handle, out error);
            bool   ret             = raw_ret;

            GLib.Marshaller.Free(native_help_uri);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(ret);
        }
Beispiel #21
0
        public static unsafe bool ShowUri(Gdk.Screen screen, string uri, uint timestamp)
        {
            IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup(uri);
            IntPtr error      = IntPtr.Zero;
            bool   raw_ret    = gtk_show_uri(screen == null ? IntPtr.Zero : screen.Handle, native_uri, timestamp, out error);
            bool   ret        = raw_ret;

            GLib.Marshaller.Free(native_uri);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(ret);
        }
Beispiel #22
0
        static void OnShowHelpAction(object sender, EventArgs args)
        {
            Gdk.Screen screen = null;
            if (tray_icon != null)
            {
#if WIN32 || MAC
                screen = tray_icon.Tray.TomboyTrayMenu.Screen;
#else
                Gdk.Rectangle   area;
                Gtk.Orientation orientation;
                tray_icon.GetGeometry(out screen, out area, out orientation);
#endif
            }
            GuiUtils.ShowHelp("tomboy", null, screen, null);
        }
Beispiel #23
0
 public TrayIcon(Gdk.Screen screen, string name) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(TrayIcon))
     {
         ArrayList vals  = new ArrayList();
         ArrayList names = new ArrayList();
         names.Add("screen");
         vals.Add(new GLib.Value(screen));
         names.Add("name");
         vals.Add(new GLib.Value(name));
         CreateNativeObject((string[])names.ToArray(typeof(string)), (GLib.Value[])vals.ToArray(typeof(GLib.Value)));
         return;
     }
     Raw = egg_tray_icon_new_for_screen(screen.Handle, name);
 }
Beispiel #24
0
        public static unsafe bool DisplayOnScreen(string file_name, string link_id, Gdk.Screen screen)
        {
            IntPtr native_file_name = GLib.Marshaller.StringToPtrGStrdup(file_name);
            IntPtr native_link_id   = GLib.Marshaller.StringToPtrGStrdup(link_id);
            IntPtr error            = IntPtr.Zero;
            bool   raw_ret          = gnome_help_display_on_screen(native_file_name, native_link_id, screen == null ? IntPtr.Zero : screen.Handle, out error);
            bool   ret = raw_ret;

            GLib.Marshaller.Free(native_file_name);
            GLib.Marshaller.Free(native_link_id);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(ret);
        }
Beispiel #25
0
        public static Profile GetScreenProfile(Gdk.Screen screen)
        {
            if (screen == null)
            {
                throw new ArgumentNullException("screen");
            }

            IntPtr profile = NativeMethods.FScreenGetProfile(screen.Handle);

            if (profile == IntPtr.Zero)
            {
                return(null);
            }

            return(new Profile(profile));
        }
        public static bool ShowUri(Gdk.Screen screen, string uri, uint timestamp)
        {
            var native_uri   = GLib.Marshaller.StringToPtrGStrdup(uri);
            var native_error = IntPtr.Zero;

            try {
                return(gtk_show_uri(screen == null ? IntPtr.Zero : screen.Handle,
                                    native_uri, timestamp, out native_error));
            } finally {
                GLib.Marshaller.Free(native_uri);
                if (native_error != IntPtr.Zero)
                {
                    throw new GLib.GException(native_error);
                }
            }
        }
Beispiel #27
0
 public Invisible(Gdk.Screen screen) : base(IntPtr.Zero)
 {
     if (GetType() != typeof(Invisible))
     {
         var vals  = new List <GLib.Value> ();
         var names = new List <string> ();
         if (screen != null)
         {
             names.Add("screen");
             vals.Add(new GLib.Value(screen));
         }
         CreateNativeObject(names.ToArray(), vals.ToArray());
         return;
     }
     Raw = gtk_invisible_new_for_screen(screen == null ? IntPtr.Zero : screen.Handle);
 }
Beispiel #28
0
        public void Position(Gdk.Window eventWindow)
        {
            int x, y;
            int widget_x, widget_y;
            int widget_height, widget_width;

            Realize();

            var widget_window = eventWindow;

            Gdk.Screen widget_screen = widget_window.Screen;

            Gtk.Requisition popup_req;

            widget_window.GetOrigin(out widget_x, out widget_y);
            widget_window.GetSize(out widget_width, out widget_height);

            popup_req = Requisition;

            if (widget_x + widget_width > widget_screen.Width)
            {
                x = widget_screen.Width - popup_req.Width;
            }
            else if (widget_x + widget_width - popup_req.Width < 0)
            {
                x = 0;
            }
            else
            {
                x = widget_x + widget_width - popup_req.Width;
            }

            if (widget_y + widget_height + popup_req.Height > widget_screen.Height)
            {
                y = widget_screen.Height - popup_req.Height;
            }
            else if (widget_y + widget_height < 0)
            {
                y = 0;
            }
            else
            {
                y = widget_y + widget_height;
            }

            Move(x, y);
        }
        protected override void OnScreenChanged(Gdk.Screen previous_screen)
        {
            // To check if the display supports alpha channels, get the colormap
            var visual = this.Screen.RgbaVisual;

            if (visual == null)
            {
                visual       = this.Screen.SystemVisual;
                supportAlpha = false;
            }
            else
            {
                supportAlpha = true;
            }
            this.Visual = visual;
            base.OnScreenChanged(previous_screen);
        }
Beispiel #30
0
            protected override void OnScreenChanged(Gdk.Screen previous_screen)
            {
                // To check if the display supports alpha channels, get the colormap
                var colormap = this.Screen.RgbaColormap;

                if (colormap == null)
                {
                    colormap     = this.Screen.RgbColormap;
                    supportAlpha = false;
                }
                else
                {
                    supportAlpha = true;
                }
                this.Colormap = colormap;
                base.OnScreenChanged(previous_screen);
            }