* cleanup window state handling
* first attemps in handling ALT+TABa (WIP)
This commit is contained in:
parent
6185949f6a
commit
f1dc00e380
@ -25,9 +25,9 @@ func _fixed_process(delta):
|
|||||||
|
|
||||||
get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) )
|
get_node("Label_Size").set_text(str("Size:\n", OS.get_window_size() ) )
|
||||||
|
|
||||||
get_node("Label_Screen_Count").set_text( str("Screens:\n", OS.get_screen_count() ) )
|
get_node("Label_Screen_Count").set_text( str("Screen_Count:\n", OS.get_screen_count() ) )
|
||||||
|
|
||||||
get_node("Label_Screen_Current").set_text( str("Current:\n", OS.get_screen() ) )
|
get_node("Label_Screen_Current").set_text( str("Screen:\n", OS.get_screen() ) )
|
||||||
|
|
||||||
get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) )
|
get_node("Label_Screen0_Resolution").set_text( str("Screen0 Resolution:\n", OS.get_screen_size() ) )
|
||||||
|
|
||||||
@ -35,12 +35,14 @@ func _fixed_process(delta):
|
|||||||
|
|
||||||
|
|
||||||
if(OS.get_screen_count() > 1):
|
if(OS.get_screen_count() > 1):
|
||||||
|
get_node("Button_Screen0").show()
|
||||||
get_node("Button_Screen1").show()
|
get_node("Button_Screen1").show()
|
||||||
get_node("Label_Screen1_Resolution").show()
|
get_node("Label_Screen1_Resolution").show()
|
||||||
get_node("Label_Screen1_Position").show()
|
get_node("Label_Screen1_Position").show()
|
||||||
get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
|
get_node("Label_Screen1_Resolution").set_text( str("Screen1 Resolution:\n", OS.get_screen_size(1) ) )
|
||||||
get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
|
get_node("Label_Screen1_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
|
||||||
else:
|
else:
|
||||||
|
get_node("Button_Screen0").hide()
|
||||||
get_node("Button_Screen1").hide()
|
get_node("Button_Screen1").hide()
|
||||||
get_node("Label_Screen1_Resolution").hide()
|
get_node("Label_Screen1_Resolution").hide()
|
||||||
get_node("Label_Screen1_Position").hide()
|
get_node("Label_Screen1_Position").hide()
|
||||||
@ -57,21 +59,16 @@ func _fixed_process(delta):
|
|||||||
if( Input.is_action_pressed("ui_down")):
|
if( Input.is_action_pressed("ui_down")):
|
||||||
OS.set_fullscreen(false)
|
OS.set_fullscreen(false)
|
||||||
|
|
||||||
|
get_node("Button_Fullscreen").set_pressed( OS.is_fullscreen() )
|
||||||
get_node("Button_FixedSize").set_pressed( !OS.is_resizable() )
|
get_node("Button_FixedSize").set_pressed( !OS.is_resizable() )
|
||||||
get_node("Button_Minimized").set_pressed( OS.is_minimized() )
|
get_node("Button_Minimized").set_pressed( OS.is_minimized() )
|
||||||
get_node("Button_Maximized").set_pressed( OS.is_maximized() )
|
get_node("Button_Maximized").set_pressed( OS.is_maximized() )
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
|
||||||
func _on_Fullscreen_toggled( pressed ):
|
|
||||||
if(pressed):
|
|
||||||
OS.set_fullscreen(true)
|
|
||||||
else:
|
|
||||||
OS.set_fullscreen(false)
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_MoveTo_pressed():
|
func _on_Button_MoveTo_pressed():
|
||||||
OS.set_window_position( Vector2(100,100) )
|
OS.set_window_position( Vector2(100,100) )
|
||||||
|
|
||||||
@ -88,6 +85,13 @@ func _on_Button_Screen1_pressed():
|
|||||||
OS.set_screen(1)
|
OS.set_screen(1)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_Fullscreen_pressed():
|
||||||
|
if(OS.is_fullscreen()):
|
||||||
|
OS.set_fullscreen(false)
|
||||||
|
else:
|
||||||
|
OS.set_fullscreen(true)
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_FixedSize_pressed():
|
func _on_Button_FixedSize_pressed():
|
||||||
if(OS.is_resizable()):
|
if(OS.is_resizable()):
|
||||||
OS.set_resizable(false)
|
OS.set_resizable(false)
|
||||||
@ -95,7 +99,6 @@ func _on_Button_FixedSize_pressed():
|
|||||||
OS.set_resizable(true)
|
OS.set_resizable(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Button_Minimized_pressed():
|
func _on_Button_Minimized_pressed():
|
||||||
if(OS.is_minimized()):
|
if(OS.is_minimized()):
|
||||||
OS.set_minimized(false)
|
OS.set_minimized(false)
|
||||||
@ -108,3 +111,6 @@ func _on_Button_Maximized_pressed():
|
|||||||
OS.set_maximized(false)
|
OS.set_maximized(false)
|
||||||
else:
|
else:
|
||||||
OS.set_maximized(true)
|
OS.set_maximized(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
@ -229,7 +229,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
|||||||
window_data.position.y = 0;
|
window_data.position.y = 0;
|
||||||
window_data.size.width = 800;
|
window_data.size.width = 800;
|
||||||
window_data.size.height = 600;
|
window_data.size.height = 600;
|
||||||
set_wm_border(false);
|
//set_wm_border(false);
|
||||||
set_wm_fullscreen(true);
|
set_wm_fullscreen(true);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -574,7 +574,7 @@ void OS_X11::set_wm_fullscreen(bool p_enabled) {
|
|||||||
xev.xclient.data.l[1] = wm_fullscreen;
|
xev.xclient.data.l[1] = wm_fullscreen;
|
||||||
xev.xclient.data.l[2] = 0;
|
xev.xclient.data.l[2] = 0;
|
||||||
|
|
||||||
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev);
|
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OS_X11::get_screen_count() const {
|
int OS_X11::get_screen_count() const {
|
||||||
@ -661,10 +661,6 @@ Point2 OS_X11::get_window_position() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::set_window_position(const Point2& p_position) {
|
void OS_X11::set_window_position(const Point2& p_position) {
|
||||||
|
|
||||||
if( current_videomode.fullscreen )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Using EWMH -- Extended Window Manager Hints
|
// Using EWMH -- Extended Window Manager Hints
|
||||||
// to get the size of the decoration
|
// to get the size of the decoration
|
||||||
Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True);
|
Atom property = XInternAtom(x11_display,"_NET_FRAME_EXTENTS", True);
|
||||||
@ -712,14 +708,12 @@ Size2 OS_X11::get_window_size() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::set_window_size(const Size2 p_size) {
|
void OS_X11::set_window_size(const Size2 p_size) {
|
||||||
if( current_videomode.fullscreen )
|
|
||||||
return;
|
|
||||||
|
|
||||||
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
|
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::set_fullscreen(bool p_enabled) {
|
void OS_X11::set_fullscreen(bool p_enabled) {
|
||||||
|
|
||||||
|
#if 0
|
||||||
if(p_enabled && current_videomode.fullscreen)
|
if(p_enabled && current_videomode.fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -750,6 +744,9 @@ void OS_X11::set_fullscreen(bool p_enabled) {
|
|||||||
|
|
||||||
current_videomode.fullscreen = False;
|
current_videomode.fullscreen = False;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
set_wm_fullscreen(p_enabled);
|
||||||
|
current_videomode.fullscreen = p_enabled;
|
||||||
|
|
||||||
visual_server->init();
|
visual_server->init();
|
||||||
|
|
||||||
@ -760,8 +757,6 @@ bool OS_X11::is_fullscreen() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::set_resizable(bool p_enabled) {
|
void OS_X11::set_resizable(bool p_enabled) {
|
||||||
|
|
||||||
if(!current_videomode.fullscreen) {
|
|
||||||
XSizeHints *xsh;
|
XSizeHints *xsh;
|
||||||
xsh = XAllocSizeHints();
|
xsh = XAllocSizeHints();
|
||||||
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
|
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
|
||||||
@ -777,17 +772,12 @@ void OS_X11::set_resizable(bool p_enabled) {
|
|||||||
XFree(xsh);
|
XFree(xsh);
|
||||||
current_videomode.resizable = p_enabled;
|
current_videomode.resizable = p_enabled;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool OS_X11::is_resizable() const {
|
bool OS_X11::is_resizable() const {
|
||||||
return current_videomode.resizable;
|
return current_videomode.resizable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::set_minimized(bool p_enabled) {
|
void OS_X11::set_minimized(bool p_enabled) {
|
||||||
|
|
||||||
if( is_fullscreen() )
|
|
||||||
set_fullscreen(false);
|
|
||||||
|
|
||||||
// Using ICCCM -- Inter-Client Communication Conventions Manual
|
// Using ICCCM -- Inter-Client Communication Conventions Manual
|
||||||
XEvent xev;
|
XEvent xev;
|
||||||
Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
|
Atom wm_change = XInternAtom(x11_display, "WM_CHANGE_STATE", False);
|
||||||
@ -799,7 +789,7 @@ void OS_X11::set_minimized(bool p_enabled) {
|
|||||||
xev.xclient.format = 32;
|
xev.xclient.format = 32;
|
||||||
xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState;
|
xev.xclient.data.l[0] = p_enabled ? WM_IconicState : WM_NormalState;
|
||||||
|
|
||||||
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev);
|
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||||
|
|
||||||
//XEvent xev;
|
//XEvent xev;
|
||||||
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
|
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
|
||||||
@ -1152,13 +1142,16 @@ void OS_X11::process_xevents() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VisibilityNotify: {
|
case VisibilityNotify: {
|
||||||
|
|
||||||
XVisibilityEvent * visibility = (XVisibilityEvent *)&event;
|
XVisibilityEvent * visibility = (XVisibilityEvent *)&event;
|
||||||
minimized = (visibility->state == VisibilityFullyObscured);
|
minimized = (visibility->state == VisibilityFullyObscured);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
|
if(current_videomode.fullscreen) {
|
||||||
|
set_minimized(false);
|
||||||
|
set_wm_fullscreen(true);
|
||||||
|
visual_server->init();
|
||||||
|
}
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||||
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
||||||
XGrabPointer(x11_display, x11_window, True,
|
XGrabPointer(x11_display, x11_window, True,
|
||||||
@ -1169,6 +1162,11 @@ void OS_X11::process_xevents() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
|
if(current_videomode.fullscreen) {
|
||||||
|
set_wm_fullscreen(false);
|
||||||
|
set_minimized(true);
|
||||||
|
visual_server->init();
|
||||||
|
}
|
||||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||||
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
||||||
//dear X11, I try, I really try, but you never work, you do whathever you want.
|
//dear X11, I try, I really try, but you never work, you do whathever you want.
|
||||||
|
Loading…
Reference in New Issue
Block a user