Commit Graph

59 Commits

Author SHA1 Message Date
reduz 2787ad65be RenderingServer reorganization 2020-12-04 18:39:46 -03:00
reduz e93b2242c2 Reorganize rendering server.
-Made RenderingServerScene abstract, allowing reimplementation
-RenderingServerRaster -> RenderingServerDefault, but this class is going away soon.
2020-12-03 19:01:01 -03:00
Rémi Verschelde f1a9de9c59
X11: Include limits.h for LONG_MAX
Fixes #44030.
2020-12-02 15:43:29 +01:00
PouleyKetchoupp 6b97901d4d Implement INCR mechanism for Linux clipboard
Allows pasting from x11 clipboard to receive data incrementally, which
is required when handling data size > 256KB.
2020-11-27 10:00:09 -07:00
Rémi Verschelde a4e04cdd47
Merge pull request #42652 from nekomatata/x11-clipboard-save-targets
Implement SAVE_TARGETS mechanism for Linux clipboard
2020-11-26 09:34:18 +01:00
bruvzg 319bc5ffda
Add XChangeProperty Atoms validity checks. 2020-11-15 22:20:14 +02:00
bruvzg f09a37a8d5
Fixes crash if Vulkan presentation surface is not available. 2020-11-14 13:41:13 +02:00
bruvzg fed776c64c
Add X11 Atom validity checks. 2020-11-12 16:10:17 +02:00
reduz 127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00
PouleyKetchoupp 96e8b904cf Implement SAVE_TARGETS mechanism for Linux clipboard
Allows sending the clipboard content to the clipboard manager on exit to
keep the content when using a clipboard manager that doesn't
automatically makes a backup when copying.

MULTIPLE selection mechanism also had to be implemented, because in this
case, the clipboard manager might request multiple selection targets at
once.

Known use case: Ubuntu with XFCE4
2020-10-09 21:12:56 +02:00
PouleyKetchoupp 48a0d44e67 Fix x11 display server crash when deleting popup window when unfocused
On FocusOut events, the window could be destroyed while propagating
WINDOW_EVENT_FOCUS_OUT event, which causes the WindowData to be
invalidated, and still used for calls to XUnsetICFocus.

This change moves calls to XUnsetICFocus, and also XSetICFocus in
FocusIn events, before propagating the change of focus event to the
engine, to be safe in any case.

Also setting xic member to nullptr after all calls to XDestroyIC to keep
things clean and consistent.

Fixes #42645
2020-10-08 17:22:03 +02:00
PouleyKetchoupp 5a0376f969 Fix delay to process clipboard content from Godot in other programs
When pasting clipboard content from Godot to other applications,
multiple SelectionRequest events are sent to Godot in order to access
the data. It could take a long time before the data is ready for the
other app because events were processed one by one on the main thread,
especially when Godot is unfocused and runs at low frequency.

With this change, SelectionRequest events are directly handled on the
separate event polling thread to minimize this delay.

This change also replaces clipboard_get() calls in SelectionRequest with
a direct access to internal_clipboard, since in this case we know Godot
is the owner of the clipboard content and it's not necessary to query
the x server for it.
2020-09-25 16:40:04 +02:00
PouleyKetchoupp 2c4d64102a Fix general keyboard input lag on X11 display server
This change makes keyboard inputs more responsive on Linux, especially
when the FPS is lower on slower configurations.

Polling events from the x server is done on a separate thread to avoid a
frame delay with inputs, due to first sending the event to the input
manager with XFilterEvent then processing the new event only on the next
frame.

Calls to Input Manager functions like XSetICFocus, XUnsetICFocus and
XSetICValues use a mutex, because they are polling events internally and
would otherwise interfere with our own thread process for polling events
which can cause a deadlock in some cases.

XUnsetICFocus is called instead of XSetICFocus on FocusOut events,
so the input manager can be properly notified of focus changes.

clipboard_get now uses a blocking call to poll for a specific event type
when waiting for a SelectionNotify event, instead of polling all events
and filtering them afterwards.
2020-09-24 16:01:41 +02:00
Rémi Verschelde 413ff7938d
X11: Try to load libXrandr.so.3 if libXrandr.so.2 isn't found
All Linux distros, and FreeBSD and OpenBSD seem to have libXrandr.so.2,
but for some reason recent NetBSD versions seem to have libXrandr.so.3 now.
2020-09-18 11:55:12 +02:00
bruvzg 6a14c72b12
Add window click-through support. 2020-09-17 12:36:18 +03:00
PouleyKetchoupp eeebe6914e Fix drag and drop between windows in X11 display server
Proper implementation for get_window_at_screen_position:
Now getting the topmost last active window when overlapping.

