* 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_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() ) )
|
||||
|
||||
@ -35,12 +35,14 @@ func _fixed_process(delta):
|
||||
|
||||
|
||||
if(OS.get_screen_count() > 1):
|
||||
get_node("Button_Screen0").show()
|
||||
get_node("Button_Screen1").show()
|
||||
get_node("Label_Screen1_Resolution").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_Position").set_text( str("Screen1 Position:\n", OS.get_screen_position(1) ) )
|
||||
else:
|
||||
get_node("Button_Screen0").hide()
|
||||
get_node("Button_Screen1").hide()
|
||||
get_node("Label_Screen1_Resolution").hide()
|
||||
get_node("Label_Screen1_Position").hide()
|
||||
@ -57,21 +59,16 @@ func _fixed_process(delta):
|
||||
if( Input.is_action_pressed("ui_down")):
|
||||
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_Minimized").set_pressed( OS.is_minimized() )
|
||||
get_node("Button_Maximized").set_pressed( OS.is_maximized() )
|
||||
|
||||
|
||||
|
||||
func _ready():
|
||||
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():
|
||||
OS.set_window_position( Vector2(100,100) )
|
||||
|
||||
@ -88,12 +85,18 @@ func _on_Button_Screen1_pressed():
|
||||
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():
|
||||
if(OS.is_resizable()):
|
||||
OS.set_resizable(false)
|
||||
else:
|
||||
OS.set_resizable(true)
|
||||
|
||||
|
||||
|
||||
func _on_Button_Minimized_pressed():
|
||||
@ -108,3 +111,6 @@ func _on_Button_Maximized_pressed():
|
||||
OS.set_maximized(false)
|
||||
else:
|
||||
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.size.width = 800;
|
||||
window_data.size.height = 600;
|
||||
set_wm_border(false);
|
||||
//set_wm_border(false);
|
||||
set_wm_fullscreen(true);
|
||||
#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[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 {
|
||||
@ -661,10 +661,6 @@ Point2 OS_X11::get_window_position() const {
|
||||
}
|
||||
|
||||
void OS_X11::set_window_position(const Point2& p_position) {
|
||||
|
||||
if( current_videomode.fullscreen )
|
||||
return;
|
||||
|
||||
// Using EWMH -- Extended Window Manager Hints
|
||||
// to get the size of the decoration
|
||||
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) {
|
||||
if( current_videomode.fullscreen )
|
||||
return;
|
||||
|
||||
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
|
||||
}
|
||||
|
||||
void OS_X11::set_fullscreen(bool p_enabled) {
|
||||
|
||||
#if 0
|
||||
if(p_enabled && current_videomode.fullscreen)
|
||||
return;
|
||||
|
||||
@ -750,6 +744,9 @@ void OS_X11::set_fullscreen(bool p_enabled) {
|
||||
|
||||
current_videomode.fullscreen = False;
|
||||
}
|
||||
#endif
|
||||
set_wm_fullscreen(p_enabled);
|
||||
current_videomode.fullscreen = p_enabled;
|
||||
|
||||
visual_server->init();
|
||||
|
||||
@ -760,23 +757,20 @@ bool OS_X11::is_fullscreen() const {
|
||||
}
|
||||
|
||||
void OS_X11::set_resizable(bool p_enabled) {
|
||||
|
||||
if(!current_videomode.fullscreen) {
|
||||
XSizeHints *xsh;
|
||||
xsh = XAllocSizeHints();
|
||||
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
|
||||
if(!p_enabled) {
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display,x11_window,&xwa);
|
||||
xsh->min_width = xwa.width;
|
||||
xsh->max_width = xwa.width;
|
||||
xsh->min_height = xwa.height;
|
||||
xsh->max_height = xwa.height;
|
||||
}
|
||||
XSetWMNormalHints(x11_display, x11_window, xsh);
|
||||
XFree(xsh);
|
||||
current_videomode.resizable = p_enabled;
|
||||
XSizeHints *xsh;
|
||||
xsh = XAllocSizeHints();
|
||||
xsh->flags = p_enabled ? 0L : PMinSize | PMaxSize;
|
||||
if(!p_enabled) {
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display,x11_window,&xwa);
|
||||
xsh->min_width = xwa.width;
|
||||
xsh->max_width = xwa.width;
|
||||
xsh->min_height = xwa.height;
|
||||
xsh->max_height = xwa.height;
|
||||
}
|
||||
XSetWMNormalHints(x11_display, x11_window, xsh);
|
||||
XFree(xsh);
|
||||
current_videomode.resizable = p_enabled;
|
||||
}
|
||||
|
||||
bool OS_X11::is_resizable() const {
|
||||
@ -784,10 +778,6 @@ bool OS_X11::is_resizable() const {
|
||||
}
|
||||
|
||||
void OS_X11::set_minimized(bool p_enabled) {
|
||||
|
||||
if( is_fullscreen() )
|
||||
set_fullscreen(false);
|
||||
|
||||
// Using ICCCM -- Inter-Client Communication Conventions Manual
|
||||
XEvent xev;
|
||||
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.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;
|
||||
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
|
||||
@ -1152,13 +1142,16 @@ void OS_X11::process_xevents() {
|
||||
break;
|
||||
|
||||
case VisibilityNotify: {
|
||||
|
||||
XVisibilityEvent * visibility = (XVisibilityEvent *)&event;
|
||||
minimized = (visibility->state == VisibilityFullyObscured);
|
||||
|
||||
} break;
|
||||
|
||||
case FocusIn:
|
||||
if(current_videomode.fullscreen) {
|
||||
set_minimized(false);
|
||||
set_wm_fullscreen(true);
|
||||
visual_server->init();
|
||||
}
|
||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
|
||||
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
||||
XGrabPointer(x11_display, x11_window, True,
|
||||
@ -1169,6 +1162,11 @@ void OS_X11::process_xevents() {
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
if(current_videomode.fullscreen) {
|
||||
set_wm_fullscreen(false);
|
||||
set_minimized(true);
|
||||
visual_server->init();
|
||||
}
|
||||
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
|
||||
if (mouse_mode==MOUSE_MODE_CAPTURED) {
|
||||
//dear X11, I try, I really try, but you never work, you do whathever you want.
|
||||
|
Loading…
Reference in New Issue
Block a user