x11-fullscreen support through GDScript( OS.set_fullscreen(bool) )
This commit is contained in:
parent
0c2222188e
commit
97d290e466
|
@ -176,6 +176,14 @@ bool _OS::is_video_mode_fullscreen(int p_screen) const {
|
|||
|
||||
}
|
||||
|
||||
void _OS::set_fullscreen(bool p_fullscreen) {
|
||||
OS::get_singleton()->set_fullscreen(p_fullscreen);
|
||||
}
|
||||
|
||||
bool _OS::is_fullscreen() const {
|
||||
return OS::get_singleton()->is_fullscreen();
|
||||
}
|
||||
|
||||
void _OS::set_use_file_access_save_and_swap(bool p_enable) {
|
||||
|
||||
FileAccess::set_backup_save(p_enable);
|
||||
|
@ -632,6 +640,10 @@ void _OS::_bind_methods() {
|
|||
ObjectTypeDB::bind_method(_MD("is_video_mode_resizable","screen"),&_OS::is_video_mode_resizable,DEFVAL(0));
|
||||
ObjectTypeDB::bind_method(_MD("get_fullscreen_mode_list","screen"),&_OS::get_fullscreen_mode_list,DEFVAL(0));
|
||||
|
||||
//MSC
|
||||
ObjectTypeDB::bind_method(_MD("set_fullscreen","fullscreen"),&_OS::set_fullscreen);
|
||||
ObjectTypeDB::bind_method(_MD("is_fullscreen"),&_OS::is_fullscreen);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
|
||||
ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
|
||||
ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
|
||||
|
|
|
@ -108,6 +108,10 @@ public:
|
|||
bool is_video_mode_resizable(int p_screen=0) const;
|
||||
Array get_fullscreen_mode_list(int p_screen=0) const;
|
||||
|
||||
//MSC
|
||||
void set_fullscreen(bool p_fullscreen);
|
||||
bool is_fullscreen() const;
|
||||
|
||||
Error native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track);
|
||||
bool native_video_is_playing();
|
||||
void native_video_pause();
|
||||
|
|
|
@ -149,6 +149,10 @@ public:
|
|||
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0)=0;
|
||||
virtual VideoMode get_video_mode(int p_screen=0) const=0;
|
||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const=0;
|
||||
|
||||
//MSC
|
||||
virtual void set_fullscreen(bool fullscreen)=0;
|
||||
virtual bool is_fullscreen() const=0;
|
||||
|
||||
virtual void set_iterations_per_second(int p_ips);
|
||||
virtual int get_iterations_per_second() const;
|
||||
|
|
|
@ -521,6 +521,55 @@ void OS_X11::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) cons
|
|||
|
||||
}
|
||||
|
||||
void OS_X11::set_fullscreen(bool p_fullscreen) {
|
||||
|
||||
long wm_action;
|
||||
|
||||
if(p_fullscreen) {
|
||||
current_videomode.fullscreen = True;
|
||||
wm_action = 1;
|
||||
} else {
|
||||
current_videomode.fullscreen = False;
|
||||
wm_action = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
// MSC: Disabled until I can test it with lxde
|
||||
//
|
||||
// needed for lxde/openbox, possibly others
|
||||
Hints hints;
|
||||
Atom property;
|
||||
hints.flags = 2;
|
||||
hints.decorations = 0;
|
||||
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);
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes(x11_display, DefaultRootWindow(x11_display), &xwa);
|
||||
XMoveResizeWindow(x11_display, x11_window, 0, 0, xwa.width, xwa.height);
|
||||
*/
|
||||
|
||||
// code for netwm-compliants
|
||||
XEvent xev;
|
||||
Atom wm_state = XInternAtom(x11_display, "_NET_WM_STATE", False);
|
||||
Atom wm_fullscreen = XInternAtom(x11_display, "_NET_WM_STATE_FULLSCREEN", False);
|
||||
|
||||
memset(&xev, 0, sizeof(xev));
|
||||
xev.type = ClientMessage;
|
||||
xev.xclient.window = x11_window;
|
||||
xev.xclient.message_type = wm_state;
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.data.l[0] = wm_action;
|
||||
xev.xclient.data.l[1] = wm_fullscreen;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
|
||||
XSendEvent(x11_display, DefaultRootWindow(x11_display), False, SubstructureNotifyMask, &xev);
|
||||
|
||||
visual_server->init();
|
||||
}
|
||||
|
||||
bool OS_X11::is_fullscreen() const {
|
||||
}
|
||||
|
||||
InputModifierState OS_X11::get_key_modifier_state(unsigned int p_x11_state) {
|
||||
|
||||
|
|
|
@ -213,6 +213,9 @@ public:
|
|||
virtual VideoMode get_video_mode(int p_screen=0) const;
|
||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
|
||||
|
||||
virtual void set_fullscreen(bool p_fullscreen);
|
||||
virtual bool is_fullscreen() const;
|
||||
|
||||
virtual void move_window_to_foreground();
|
||||
|
||||
void run();
|
||||
|
|
Loading…
Reference in New Issue