Mouse drag & release events:
They are now propagated through the current focused window, in order to
make it consistent with the engine expectations and the Windows display
server implementation.
2020-09-03 10:31:03 +02:00
PouleyKetchoupp 5315bff002 Fix menu popups delay and focus in X11 display server
Now using override_redirect for menu & tooltip popups to prevent the WM from
interfering with them, so we have more control over focus management
and avoid a delay before they show up.
2020-08-26 18:14:07 +02:00
PouleyKetchoupp 2b49cb0b73 Re-apply "Fixes for windows in X11 tiling WMs"
From PR #38727 which was reverted in #41373 because of regressions in Ubuntu
with Gnome.

Co-authored-by: Lorenzo Cerqua <lorenzocerqua@tutanota.com>
2020-08-22 18:42:42 +02:00
Juan Linietsky 9c5c1635b2
Revert "Fixes for windows in X11 tiling WMs" 2020-08-19 12:37:59 -03:00
Rémi Verschelde 33b2070d2e Remove obsolete GLES2 backend code
This code currently isn't compiled (and cannot compile).

We plan to re-add OpenGL ES-based renderer(s) in Godot 4.0 alongside Vulkan
(probably ES 3.0, possibly also a low-end ES 2.0), but the code will be quite
different so it's not relevant to keep this old Godot 3.2 code.

The `drivers/gles2` code from the `3.2` branch can be used as a reference for
a potential new implementation.
2020-08-13 10:04:53 +02:00
opl- a31b164071 Fix losing X11 window normal size hint properties
This was caused by `XSetWMNormalHints` being called multiple times, each time with different values. Calling the method replaces the old data completely, resulting in some of the settings being lost.

Since the method was called 3 times before the window was mapped, this resulted in the position hint being lost and the window always getting opened at a position determined by the WM.
2020-07-31 17:32:46 +02:00
Lorenzo Cerqua d670a49612 DisplayServer: separate window showing into another function
When creating a window, Godot would first register it to the WM(show it) and then set its flags.
This works fine on a floating WM, but on tiling WMs as soon as a window gets registered
the WM immediately acts on the window by scaling it up and treating it as a generic window,
being registered without any special flags.

This commit separates the showing of the window into another function and calls it after the most important flags are set,
making windows with special flags(eg. all popups) work again on tiling WMs.

Fixes #37930
2020-07-23 07:58:10 +02:00
Andy Maloney 4dda62f591 Fix spelling & grammar in comments, docs, and messages 2020-07-21 15:17:23 -04:00
bruvzg 996910b627
Add error messages if Vulkan init failed, prevent Vulkan context freeing uninitialized device and instance. 2020-07-13 19:24:21 +03:00
Rémi Verschelde 9828fcc01a
Merge pull request #40105 from Logharaa/master
Stop looping as soon as the first window that has focus is found
2020-07-04 09:57:14 +02:00
Gaël 6c76639c40 Break loop when the first focused window is found 2020-07-04 01:57:16 +02:00
Juan Linietsky 14263d3d0d Improve the situation of DND on X11 2020-07-03 12:09:22 -03:00
Juan Linietsky 0b7bc83fe3 Add a focus out timeout for X11 to less events of this type are received 2020-07-01 16:14:46 -03:00
Juan Linietsky 239942cfef Ensure embedded mode works again
Also implemented application in/out notifications in X11.
2020-07-01 09:27:43 -03:00
Rémi Verschelde 524f061c01 X11: Ensure XGetWindowProperty data gets freed
And cleanup includes a bit.
2020-06-29 13:32:21 +02:00
bruvzg 92352b1c23
Add keyboard layout enumeration / set / get functions (macOS, Windows, Linux/X11), remove latin variant function. 2020-06-13 11:02:00 +03:00
Rémi Verschelde 0ee0fa42e6 Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`.
https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14 21:57:34 +02:00
Rémi Verschelde 07bc4e2f96 Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route:
```
find -name "thirdparty" -prune \
  -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \
  -o -name "*.glsl" > files
perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files)
misc/scripts/fix_style.sh -c
```

This adds a newline after all `}` on the first column, unless they
are followed by `#` (typically `#endif`). This leads to having lots
of places with two lines between function/class definitions, but
clang-format then fixes it as we enforce max one line of separation.

This doesn't fix potential occurrences of function definitions which
are indented (e.g. for a helper class defined in a .cpp), but it's
better than nothing. Also can't be made to run easily on CI/hooks so
we'll have to be careful with new code.

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde 0be6d925dc Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.

This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.

There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).

Part of #33027.
2020-05-14 16:54:55 +02:00
Rémi Verschelde e956e80c1f Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Part of #33027, also discussed in #29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
2020-05-10 13:12:16 +02:00
bruvzg 0128947894
[Linux/Windows] Set pressure to 1.0f when primary button is pressed and device is not pressure sensitive. 2020-05-03 20:13:01 +03:00
Rémi Verschelde 78db7824b7
Merge pull request #37756 from madmiraal/fix-x11-pressure-tilt
Fix X11 pressure and tilt values.
2020-05-03 18:09:33 +02:00
Rémi Verschelde 7e1e0f496b
Merge pull request #37802 from ThakeeNathees/window-position-bug-osx-x11
display server window position bug fix
2020-04-29 09:04:53 +02:00
Rémi Verschelde fdf58a5858 Rename InputFilter back to Input
It changed name as part of the DisplayServer and input refactoring
in #37317, with the rationale that input no longer goes through the
main loop, so the previous Input singleton now only does filtering.

But the gains in consistency are quite limited in the renaming, and
it breaks compatibility for all scripts and tutorials that access
the Input singleton via the scripting language. A temporary option
was suggested to keep the scripting singleton named `Input` even if
its type is `InputFilter`, but that adds inconsistency and breaks C#.

Fixes godotengine/godot-proposals#639.
Fixes #37319.
Fixes #37690.
2020-04-28 15:19:49 +02:00
qarmin 943ec79859 Fixes leaks in ResourceCache, Vulkan and X11 2020-04-15 10:27:57 +02:00
Thakee Nathees 63a00aec68 display server window position bug fix (#37323) 2020-04-11 20:13:12 +05:30
Marcel Admiraal a2ad0878ed Fix X11 pressure and tilt values. 2020-04-10 12:10:24 +01:00
Marcel Admiraal 9369b37f1f Fix loss of precision in X11 device info. 2020-04-10 07:40:14 +01:00
lupoDharkael 95a1400a2a Replace NULL with nullptr 2020-04-02 13:38:00 +02:00
Rafał Mikrut 359bebd8c0 Fix out of bound array access caused by unassigned variable 2020-04-01 19:29:35 +02:00
Juan Linietsky a6f3bc7c69 Renaming of servers for coherency.
VisualServer -> RenderingServer
PhysicsServer -> PhysicsServer3D
Physics2DServer -> PhysicsServer2D
NavigationServer -> NavigationServer3D
Navigation2DServer -> NavigationServer2D

Also renamed corresponding files.
2020-03-27 15:21:27 -03:00
bruvzg 15a9f94346 Add macOS DisplayServer implementation.
Change global menu to use Callable, add support for check items and submenus.
2020-03-26 16:24:05 +01:00
Juan Linietsky 197cb4e771 Fixes to X11, still pretty broken 2020-03-26 15:50:00 +01:00
Mateo Kuruk Miccino f387b9b4f4 Multiple changes to DisplayServerX11
- Travis: Change x11 to linuxbsd
- SCons: Change x11 plataform to linuxbsd
- Plugins: Remove ; to avoid fallthrough warning
- DisplayServerX11: Implement set_icon
- DisplayServerX11: Fix X11 bug when a window was erased from windows
  map, all the changes from that erased windows are sending to the main
  window
- DisplayServerX11: Reorder create_window commands
- DisplayServerX11: Change every Size2 to Size2i and Rect2 to Rect2i
  where it belongs

+ More X11 fixes which have been integrated directly back into reduz's
original commits while rebasing the branch.
2020-03-26 15:49:54 +01:00
Juan Linietsky 9a5d15a2dc Implemented drag and drop across windows, both OS and embedded. 2020-03-26 15:49:46 +01:00