WIP -- set_resizable() + is_resizable added
This commit is contained in:
parent
07b8d9136a
commit
d269344bbd
|
@ -220,6 +220,14 @@ void _OS::set_fullscreen(bool p_enabled) {
|
||||||
bool _OS::is_fullscreen() const {
|
bool _OS::is_fullscreen() const {
|
||||||
return OS::get_singleton()->is_fullscreen();
|
return OS::get_singleton()->is_fullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _OS::set_resizable(bool p_enabled) {
|
||||||
|
OS::get_singleton()->set_resizable(p_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _OS::is_resizable() const {
|
||||||
|
return OS::get_singleton()->is_resizable();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
|
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
|
||||||
|
@ -232,7 +240,6 @@ bool _OS::is_video_mode_resizable(int p_screen) const {
|
||||||
OS::VideoMode vm;
|
OS::VideoMode vm;
|
||||||
vm = OS::get_singleton()->get_video_mode(p_screen);
|
vm = OS::get_singleton()->get_video_mode(p_screen);
|
||||||
return vm.resizable;
|
return vm.resizable;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Array _OS::get_fullscreen_mode_list(int p_screen) const {
|
Array _OS::get_fullscreen_mode_list(int p_screen) const {
|
||||||
|
@ -690,6 +697,8 @@ void _OS::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size);
|
ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size);
|
||||||
ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen);
|
ObjectTypeDB::bind_method(_MD("set_fullscreen","enabled"),&_OS::set_fullscreen);
|
||||||
ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen);
|
ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen);
|
||||||
|
ObjectTypeDB::bind_method(_MD("set_resizable","enabled"),&_OS::set_resizable);
|
||||||
|
ObjectTypeDB::bind_method(_MD("is_resizable"),&_OS::is_resizable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
|
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
|
||||||
|
|
|
@ -120,6 +120,8 @@ public:
|
||||||
virtual void set_window_size(const Size2& p_size);
|
virtual void set_window_size(const Size2& p_size);
|
||||||
void set_fullscreen(bool p_enabled);
|
void set_fullscreen(bool p_enabled);
|
||||||
bool is_fullscreen() const;
|
bool is_fullscreen() const;
|
||||||
|
void set_resizable(bool p_enabled);
|
||||||
|
bool is_resizable() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
|
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
|
||||||
|
|
|
@ -162,6 +162,8 @@ public:
|
||||||
virtual void set_window_size(const Size2 p_size)=0;
|
virtual void set_window_size(const Size2 p_size)=0;
|
||||||
virtual void set_fullscreen(bool p_enabled)=0;
|
virtual void set_fullscreen(bool p_enabled)=0;
|
||||||
virtual bool is_fullscreen() const=0;
|
virtual bool is_fullscreen() const=0;
|
||||||
|
virtual void set_resizable(bool p_enabled)=0;
|
||||||
|
virtual bool is_resizable() const=0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual void set_iterations_per_second(int p_ips);
|
virtual void set_iterations_per_second(int p_ips);
|
||||||
|
|
|
@ -2,10 +2,18 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
func _fixed_process(delta):
|
func _fixed_process(delta):
|
||||||
|
|
||||||
|
var modetext = "Mode:\n"
|
||||||
|
|
||||||
if(OS.is_fullscreen()):
|
if(OS.is_fullscreen()):
|
||||||
get_node("Label_Fullscreen").set_text("Mode:\nFullscreen")
|
modetext += "Fullscreen\n"
|
||||||
else:
|
else:
|
||||||
get_node("Label_Fullscreen").set_text("Mode:\nWindowed")
|
modetext += "Windowed\n"
|
||||||
|
|
||||||
|
if(!OS.is_resizable()):
|
||||||
|
modetext += "FixedSize\n"
|
||||||
|
|
||||||
|
get_node("Label_Mode").set_text(modetext)
|
||||||
|
|
||||||
get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) )
|
get_node("Label_Position").set_text( str("Position:\n", OS.get_window_position() ) )
|
||||||
|
|
||||||
|
@ -19,6 +27,7 @@ func _fixed_process(delta):
|
||||||
|
|
||||||
get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position()))
|
get_node("Label_Screen0_Position").set_text(str("Screen0 Position:\n",OS.get_screen_position()))
|
||||||
|
|
||||||
|
|
||||||
if(OS.get_screen_count() > 1):
|
if(OS.get_screen_count() > 1):
|
||||||
get_node("Button_Screen1").show()
|
get_node("Button_Screen1").show()
|
||||||
get_node("Label_Screen1_Resolution").show()
|
get_node("Label_Screen1_Resolution").show()
|
||||||
|
@ -42,6 +51,9 @@ 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_FixedSize").set_pressed( !OS.is_resizable() )
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
set_fixed_process(true)
|
set_fixed_process(true)
|
||||||
|
|
||||||
|
@ -67,3 +79,15 @@ func _on_Button_Screen0_pressed():
|
||||||
|
|
||||||
func _on_Button_Screen1_pressed():
|
func _on_Button_Screen1_pressed():
|
||||||
OS.set_screen(1)
|
OS.set_screen(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_FixedSize_pressed():
|
||||||
|
if(OS.is_resizable()):
|
||||||
|
OS.set_resizable(false)
|
||||||
|
else:
|
||||||
|
OS.set_resizable(true)
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -223,7 +223,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable resizeable window
|
// disable resizable window
|
||||||
if (!current_videomode.resizable) {
|
if (!current_videomode.resizable) {
|
||||||
XSizeHints *xsh;
|
XSizeHints *xsh;
|
||||||
xsh = XAllocSizeHints();
|
xsh = XAllocSizeHints();
|
||||||
|
@ -239,7 +239,9 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
xsh->min_height = xwa.height;
|
xsh->min_height = xwa.height;
|
||||||
xsh->max_height = xwa.height;
|
xsh->max_height = xwa.height;
|
||||||
XSetWMNormalHints(x11_display, x11_window, xsh);
|
XSetWMNormalHints(x11_display, x11_window, xsh);
|
||||||
|
XFree(xsh);
|
||||||
}
|
}
|
||||||
|
current_videomode.resizable;
|
||||||
|
|
||||||
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
|
AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
|
||||||
|
|
||||||
|
@ -277,19 +279,19 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
|
||||||
|
|
||||||
XChangeWindowAttributes(x11_display, x11_window,CWEventMask,&new_attr);
|
XChangeWindowAttributes(x11_display, x11_window,CWEventMask,&new_attr);
|
||||||
|
|
||||||
XClassHint* classHint;
|
XClassHint* classHint;
|
||||||
|
|
||||||
/* set the titlebar name */
|
/* set the titlebar name */
|
||||||
XStoreName(x11_display, x11_window, "Godot");
|
XStoreName(x11_display, x11_window, "Godot");
|
||||||
|
|
||||||
/* set the name and class hints for the window manager to use */
|
/* set the name and class hints for the window manager to use */
|
||||||
classHint = XAllocClassHint();
|
classHint = XAllocClassHint();
|
||||||
if (classHint) {
|
if (classHint) {
|
||||||
classHint->res_name = "Godot";
|
classHint->res_name = "Godot";
|
||||||
classHint->res_class = "Godot";
|
classHint->res_class = "Godot";
|
||||||
}
|
}
|
||||||
XSetClassHint(x11_display, x11_window, classHint);
|
XSetClassHint(x11_display, x11_window, classHint);
|
||||||
XFree(classHint);
|
XFree(classHint);
|
||||||
|
|
||||||
wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
|
wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
|
||||||
XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
|
XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
|
||||||
|
@ -708,6 +710,9 @@ void OS_X11::set_fullscreen(bool p_enabled) {
|
||||||
if(p_enabled && current_videomode.fullscreen)
|
if(p_enabled && current_videomode.fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(!current_videomode.resizable)
|
||||||
|
set_resizable(true);
|
||||||
|
|
||||||
if(p_enabled) {
|
if(p_enabled) {
|
||||||
window_data.size = get_window_size();
|
window_data.size = get_window_size();
|
||||||
window_data.position = get_window_position();
|
window_data.position = get_window_position();
|
||||||
|
@ -734,11 +739,37 @@ void OS_X11::set_fullscreen(bool p_enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
visual_server->init();
|
visual_server->init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OS_X11::is_fullscreen() const {
|
bool OS_X11::is_fullscreen() const {
|
||||||
return current_videomode.fullscreen;
|
return current_videomode.fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
printf("%d %d\n", xwa.width, xwa.height);
|
||||||
|
}
|
||||||
|
XSetWMNormalHints(x11_display, x11_window, xsh);
|
||||||
|
XFree(xsh);
|
||||||
|
current_videomode.resizable = p_enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OS_X11::is_resizable() const {
|
||||||
|
return current_videomode.resizable;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
|
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
|
||||||
|
@ -1688,6 +1719,4 @@ OS_X11::OS_X11() {
|
||||||
minimized = false;
|
minimized = false;
|
||||||
xim_style=NULL;
|
xim_style=NULL;
|
||||||
mouse_mode=MOUSE_MODE_VISIBLE;
|
mouse_mode=MOUSE_MODE_VISIBLE;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,10 +160,15 @@ class OS_X11 : public OS_Unix {
|
||||||
Joystick joysticks[JOYSTICKS_MAX];
|
Joystick joysticks[JOYSTICKS_MAX];
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_WM_API
|
#ifdef EXPERIMENTAL_WM_API
|
||||||
|
// This struct saves the values of the window before going fullscreen
|
||||||
|
// to be able to restore the same state after leaving fullscreen
|
||||||
struct {
|
struct {
|
||||||
|
bool resizable;
|
||||||
Point2i position;
|
Point2i position;
|
||||||
Size2i size;
|
Size2i size;
|
||||||
} window_data;
|
} window_data;
|
||||||
|
|
||||||
|
bool maximized;
|
||||||
void set_wm_border(bool p_enabled);
|
void set_wm_border(bool p_enabled);
|
||||||
void set_wm_fullscreen(bool p_enabled);
|
void set_wm_fullscreen(bool p_enabled);
|
||||||
#endif
|
#endif
|
||||||
|
@ -234,6 +239,8 @@ public:
|
||||||
virtual void set_window_size(const Size2 p_size);
|
virtual void set_window_size(const Size2 p_size);
|
||||||
virtual void set_fullscreen(bool p_enabled);
|
virtual void set_fullscreen(bool p_enabled);
|
||||||
virtual bool is_fullscreen() const;
|
virtual bool is_fullscreen() const;
|
||||||
|
virtual void set_resizable(bool p_enabled);
|
||||||
|
virtual bool is_resizable() const;
|
||||||
#endif
|
#endif
|
||||||
virtual void move_window_to_foreground();
|
virtual void move_window_to_foreground();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue