Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » [BUG] Ctrl::GetDefaultWindowRect on X11 dosen't recognize multi monitor mode.
[BUG] Ctrl::GetDefaultWindowRect on X11 dosen't recognize multi monitor mode. [message #41200] Mon, 11 November 2013 22:47
Klugier is currently offline  Klugier
Messages: 627
Registered: September 2012
Location: Poland, Kraków
Contributor
Hello,

In my last post on the forum I was writing about unatural window width. Now, I know what causes this issue. The problem is that I use two monitors and function Ctrl::GetDefaultWindowRect() on X11 dosen't support them. I modified this function using Xinerama extension:

Vector<Rect> FindScreensResolution()
{
	Vector<Rect> screens;
	int event, error;
	
	if(XineramaQueryExtension(Xdisplay, &event, &error)) {
		if(XineramaIsActive(Xdisplay)) {
			int screensNumber = 0;
			XineramaScreenInfo* info = XineramaQueryScreens(Xdisplay, &screensNumber);
			for(int i = 0; i < screensNumber; i++)
				screens.Add(Rect(info[i].x_org, info[i].y_org, info[i].x_org + info[i].width, info[i].y_org + info[i].height));
			XFree(info);
		}
	}
	return screens;
}

Rect Ctrl::GetDefaultWindowRect()
{
	GuiLock __;
	int width  = Xwidth;
	int height = Xheight; 
	
	Vector<Rect> screens = FindScreensResolution();
	for(int i = 0; i < screens.GetCount(); i++) {
		if(width > screens[i].Width()) {
			width = screens[i].Width();
		}
		if(height > screens[i].Height()) {
			height = screens[i].Height();
		}
	}
		
	static int pos = min(width / 10, 50);
	pos += 10;
	int cx = width * 2 / 3;
	int cy = height * 2 / 3;
	if(pos + cx + 50 > width || pos + cy + 50 > height)
		pos = 0;
	return RectC(pos + 20, pos + 20, cx, cy);
}


I enclose improved sorce files(CtrlCore - X11App.cpp, X11Gui.h - Xinerama header).

P.S.
* The algorith works on the principle: "the smallest screen is optimal".
* It doesn't change single monitor behavior

Sincerely,
Klugier
  • Attachment: X11Gui.h
    (Size: 6.41KB, Downloaded 146 times)
  • Attachment: X11App.cpp
    (Size: 11.85KB, Downloaded 384 times)


Ultimate++ - one framework to rule them all.

[Updated on: Wed, 13 November 2013 02:37]

Report message to a moderator

Previous Topic: What is VectorDes?
Next Topic: Remove unused languages
Goto Forum:
  


Current Time: Mon Sep 16 06:04:24 CEST 2019

Total time taken to generate the page: 0.01430 seconds