Search code examples
c#monogtkmonodevelopgtk#

GTK# Ask monitor boundaries


I'm developing an application for audio cuesheet. Inside the application I save position, height and width if user closes the application, so that on start I can reset the position, height and width. Now I got a bug report, that on 2 monitors, the user closes the application, switches to only 1 monitor (docking out notebook) and opens the application again, the application is not seen anymore, since the position was on the second monitor (x,y > 2000px). Do you have an idea, how I could ask GTK for monitor boundaries? The code I use: Setting position:

this.Move(Program.getInstance().getObjOption().getIntWindowX(), Program.getInstance().getObjOption().getIntWindowY());

Getting position:

protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
            //Save window allocation
            int intX;
            int intY;
            this.GetPosition(out intX, out intY);
            Program.getInstance().getObjOption().setIntWindowX(intX);
            Program.getInstance().getObjOption().setIntWindowY(intY);
}

Thanks for your help! Sven


Solution

  • If you are after total screen size of connected monitors this can be obtained by

     Gdk.Screen screen = Gdk.Screen.Default;
     int width = screen.Width; 
     int height = screen.Height;
    

    I just tried it with 2 monitors connected (1920x1200 & 1920x1080) It gave 3840x1200