summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/build.gradle.template3
-rw-r--r--platform/android/export/export.cpp3
-rw-r--r--platform/bb10/export/export.cpp3
-rw-r--r--platform/javascript/audio_driver_javascript.h2
-rw-r--r--platform/javascript/detect.py13
-rw-r--r--platform/javascript/export/export.cpp8
-rw-r--r--platform/javascript/godot_shell.html16
-rw-r--r--platform/javascript/javascript_eval.cpp2
-rw-r--r--platform/javascript/os_javascript.cpp37
-rw-r--r--platform/javascript/os_javascript.h5
-rw-r--r--platform/osx/export/export.cpp3
-rw-r--r--platform/uwp/export/export.cpp3
-rw-r--r--platform/windows/export/export.cpp3
-rw-r--r--platform/windows/os_windows.cpp41
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/detect.py25
-rw-r--r--platform/x11/export/export.cpp3
-rw-r--r--platform/x11/os_x11.cpp96
-rw-r--r--platform/x11/os_x11.h2
19 files changed, 156 insertions, 113 deletions
diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template
index 873eef0566..c46a15bd12 100644
--- a/platform/android/build.gradle.template
+++ b/platform/android/build.gradle.template
@@ -52,11 +52,10 @@ android {
java.srcDirs = ['src'
$$GRADLE_JAVA_DIRS$$
]
- resources.srcDirs = [
+ res.srcDirs = [
'res'
$$GRADLE_RES_DIRS$$
]
- res.srcDirs = ['res']
// libs.srcDirs = ['libs']
aidl.srcDirs = [
'aidl'
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 33283eccea..8e1fda74ed 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -38,7 +38,7 @@
#include "os/os.h"
#include "platform/android/logo.h"
#include <string.h>
-
+#if 0
static const char* android_perms[]={
"ACCESS_CHECKIN_PROPERTIES",
@@ -1915,3 +1915,4 @@ void register_android_exporter() {
EditorImportExport::get_singleton()->add_export_platform(exporter);
}
+#endif
diff --git a/platform/bb10/export/export.cpp b/platform/bb10/export/export.cpp
index cc994c8f24..3e6dadb094 100644
--- a/platform/bb10/export/export.cpp
+++ b/platform/bb10/export/export.cpp
@@ -40,7 +40,7 @@
#include "io/xml_parser.h"
#define MAX_DEVICES 5
-
+#if 0
class EditorExportPlatformBB10 : public EditorExportPlatform {
GDCLASS( EditorExportPlatformBB10,EditorExportPlatform );
@@ -827,3 +827,4 @@ void register_bb10_exporter() {
}
+#endif
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h
index da146fcdd0..4c2064663a 100644
--- a/platform/javascript/audio_driver_javascript.h
+++ b/platform/javascript/audio_driver_javascript.h
@@ -36,8 +36,6 @@
class AudioDriverJavaScript : public AudioDriver {
public:
- void set_singleton();
-
virtual const char* get_name() const;
virtual Error init();
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 55b05a9123..a701823b2e 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -14,9 +14,7 @@ def get_name():
def can_build():
import os
- if (not os.environ.has_key("EMSCRIPTEN_ROOT")):
- return False
- return True
+ return os.environ.has_key("EMSCRIPTEN_ROOT")
def get_opts():
@@ -79,9 +77,8 @@ def configure(env):
# These flags help keep the file size down
env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti'])
env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
- env.Append(CPPFLAGS=['-DGLES2_ENABLED'])
+ env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS'])
-# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT'])
if env['wasm'] == 'yes':
env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
@@ -101,14 +98,10 @@ def configure(env):
env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED'])
env.Append(LINKFLAGS=['-O2'])
+ env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
# env.Append(LINKFLAGS=['-g4'])
# print "CCCOM is:", env.subst('$CCCOM')
# print "P: ", env['p'], " Platofrm: ", env['platform']
import methods
-
- env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')})
- env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')})
- #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index e0ff9932cc..e487383ef4 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -38,6 +38,9 @@
#include "os/os.h"
#include "platform/javascript/logo.h"
#include "string.h"
+
+
+#if 0
class EditorExportPlatformJavaScript : public EditorExportPlatform {
GDCLASS( EditorExportPlatformJavaScript,EditorExportPlatform );
@@ -181,8 +184,8 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St
String current_line = lines[i];
current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024));
current_line = current_line.replace("$GODOT_BASE",p_name);
- current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/width"));
- current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/height"));
+ current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/window/width"));
+ current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/window/height"));
current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) GlobalConfig::get_singleton()->get("application/name"));
current_line = current_line.replace("$GODOT_HEAD_INCLUDE",html_head_include);
current_line = current_line.replace("$GODOT_STYLE_FONT_FAMILY",html_font_family);
@@ -424,3 +427,4 @@ void register_javascript_exporter() {
}
+#endif
diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html
index a8b9594935..65f3b4a340 100644
--- a/platform/javascript/godot_shell.html
+++ b/platform/javascript/godot_shell.html
@@ -277,10 +277,10 @@ $GODOT_STYLE_INCLUDE
statusElement.appendChild(closeNote);
Presentation.setStatusVisible(true);
},
- isWebGLAvailable: function isWebGLAvailable() {
+ isWebGL2Available: function isWebGL2Available() {
var context;
try {
- context = canvasElement.getContext("webgl") || canvasElement.getContext("experimental-webgl");
+ context = canvasElement.getContext("webgl2") || canvasElement.getContext("experimental-webgl2");
} catch (e) {}
return !!context;
},
@@ -319,12 +319,12 @@ $GODOT_STYLE_INCLUDE
outputElement.firstChild.remove();
}
var msg = document.createElement("div");
- if (text.trim().startsWith("**ERROR**")
- || text.startsWith("**EXCEPTION**")) {
+ if (String.prototype.trim.call(text).startsWith("**ERROR**")
+ || String.prototype.trim.call(text).startsWith("**EXCEPTION**")) {
msg.style.color = "#d44";
- } else if (text.trim().startsWith("**WARNING**")) {
+ } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) {
msg.style.color = "#ccc000";
- } else if (text.trim().startsWith("**SCRIPT ERROR**")) {
+ } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) {
msg.style.color = "#c6d";
}
msg.textContent = text;
@@ -395,8 +395,8 @@ $GODOT_STYLE_INCLUDE
}
};
- if (!Presentation.isWebGLAvailable()) {
- Presentation.setStatus("WebGL appears to be unsupported in the current browser.\nPlease try updating or use a different browser.");
+ if (!Presentation.isWebGL2Available()) {
+ Presentation.setStatus("WebGL2 appears to be unsupported in the current browser.\nPlease try updating or use a different browser.");
Presentation.preventLoading = true;
} else {
Presentation.setStatus("Downloading...");
diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp
index a79e5473c2..72b7ab06cd 100644
--- a/platform/javascript/javascript_eval.cpp
+++ b/platform/javascript/javascript_eval.cpp
@@ -156,7 +156,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) {
void JavaScript::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false);
+ ClassDB::bind_method(_MD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false);
}
JavaScript::JavaScript() {
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index 317a6676a4..b8c3dea3b4 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -28,7 +28,7 @@
/*************************************************************************/
#include "os_javascript.h"
-#include "drivers/gles2/rasterizer_gles2.h"
+#include "drivers/gles3/rasterizer_gles3.h"
#include "core/io/file_access_buffered_fa.h"
#include "drivers/unix/file_access_unix.h"
#include "drivers/unix/dir_access_unix.h"
@@ -47,7 +47,7 @@ int OS_JavaScript::get_video_driver_count() const {
const char * OS_JavaScript::get_video_driver_name(int p_driver) const {
- return "GLES2";
+ return "GLES3";
}
OS::VideoMode OS_JavaScript::get_default_video_mode() const {
@@ -237,30 +237,20 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int
print_line("Init Audio");
AudioDriverManager::add_driver(&audio_driver_javascript);
+ audio_driver_javascript.set_singleton();
+ if (audio_driver_javascript.init() != OK) {
- if (true) {
- RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,false,false,false) );
- rasterizer_gles22->set_use_framebuffers(false); //not supported by emscripten
- if (gl_extensions)
- rasterizer_gles22->set_extensions(gl_extensions);
- rasterizer = rasterizer_gles22;
- } else {
- //rasterizer = memnew( RasterizerGLES1(true, false) );
+ ERR_PRINT("Initializing audio failed.");
}
+ RasterizerGLES3::register_config();
+ RasterizerGLES3::make_current();
+
print_line("Init VS");
- visual_server = memnew( VisualServerRaster(rasterizer) );
- visual_server->init();
+ visual_server = memnew( VisualServerRaster() );
visual_server->cursor_set_visible(false, 0);
- /*AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton();
-
- if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) {
-
- ERR_PRINT("Initializing audio failed.");
- }*/
-
print_line("Init Physicsserver");
physics_server = memnew( PhysicsServerSW );
@@ -767,14 +757,6 @@ void OS_JavaScript::main_loop_request_quit() {
main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST);
}
-void OS_JavaScript::reload_gfx() {
-
- if (gfx_init_func)
- gfx_init_func(gfx_init_ud,use_gl2,video_mode.width,video_mode.height,video_mode.fullscreen);
- if (rasterizer)
- rasterizer->reload_vram();
-}
-
Error OS_JavaScript::shell_open(String p_uri) {
/* clang-format off */
EM_ASM_({
@@ -877,7 +859,6 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Get
main_loop=NULL;
last_id=1;
gl_extensions=NULL;
- rasterizer=NULL;
window_maximized=false;
get_data_dir_func=p_get_data_dir_func;
diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h
index d11494a8aa..582f128ce8 100644
--- a/platform/javascript/os_javascript.h
+++ b/platform/javascript/os_javascript.h
@@ -33,8 +33,6 @@
#include "drivers/unix/os_unix.h"
#include "os/main_loop.h"
#include "servers/physics/physics_server_sw.h"
-#include "servers/spatial_sound/spatial_sound_server_sw.h"
-#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "servers/audio_server.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/visual/rasterizer.h"
@@ -70,7 +68,6 @@ private:
int64_t time_to_save_sync;
int64_t last_sync_time;
- Rasterizer *rasterizer;
VisualServer *visual_server;
PhysicsServer *physics_server;
Physics2DServer *physics_2d_server;
@@ -165,8 +162,6 @@ public:
void set_opengl_extensions(const char* p_gl_extensions);
- void reload_gfx();
-
virtual Error shell_open(String p_uri);
virtual String get_data_dir() const;
String get_executable_path() const;
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp
index 1cb41cede2..3a97827c16 100644
--- a/platform/osx/export/export.cpp
+++ b/platform/osx/export/export.cpp
@@ -39,7 +39,7 @@
#include "os/os.h"
#include "platform/osx/logo.h"
#include "string.h"
-
+#if 0
class EditorExportPlatformOSX : public EditorExportPlatform {
@@ -546,3 +546,4 @@ void register_osx_exporter() {
}
+#endif
diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp
index f31c91ef6d..167a5831cf 100644
--- a/platform/uwp/export/export.cpp
+++ b/platform/uwp/export/export.cpp
@@ -65,7 +65,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*************************************************************************/
-
+#if 0
#include "version.h"
#include "export.h"
#include "object.h"
@@ -2390,3 +2390,4 @@ void register_uwp_exporter() {
Ref<EditorExportPlatformUWP> exporter = Ref<EditorExportPlatformUWP>(memnew(EditorExportPlatformUWP));
EditorImportExport::get_singleton()->add_export_platform(exporter);
}
+#endif
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index 1ad61844d0..88d534887b 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -29,7 +29,7 @@
#include "export.h"
#include "platform/windows/logo.h"
#include "tools/editor/editor_import_export.h"
-
+#if 0
void register_windows_exporter() {
Image img(_windows_logo);
@@ -50,3 +50,4 @@ void register_windows_exporter() {
}
+#endif
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index d1d769adf7..b230dda9cb 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -254,6 +254,25 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) // Check For Windows Messages
{
+ case WM_SETFOCUS:
+ {
+ window_has_focus = true;
+ // Re-capture cursor if we're in one of the capture modes
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
+ SetCapture(hWnd);
+ }
+ break;
+ }
+ case WM_KILLFOCUS:
+ {
+ window_has_focus = false;
+
+ // Release capture if we're in one of the capture modes
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
+ ReleaseCapture();
+ }
+ break;
+ }
case WM_ACTIVATE: // Watch For Window Activate Message
{
minimized = HIWORD(wParam) != 0;
@@ -266,19 +285,17 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
alt_mem=false;
control_mem=false;
shift_mem=false;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
RECT clipRect;
GetClientRect(hWnd, &clipRect);
ClientToScreen(hWnd, (POINT*) &clipRect.left);
ClientToScreen(hWnd, (POINT*) &clipRect.right);
ClipCursor(&clipRect);
SetCapture(hWnd);
-
}
} else {
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
alt_mem=false;
-
};
return 0; // Return To The Message Loop
@@ -345,6 +362,9 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
+ // Don't calculate relative mouse movement if we don't have focus in CAPTURED mode.
+ if (!window_has_focus && mouse_mode==MOUSE_MODE_CAPTURED)
+ break;
/*
LPARAM extra = GetMessageExtraInfo();
if (IsPenEvent(extra)) {
@@ -376,7 +396,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
mm.button_mask|=(wParam&MK_XBUTTON2)?(1<<6):0;*/
mm.x=GET_X_LPARAM(lParam);
mm.y=GET_Y_LPARAM(lParam);
-
+
if (mouse_mode==MOUSE_MODE_CAPTURED) {
Point2i c(video_mode.width/2,video_mode.height/2);
@@ -410,7 +430,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
mm.relative_y=mm.y-old_y;
old_x=mm.x;
old_y=mm.y;
- if (main_loop)
+ if (window_has_focus && main_loop)
input->parse_input_event(event);
@@ -714,9 +734,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
joypad->probe_joypads();
} break;
case WM_SETCURSOR: {
-
if(LOWORD(lParam) == HTCLIENT) {
- if(mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED) {
+ if(window_has_focus && (mouse_mode == MOUSE_MODE_HIDDEN || mouse_mode == MOUSE_MODE_CAPTURED)) {
//Hide the cursor
if(hCursor == NULL)
hCursor = SetCursor(NULL);
@@ -948,7 +967,7 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
main_loop=NULL;
outside=true;
-
+ window_has_focus=true;
WNDCLASSEXW wc;
video_mode=p_desired;
@@ -1326,17 +1345,17 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) {
if (mouse_mode==p_mode)
return;
mouse_mode=p_mode;
- if (p_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED) {
RECT clipRect;
GetClientRect(hWnd, &clipRect);
ClientToScreen(hWnd, (POINT*) &clipRect.left);
ClientToScreen(hWnd, (POINT*) &clipRect.right);
ClipCursor(&clipRect);
- SetCapture(hWnd);
center=Point2i(video_mode.width/2,video_mode.height/2);
POINT pos = { (int) center.x, (int) center.y };
ClientToScreen(hWnd, &pos);
- SetCursorPos(pos.x, pos.y);
+ if (mouse_mode==MOUSE_MODE_CAPTURED)
+ SetCursorPos(pos.x, pos.y);
} else {
ReleaseCapture();
ClipCursor(NULL);
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index a5c8ecbe1b..2c8fa64f8e 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -118,6 +118,7 @@ class OS_Windows : public OS {
bool control_mem;
bool meta_mem;
bool force_quit;
+ bool window_has_focus;
uint32_t last_button_state;
CursorShape cursor_shape;
diff --git a/platform/x11/detect.py b/platform/x11/detect.py
index b5f6359d21..89cf639114 100644
--- a/platform/x11/detect.py
+++ b/platform/x11/detect.py
@@ -61,6 +61,7 @@ def get_opts():
('use_static_cpp', 'link stdc++ statically', 'no'),
('use_sanitizer', 'Use llvm compiler sanitize address', 'no'),
('use_leak_sanitizer', 'Use llvm compiler sanitize memory leaks', 'no'),
+ ('use_lto', 'Use link time optimization', 'no'),
('pulseaudio', 'Detect & Use pulseaudio', 'yes'),
('udev', 'Use udev for gamepad connection callbacks', 'no'),
('debug_release', 'Add debug symbols to release version', 'no'),
@@ -97,12 +98,12 @@ def configure(env):
env.extra_suffix = ".llvm"
if (env["use_sanitizer"] == "yes"):
- env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
if (env["use_leak_sanitizer"] == "yes"):
- env.Append(CXXFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
+ env.Append(CCFLAGS=['-fsanitize=address', '-fno-omit-frame-pointer'])
env.Append(LINKFLAGS=['-fsanitize=address'])
env.extra_suffix += "s"
@@ -111,22 +112,28 @@ def configure(env):
# env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
# env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
- if (env["target"] == "release"):
+ if (env["use_lto"] == "yes"):
+ env.Append(CCFLAGS=['-flto'])
+ env.Append(LINKFLAGS=['-flto'])
+
+
+ env.Append(CCFLAGS=['-pipe'])
+ env.Append(LINKFLAGS=['-pipe'])
+ if (env["target"] == "release"):
+ env.Prepend(CCFLAGS=['-Ofast'])
if (env["debug_release"] == "yes"):
- env.Append(CCFLAGS=['-g2'])
- else:
- env.Append(CCFLAGS=['-O3', '-ffast-math'])
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "release_debug"):
- env.Append(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
+ env.Prepend(CCFLAGS=['-O2', '-ffast-math', '-DDEBUG_ENABLED'])
if (env["debug_release"] == "yes"):
- env.Append(CCFLAGS=['-g2'])
+ env.Prepend(CCFLAGS=['-g2'])
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Prepend(CCFLAGS=['-g2', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env.ParseConfig('pkg-config x11 --cflags --libs')
env.ParseConfig('pkg-config xinerama --cflags --libs')
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index c1af323453..5a4751b387 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -30,7 +30,7 @@
#include "platform/x11/logo.h"
#include "tools/editor/editor_import_export.h"
#include "scene/resources/texture.h"
-
+#if 0
void register_x11_exporter() {
Image img(_x11_logo);
@@ -50,3 +50,4 @@ void register_x11_exporter() {
}
}
+#endif
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 41746c2431..e792d0465e 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -295,6 +295,7 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
}
+
ERR_FAIL_COND(!visual_server);
ERR_FAIL_COND(x11_window==0);
@@ -449,6 +450,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
physics_2d_server->init();
input = memnew( InputDefault );
+
+ window_has_focus = true; // Set focus to true at init
#ifdef JOYDEV_ENABLED
joypad = memnew( JoypadLinux(input));
#endif
@@ -517,17 +520,21 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
if (p_mode==mouse_mode)
return;
- if (mouse_mode==MOUSE_MODE_CAPTURED)
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED)
XUngrabPointer(x11_display, CurrentTime);
- if (mouse_mode!=MOUSE_MODE_VISIBLE && p_mode==MOUSE_MODE_VISIBLE)
- XUndefineCursor(x11_display,x11_window);
- if (p_mode!=MOUSE_MODE_VISIBLE && mouse_mode==MOUSE_MODE_VISIBLE) {
- XDefineCursor(x11_display,x11_window,null_cursor);
+
+ // The only modes that show a cursor are VISIBLE and CONFINED
+ bool showCursor = (p_mode == MOUSE_MODE_VISIBLE || p_mode == MOUSE_MODE_CONFINED);
+
+ if (showCursor) {
+ XUndefineCursor(x11_display,x11_window); // show cursor
+ } else {
+ XDefineCursor(x11_display,x11_window,null_cursor); // hide cursor
}
mouse_mode=p_mode;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) {
while(true) {
//flush pending motion events
@@ -768,13 +775,31 @@ void OS_X11::set_window_position(const Point2& p_position) {
}
Size2 OS_X11::get_window_size() const {
- XWindowAttributes xwa;
- XGetWindowAttributes(x11_display, x11_window, &xwa);
- return Size2i(xwa.width, xwa.height);
+ // Use current_videomode width and height instead of XGetWindowAttributes
+ // since right after a XResizeWindow the attributes may not be updated yet
+ return Size2i(current_videomode.width, current_videomode.height);
}
void OS_X11::set_window_size(const Size2 p_size) {
+ // If window resizable is disabled we need to update the attributes first
+ if (is_window_resizable() == false) {
+ XSizeHints *xsh;
+ xsh = XAllocSizeHints();
+ xsh->flags = PMinSize | PMaxSize;
+ xsh->min_width = p_size.x;
+ xsh->max_width = p_size.x;
+ xsh->min_height = p_size.y;
+ xsh->max_height = p_size.y;
+ XSetWMNormalHints(x11_display, x11_window, xsh);
+ XFree(xsh);
+ }
+
+ // Resize the window
XResizeWindow(x11_display, x11_window, p_size.x, p_size.y);
+
+ // Update our videomode width and height
+ current_videomode.width = p_size.x;
+ current_videomode.height = p_size.y;
}
void OS_X11::set_window_fullscreen(bool p_enabled) {
@@ -788,15 +813,15 @@ bool OS_X11::is_window_fullscreen() const {
void OS_X11::set_window_resizable(bool p_enabled) {
XSizeHints *xsh;
+ Size2 size = get_window_size();
+
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;
+ xsh->min_width = size.x;
+ xsh->max_width = size.x;
+ xsh->min_height = size.y;
+ xsh->max_height = size.y;
}
XSetWMNormalHints(x11_display, x11_window, xsh);
XFree(xsh);
@@ -1253,6 +1278,10 @@ void OS_X11::process_xevents() {
do_mouse_warp=false;
+
+ // Is the current mouse mode one where it needs to be grabbed.
+ bool mouse_mode_grab = mouse_mode==MOUSE_MODE_CAPTURED || mouse_mode==MOUSE_MODE_CONFINED;
+
while (XPending(x11_display) > 0) {
XEvent event;
XNextEvent(x11_display, &event);
@@ -1271,35 +1300,45 @@ void OS_X11::process_xevents() {
minimized = (visibility->state == VisibilityFullyObscured);
} break;
case LeaveNotify: {
-
- if (main_loop && mouse_mode!=MOUSE_MODE_CAPTURED)
+ if (main_loop && !mouse_mode_grab)
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_EXIT);
if (input)
input->set_mouse_in_window(false);
} break;
case EnterNotify: {
-
- if (main_loop && mouse_mode!=MOUSE_MODE_CAPTURED)
+ if (main_loop && !mouse_mode_grab)
main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
if (input)
input->set_mouse_in_window(true);
} break;
case FocusIn:
minimized = false;
+ window_has_focus = true;
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_IN);
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode_grab) {
+ // Show and update the cursor if confined and the window regained focus.
+ if (mouse_mode==MOUSE_MODE_CONFINED)
+ XUndefineCursor(x11_display, x11_window);
+ else if (mouse_mode==MOUSE_MODE_CAPTURED) // or re-hide it in captured mode
+ XDefineCursor(x11_display, x11_window, null_cursor);
+
XGrabPointer(
- x11_display, x11_window, True,
+ x11_display, x11_window, True,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime);
}
break;
case FocusOut:
+ window_has_focus = false;
main_loop->notification(MainLoop::NOTIFICATION_WM_FOCUS_OUT);
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode_grab) {
//dear X11, I try, I really try, but you never work, you do whathever you want.
+ if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ // Show the cursor if we're in captured mode so it doesn't look weird.
+ XUndefineCursor(x11_display, x11_window);
+ }
XUngrabPointer(x11_display, CurrentTime);
}
break;
@@ -1319,7 +1358,7 @@ void OS_X11::process_xevents() {
/* exit in case of a mouse button press */
last_timestamp=event.xbutton.time;
- if (mouse_mode==MOUSE_MODE_CAPTURED) {
+ if (mouse_mode == MOUSE_MODE_CAPTURED) {
event.xbutton.x=last_mouse_pos.x;
event.xbutton.y=last_mouse_pos.y;
}
@@ -1342,7 +1381,6 @@ void OS_X11::process_xevents() {
mouse_event.mouse_button.pressed=(event.type==ButtonPress);
-
if (event.type==ButtonPress && event.xbutton.button==1) {
uint64_t diff = get_ticks_usec()/1000 - last_click_ms;
@@ -1376,7 +1414,6 @@ void OS_X11::process_xevents() {
// PLEASE DO ME A FAVOR AND DIE DROWNED IN A FECAL
// MOUNTAIN BECAUSE THAT'S WHERE YOU BELONG.
-
while(true) {
if (mouse_mode==MOUSE_MODE_CAPTURED && event.xmotion.x==current_videomode.width/2 && event.xmotion.y==current_videomode.height/2) {
//this is likely the warp event since it was warped here
@@ -1418,7 +1455,7 @@ void OS_X11::process_xevents() {
Point2i new_center = pos;
pos = last_mouse_pos + ( pos - center );
center=new_center;
- do_mouse_warp=true;
+ do_mouse_warp=window_has_focus; // warp the cursor if we're focused in
#else
//Dear X11, thanks for making my life miserable
@@ -1461,8 +1498,11 @@ void OS_X11::process_xevents() {
last_mouse_pos=pos;
// printf("rel: %d,%d\n", rel.x, rel.y );
-
- input->parse_input_event( motion_event);
+ // Don't propagate the motion event unless we have focus
+ // this is so that the relative motion doesn't get messed up
+ // after we regain focus.
+ if (window_has_focus || !mouse_mode_grab)
+ input->parse_input_event( motion_event);
} break;
case KeyPress:
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 3245df32c6..3ec358f103 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -134,7 +134,7 @@ class OS_X11 : public OS_Unix {
bool force_quit;
bool minimized;
-
+ bool window_has_focus;
bool do_mouse_warp;
const char *cursor_theme;