[Gtk-sharp-list] Dual/multi monitor support?

Mark William Darbyshire me at markdarb.com
Mon Sep 7 04:59:35 EDT 2009


Hi,

Thanks for your helpful replies. They've set me on the right track
nicely (and of course reminded me of the difference between a screen
and a monitor).

Mark.

2009/9/7 Stephane Delcroix <stephane at delcroix.org>
>
> If by *screen* you mean *monitor* and you hav a single *sceen* splitted
> on 2 *monitors*, you can do this:
>
> //This will tell you on which monitor your window is on
> Gdk.Screen screen = this.Screen;
> int monitor = screen.GetMonitorAtWindow (parent.GdkWindow);
>
> //Now, you can move it at will using Move (x, y), and it's easy to get
> one monitor Bounds with:
> Gdk.Rectangle bounds = screen.GetMonitorGeometry (monitor);
>
> More info on
> http://www.go-mono.com/docs/index.aspx?link=T%3aGdk.Screen%2f*
>
> hot it helps
>
> s


2009/9/7 Jason Smith <jassmith at gmail.com>
>
> Monitor != Screen;
>
> Those functions are mapped as Gtk.Window.Screen. But you know, as
> instance methods. To figure out what physical monitor a window is on
> (sounds like what you want). You do something like;
>
> Gdk.Rectangle geo;
> window.GetPosition (out geo.X, out geo.Y);
> window.GetSize (out geo.Width, out geo.Height);
>
> for (int i=0; i < window.Screen.NMonitors; i++) {
>        if (geo.IntersectsWith (window.Screen.GetMonitorGeometry (i)) {
>                Console.WriteLine ("Window on monitor " + i);
>                break;
>        }
> }
>
> I am doing this from memory, so the method names may not be exact, but
> thats the idea.


More information about the Gtk-sharp-list mailing list