Using Xinerama extension for getting screen info
This commit is contained in:
parent
ce7c7a862e
commit
f55c0e9285
|
@ -21,7 +21,7 @@ func _fixed_process(delta):
|
|||
get_node("Label_Screen1_Resolution").show()
|
||||
get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
|
||||
get_node("Label_Screen1_Position").show()
|
||||
get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_size(1) ) )
|
||||
get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
|
||||
else:
|
||||
get_node("Label_Screen1_Resolution").hide()
|
||||
get_node("Label_Screen1_Position").hide()
|
||||
|
|
|
@ -38,6 +38,11 @@ def can_build():
|
|||
if (x11_error):
|
||||
print("xcursor not found.. x11 disabled.")
|
||||
return False
|
||||
|
||||
x11_error=os.system("pkg-config xinerama --modversion > /dev/null ")
|
||||
if (x11_error):
|
||||
print("xinerama not found.. x11 disabled.")
|
||||
return False
|
||||
|
||||
|
||||
return True # X11 enabled
|
||||
|
@ -151,4 +156,5 @@ def configure(env):
|
|||
|
||||
if(env["experimental_wm_api"]=="yes"):
|
||||
env.Append(CPPFLAGS=['-DEXPERIMENTAL_WM_API'])
|
||||
env.ParseConfig('pkg-config xinerama --cflags --libs')
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#include "servers/physics/physics_server_sw.h"
|
||||
|
||||
#include "X11/Xutil.h"
|
||||
#ifdef EXPERIMENTAL_WM_API
|
||||
#include "X11/extensions/Xinerama.h"
|
||||
#endif
|
||||
#include "main/main.h"
|
||||
|
||||
|
||||
|
@ -558,26 +561,37 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) {
|
|||
}
|
||||
|
||||
int OS_X11::get_screen_count() const {
|
||||
return XScreenCount(x11_display);
|
||||
int event_base, error_base;
|
||||
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
|
||||
if( !ext_okay ) return 0;
|
||||
int count;
|
||||
XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count);
|
||||
XFree(xsi);
|
||||
return count;
|
||||
}
|
||||
|
||||
Point2 OS_X11::get_screen_position(int p_screen) const {
|
||||
if( p_screen >= XScreenCount(x11_display) )
|
||||
return Point2i(0,0);
|
||||
|
||||
Window root = XRootWindow(x11_display, p_screen);
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display, root, &xwa);
|
||||
return Point2i(xwa.x, xwa.y);
|
||||
int event_base, error_base;
|
||||
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
|
||||
if( !ext_okay ) return Point2i(0,0);
|
||||
int count;
|
||||
XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count);
|
||||
if( p_screen >= count ) return Point2i(0,0);
|
||||
Point2i position = Point2i(xsi[p_screen].x_org, xsi[p_screen].y_org);
|
||||
XFree(xsi);
|
||||
return position;
|
||||
}
|
||||
|
||||
Size2 OS_X11::get_screen_size(int p_screen) const {
|
||||
if( p_screen >= XScreenCount(x11_display) )
|
||||
return Size2i(0,0);
|
||||
Window root = XRootWindow(x11_display, p_screen);
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display, root, &xwa);
|
||||
return Size2i(xwa.width, xwa.height);
|
||||
int event_base, error_base;
|
||||
const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base);
|
||||
if( !ext_okay ) return Size2i(0,0);
|
||||
int count;
|
||||
XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count);
|
||||
if( p_screen >= count ) return Size2i(0,0);
|
||||
Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height);
|
||||
XFree(xsi);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue