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++ Widgets - General questions or Mixed problems » Multi monitor support for X11 backend
Multi monitor support for X11 backend [message #40084] Sun, 09 June 2013 15:20 Go to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Hi,

I would like to improve a little bit multi monitor handling in X11 backend. Right now two (or more) screens are treated as one big display.
We can use Xinerama or Xrandr to get information on screens resolution & position and _NET_WM_STRUT_PARTIAL to mark areas occupied by menus, status bars etc.

Bellow are modified functions:
CtrlCore.upp:

library(LINUX !RAINBOW) "X11 Xrender Xinerama";


X11Gui.h:

#include <X11/extensions/Xrender.h>
#include <X11/extensions/Xinerama.h> //<--- new header


X11App.cpp:

static Array<Rect> GetScreenArea()
{	
	Array<Rect> out;
	int displays;

	XineramaScreenInfo * si = XineramaQueryScreens (Xdisplay, &displays);
	if (si == NULL || displays < 1) out.Add(RectC(0, 0, Xwidth, Xheight));
	else{
		for (int i = 0; i < displays; i++){
			out.Add(RectC(si[i].x_org, si[i].y_org, si[i].width, si[i].height));
		}
		XFree(si);
	}
	return out;
}

void Ctrl::GetWorkArea(Array<Rect>& out)
{
	enum {	left = 0, right, top, bottom, 
			left_start_y, left_end_y,
			right_start_y, right_end_y, 
			top_start_x, top_end_x, 
			bottom_start_x, bottom_end_x
	};
			
	Array<Rect> sa = GetScreenArea();
	out <<= sa;

	Rect total(sa[0]);
	for (int i = 1; i < sa.GetCount(); i++){
		total |= sa[i];
	}

	Vector<int> wnd_lst = GetPropertyInts(Xroot, XAtom("_NET_CLIENT_LIST"));
	for (int i = 0; i < wnd_lst.GetCount(); i++){
		Vector<int> struts = GetPropertyInts(wnd_lst[i], XAtom("_NET_WM_STRUT_PARTIAL"));
		if (struts.GetCount() != 12) continue;

		for (int j = 0; j < sa.GetCount(); j++){
			
			if (struts[left] && sa[j].left <= struts[left] && sa[j].right >= struts[left] 
				&& sa[j].Intersects(Rect(sa[j].left, struts[left_start_y], struts[left], struts[left_end_y])))
				out[j].left = struts[left];

			int tmp = total.right - struts[right];
			if (struts[right] && sa[j].left <= struts[right] && sa[j].right >= struts[right]
				&& sa[j].Intersects(Rect(tmp, struts[right_start_y], total.right, struts[right_end_y]))) 
				out[j].right  = tmp;

			if (struts[top] && sa[j].top <= struts[top] && sa[j].bottom >= struts[top]
				&& sa[j].Intersects(Rect(struts[top_start_x], sa[j].top, struts[top_end_x], struts[top]))) 
				out[j].top    = struts[top];

			tmp = total.bottom - struts[bottom];
			if (struts[bottom] && sa[j].top <= struts[bottom] && sa[j].bottom >= struts[bottom]
				&& sa[j].Intersects(Rect(struts[bottom_start_x], tmp, struts[bottom_end_x], total.bottom)))
				out[j].bottom = tmp;
		}
	}
}

Rect Ctrl::GetWorkArea() const
{
	return GetPrimaryWorkArea();
}

Rect Ctrl::GetWorkArea(Point pt)
{
	Array<Rect> rc;
	GetWorkArea(rc);
	for(int i = 0; i < rc.GetCount(); i++)
		if(rc[i].Contains(pt))
			return rc[i];
	return rc[0];
}

Rect Ctrl::GetVirtualWorkArea()
{
	Array <Rect> wa;
	GetWorkArea(wa);
	Rect r(wa[0]);
	for (int i = 1; i < wa.GetCount(); i++)
		r |= wa[i];
	
	return r;
}

Rect Ctrl::GetVirtualScreenArea()
{
	Array<Rect> sa = GetScreenArea();

	Rect out(sa[0]);
	for (int i = 1; i < sa.GetCount(); i++){
		out |= sa[i];
	}

	return out;
}

Rect Ctrl::GetPrimaryWorkArea()
{
	Array<Rect> x;
	GetWorkArea(x);
	return x[0];
}

Rect Ctrl::GetPrimaryScreenArea()
{
	return GetScreenArea()[0];
}


So far I made test on ATI and Intel graphics. Can someone compile TheIde in NOGTK mode and test window positioning on NVidia card?

Edit:
New version uploaded, should work with bottom and right panels.

[Updated on: Mon, 10 June 2013 12:56]

Report message to a moderator

Re: Multi monitor support for X11 backend [message #40087 is a reply to message #40084] Sun, 09 June 2013 17:37 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Zbych,

For me this patch is useless (NVIDIA GPU). I have noticed a lot of graphical glitches. For instance: menu toolbar bars is out of the window, running new windows from application make crash, some windows have diffrent resolution than previous (they are smaller), theIDE start logo is half on existing screen and half on no existing screen!!! (It should be in different place) etc.

I have NO recomended this patch as a linux multi-monitor user in its present form.

P.S.
1. I have tested it on two monitors with 1920x1080 resolution each.
2. I have used Kubuntu 13.04 x86_64 with nvidia 313.30 driver.

Sincerely,
Klugier


U++ - one framework to rule them all.
Re: Multi monitor support for X11 backend [message #40088 is a reply to message #40087] Sun, 09 June 2013 19:47 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Thank you Klugier for testing.

Wrong window placement is definitely caused by this patch, but it shouldn't influence resolution. Can you revert changes in upp, run attached test application and paste output log here?

Thanks in advance.
Re: Multi monitor support for X11 backend [message #40089 is a reply to message #40088] Sun, 09 June 2013 21:17 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Zbych,

Here is my log file:

* /home/klugier/upp-out/MyApps/GCC.Force_Speed.Gui.Nogtk.Shared.Sse2/MultiMonitorTest 09.06.2013 21:11:51, user: klugier

09.06.2013 21:11:51 VGA-0: 1920x1080+1920+0
09.06.2013 21:11:51 HDMI-0: 1920x1080+0+0
09.06.2013 21:11:51 TIMING GetScreenArea  : 69.00 ms - 69.00 ms (69.00 ms / 1 ), min: 69.00 ms, max: 69.00 ms, nesting: 1 - 1


Sincerely,
Klugier


U++ - one framework to rule them all.
Re: Multi monitor support for X11 backend [message #40090 is a reply to message #40089] Sun, 09 June 2013 21:29 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
Can you paste log from debug version as well?
Re: Multi monitor support for X11 backend [message #40091 is a reply to message #40090] Sun, 09 June 2013 22:14 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello Zbych,

Here is my log file from debug mode:

* /home/klugier/upp-out/MyApps/GCC.Debug.Debug_Full.Gui.Noblitz.Nogtk.Shared.Sse2/MultiMonitorTest 09.06.2013 22:12:23, user: klugier

09.06.2013 22:12:23 VGA-0: 1920x1080+1920+0
09.06.2013 22:12:23 HDMI-0: 1920x1080+0+0
09.06.2013 22:12:23 XrandrGetScreenArea(true):
09.06.2013 22:12:23 	[0] = [1920, 0] - [3840, 1080] : (1920, 1080)
09.06.2013 22:12:23 	[1] = [0, 0] - [1920, 1080] : (1920, 1080)
09.06.2013 22:12:23 XineramaGetScreenArea():
09.06.2013 22:12:23 	[0] = [1920, 0] - [3840, 1080] : (1920, 1080)
09.06.2013 22:12:23 	[1] = [0, 0] - [1920, 1080] : (1920, 1080)
09.06.2013 22:12:23 struts:
09.06.2013 22:12:23 	[0] = 0
09.06.2013 22:12:23 	[1] = 0
09.06.2013 22:12:23 	[2] = 0
09.06.2013 22:12:23 	[3] = 45
09.06.2013 22:12:23 	[4] = 0
09.06.2013 22:12:23 	[5] = 0
09.06.2013 22:12:23 	[6] = 0
09.06.2013 22:12:23 	[7] = 0
09.06.2013 22:12:23 	[8] = 0
09.06.2013 22:12:23 	[9] = 0
09.06.2013 22:12:23 	[10] = 1920
09.06.2013 22:12:23 	[11] = 3839
09.06.2013 22:12:23 work_area:
09.06.2013 22:12:23 	[0] = [1920, 0] - [3840, 45] : (1920, 45)
09.06.2013 22:12:23 	[1] = [0, 0] - [1920, 1080] : (1920, 1080)
09.06.2013 22:12:23 original_work_area:
09.06.2013 22:12:23 	[0] = [0, 0] - [3840, 1035] : (3840, 1035)
09.06.2013 22:12:23 Ctrl::GetVirtualScreenArea() = [0, 0] - [3840, 1080] : (3840, 1080)
09.06.2013 22:12:23 Ctrl::GetVirtualWorkArea() = [0, 0] - [3840, 1035] : (3840, 1035)
09.06.2013 22:12:23 TIMING GetScreenArea  : 70.00 ms - 70.00 ms (70.00 ms / 1 ), min: 70.00 ms, max: 70.00 ms, nesting: 1 - 1


Sincerely,
Klugier


U++ - one framework to rule them all.
Re: Multi monitor support for X11 backend [message #40092 is a reply to message #40084] Sun, 09 June 2013 22:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
I am planning to replace X11 with GTK backend soon; I believe that multimonitor support should work fine already there.

Mirek
Re: Multi monitor support for X11 backend [message #40093 is a reply to message #40091] Sun, 09 June 2013 22:50 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
klugier wrote on Sun, 09 June 2013 22:14

Hello Zbych,

Here is my log file from debug mode:



Thanks. It appears that I misinterpreted struts coordinates.


Re: Multi monitor support for X11 backend [message #40094 is a reply to message #40092] Sun, 09 June 2013 22:53 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
mirek wrote on Sun, 09 June 2013 22:35

I am planning to replace X11 with GTK backend soon; I believe that multimonitor support should work fine already there.

Mirek


Does it mean that you want to get rid of X11 completely? Or just remove X11 from GTK backend?

[Updated on: Mon, 10 June 2013 07:56]

Report message to a moderator

Re: Multi monitor support for X11 backend [message #40097 is a reply to message #40094] Mon, 10 June 2013 12:32 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Zbych wrote on Sun, 09 June 2013 16:53

mirek wrote on Sun, 09 June 2013 22:35

I am planning to replace X11 with GTK backend soon; I believe that multimonitor support should work fine already there.

Mirek


Does it mean that you want to get rid of X11 completely? Or just remove X11 from GTK backend?



I mean using GTK API instead of X11 API as U++ backend. Of course, GTK then uses X11... (or anything else). I hope this could iron out some hard to catch X11 issues.

You can check multimonitor support now, just place GTK into main config.

Mirek
Re: Multi monitor support for X11 backend [message #40098 is a reply to message #40097] Mon, 10 June 2013 13:03 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
I know that GTK uses X11 under the hood. Question is whether you are going to remove X11 from Upp.

I ask because I have a few embedded applications that use X11 backend and I would like to avoid additional dependencies on GTK.

PS. I uploaded modified version of multi monitor support to my first post. Klugier can you test it?

Re: Multi monitor support for X11 backend [message #40099 is a reply to message #40098] Mon, 10 June 2013 13:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Zbych wrote on Mon, 10 June 2013 07:03

I know that GTK uses X11 under the hood. Question is whether you are going to remove X11 from Upp.

I ask because I have a few embedded applications that use X11 backend and I would like to avoid additional dependencies on GTK.



Nope, but I planned to make GTK default (and X11 on config option).
Re: Multi monitor support for X11 backend [message #40100 is a reply to message #40098] Mon, 10 June 2013 13:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13984
Registered: November 2005
Ultimate Member
Zbych wrote on Mon, 10 June 2013 07:03

I know that GTK uses X11 under the hood. Question is whether you are going to remove X11 from Upp.

I ask because I have a few embedded applications that use X11 backend and I would like to avoid additional dependencies on GTK.




BTW, thing I am working on now is

- "minimal" U++ implementation (keeping dependencies at minimum)

- SDL2.0 backend (with HW acceleration)

Perhaps these might be a better option for embeded in the future?

Mirek


Re: Multi monitor support for X11 backend [message #40101 is a reply to message #40100] Mon, 10 June 2013 13:21 Go to previous messageGo to next message
Zbych is currently offline  Zbych
Messages: 327
Registered: July 2009
Senior Member
mirek wrote on Mon, 10 June 2013 13:10

BTW, thing I am working on now is

- "minimal" U++ implementation (keeping dependencies at minimum)

- SDL2.0 backend (with HW acceleration)

Perhaps these might be a better option for embeded in the future?

Mirek





It sounds nice Smile
Re: Multi monitor support for X11 backend [message #41785 is a reply to message #40101] Mon, 20 January 2014 21:04 Go to previous message
Klugier is currently offline  Klugier
Messages: 1077
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

Announcement:
Now, X11 backend has got minimal multi monitor support.

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Mon, 20 January 2014 21:04]

Report message to a moderator

Previous Topic: Help needed using IAccessible COM interface
Next Topic: DropList bug with XMonad window manager
Goto Forum:
  


Current Time: Sun Jun 16 07:33:49 CEST 2024

Total time taken to generate the page: 0.02454 seconds