diff options
author | hurikhan <m4r10.5ch14ck@gmail.com> | 2015-01-11 15:47:27 +0800 |
---|---|---|
committer | hurikhan <m4r10.5ch14ck@gmail.com> | 2015-01-11 15:47:27 +0800 |
commit | ac558c15eaeb45b3e7ae2604e26ca1dffb60b779 (patch) | |
tree | 2f46fa9ed27ea108717fc151e8635c6471213428 /platform/x11/os_x11.cpp | |
parent | 291d7992ceae487a63dc2d6eb1ee2da7312017c5 (diff) |
get_window_position() + set_window_position() added
Diffstat (limited to 'platform/x11/os_x11.cpp')
-rw-r--r-- | platform/x11/os_x11.cpp | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5a05455918..502d510f5b 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -70,7 +70,7 @@ const char * OS_X11::get_video_driver_name(int p_driver) const { } OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(0,0,800,600,false); + return OS::VideoMode(800,600,false); } int OS_X11::get_audio_driver_count() const { @@ -162,17 +162,6 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi // maybe contextgl wants to be in charge of creating the window //print_line("def videomode "+itos(current_videomode.width)+","+itos(current_videomode.height)); #if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) - if( current_videomode.x > current_videomode.width || - current_videomode.y > current_videomode.height || - current_videomode.width==0 || - current_videomode.height==0) { - - current_videomode.x = 0; - current_videomode.y = 0; - current_videomode.width = 640; - current_videomode.height = 480; - } - context_gl = memnew( ContextGL_X11( x11_display, x11_window,current_videomode, false ) ); context_gl->initialize(); @@ -516,7 +505,7 @@ void OS_X11::set_wm_border(bool p_enabled) { property = XInternAtom(x11_display, "_MOTIF_WM_HINTS", True); XChangeProperty(x11_display, x11_window, property, property, 32, PropModeReplace, (unsigned char *)&hints, 5); XMapRaised(x11_display, x11_window); - XMoveResizeWindow(x11_display, x11_window, current_videomode.x, current_videomode.y, current_videomode.width, current_videomode.height); + XMoveResizeWindow(x11_display, x11_window, 0, 0, current_videomode.width, current_videomode.height); } void OS_X11::set_wm_fullscreen(bool p_enabled) { @@ -537,26 +526,65 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) { XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev); } -void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { +Point2 OS_X11::get_window_position() const { + int x,y; + XWindowAttributes xwa; + Window child; + XTranslateCoordinates( x11_display, x11_window, DefaultRootWindow(x11_display), 0, 0, &x, &y, &child); + XGetWindowAttributes(x11_display, x11_window, &xwa); - if(p_enabled) { - XWindowAttributes xwa; - XGetWindowAttributes(x11_display, x11_window, &xwa); + return Point2i(x,y); +} - print_line(itos(xwa.x)); - print_line(itos(xwa.y)); - print_line(itos(xwa.width)); - print_line(itos(xwa.height)); - - current_videomode.x = xwa.x; - current_videomode.y = xwa.y; - current_videomode.width = xwa.width; - current_videomode.height = xwa.height; - +void OS_X11::set_window_position(const Point2& p_position) { + // _NET_FRAME_EXTENTS + Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True); + Atom type; + int format; + unsigned long len; + unsigned long remaining; + unsigned char *data = NULL; + //long *extends; + int result; + + result = XGetWindowProperty( + x11_display, + x11_window, + property, + 0, + 32, + False, + AnyPropertyType, + &type, + &format, + &len, + &remaining, + &data + ); + + long left = 0L; + long top = 0L; + + if( result == Success ) { + long *extends = (long *) data; + + left = extends[0]; + top = extends[2]; + + XFree(data); + data = NULL; + } + + XMoveWindow(x11_display,x11_window,p_position.x - left,p_position.y - top); +} + +void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { + + if(p_enabled) { pre_videomode = current_videomode; - // Get Desktop resolutuion + XWindowAttributes xwa; XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa); current_videomode.fullscreen = True; @@ -567,8 +595,6 @@ void OS_X11::set_fullscreen(bool p_enabled,int p_screen) { set_wm_fullscreen(true); } else { current_videomode.fullscreen = False; - current_videomode.x = pre_videomode.x; - current_videomode.y = pre_videomode.y; current_videomode.width = pre_videomode.width; current_videomode.height = pre_videomode.height; |