Re: Multiple Monitors

On 06/11/2010 02:07 PM, Talguy wrote:
I would like to use my application with multiple monitors.  My app
consist of two windows, from what I was reading in the documentation I
would use gdk::screen to determine how many monitors there are and then
move each window into its own monitor by determining the monitor
rectangle and then use gtk::Window::move to move the window.  Once the
window is in the proper monitor I can us the fullscreen command to set
the window to fullscreen.

Does this sound about right to create a two window fullscreen
application for a dual monitor setup?

That's exactly the way we do.

Be aware that you can have one display with many screen, one for each monitor (multiple screens), or you can have one display with only one screen that can span many monitor (xinerama).

The attached code shoud work with both configs


#include <gtkmm.h>
#include <iostream>
#include <vector>

int main(int argc, char *argv[])
	Gtk::Main lKit(argc, argv);
	std::vector<Gtk::Window *> lWindows;

	Glib::RefPtr<Gdk::Display> lDisplay = Gdk::Display::get_default();
	int lScreenCount = lDisplay->get_n_screens();

	std::cout << "Display has " << lScreenCount << " screens\n";
	for (int s = 0; s < lScreenCount; s++)
		Glib::RefPtr<Gdk::Screen> lScreen = lDisplay->get_screen(s);
		int lMonitorCount = lScreen->get_n_monitors();
		std::cout << "    Screen " << s << " has " << lMonitorCount << " monitors\n";
		for (int m = 0; m < lMonitorCount; m++)
			std::cout << "        Opening window on Screen " << s << ", monitor " << m << std::endl;   
			Gtk::Window *lWindow = new Gtk::Window;
			Gdk::Rectangle lMonitorRect;
			lScreen->get_monitor_geometry(m, lMonitorRect);
			lWindow->move(lMonitorRect.get_x(), lMonitorRect.get_y());




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]