Commit graph

98 commits

Author SHA1 Message Date
Rémi Verschelde
9fb9b99cab
Merge pull request #42117 from nekomatata/x11-get-window-screen
Fix window_get_current_screen for X11 display server
2021-10-28 20:57:24 +02:00
PouleyKetchoupp
b34480b645 Fix window_get_current_screen for X11 display server
This method used to check which screen contains the top-left corner of
the window (and default to the first screen in case none is found),
which is not accurate in some cases.

Now the area of overlap with each screen is calculated, so we can get
the best candidate based on the window's position.

This makes window_get_current_screen consistent with Windows platform,
and fixes an issue where popups appear on the main screen when the main
window is slightly moved outside of the desktop on the top or left.
2021-10-28 10:26:05 -07:00
Rémi Verschelde
3a6be64c12
clang-format: Various fixes to comments alignment from clang-format 13
All reviewed manually and occasionally rewritten to avoid bad auto formatting.
2021-10-28 15:43:36 +02:00
Rémi Verschelde
3b11e33a09
clang-format: Disable alignment of operands, too unreliable
Sets `AlignOperands` to `DontAlign`.

`clang-format` developers seem to mostly care about space-based indentation and
every other version of clang-format breaks the bad mismatch of tabs and spaces
that it seems to use for operand alignment. So it's better without, so that it
respects our two-tabs `ContinuationIndentWidth`.
2021-10-28 15:19:35 +02:00
PouleyKetchoupp
ba96fc6a4d Fix input events random delay on X11
The new system based on a thread gathering events from the X11 server
was causing delays in some scenarios where some events have just been
missed at the time of processing and we're waiting for a whole frame to
check them again.

Solved by flushing again and checking for pending events at the
beginning of the process loop, in addition to events already gathered
on the event thread.
2021-10-27 15:24:09 -07:00
ConteZero
8c48b4a7e0 Fix primary clipboard warning 2021-10-23 15:50:01 +02:00
ConteZero
838c9d37b4 Added primary clipboard for Linux 2021-10-18 14:01:06 +02:00
Rémi Verschelde
a7011fa294
Merge pull request #52684 from Frixuu/master 2021-10-01 11:53:01 +02:00
Lightning_A
c63b18507d Use range iterators for Map 2021-09-30 15:09:12 -06:00
Frixuu
650e63a7ca Allow for mapping keycodes to current layout 2021-09-21 00:03:02 +02:00
Hugo Locurcio
7486fa9b16
Mention that rebooting is required after updating graphics driver on Linux 2021-09-15 18:34:10 +02:00
Pedro J. Estébanez
dc187324be Add input buffering framework
Input buffering is implicitly used by event accumulation, but this commit makes it more generic so it can be enabled for other uses.

For desktop OSs it's currently not feasible given main and UI threads are the same).
2021-08-13 11:19:19 +02:00
Pedro J. Estébanez
7c864d41c9 Improve input event accumulation
- API has been simplified: all events now go through `parse_input_event()`. Whether they are accumulated or not depends on the `use_accumulated_input` flag.
- Event accumulation is now thread-safe (it was not needed so far, but it prepares the ground for the following changes).
- Touch drag events now support accumulation.
2021-08-13 11:19:19 +02:00
Aaron Franke
fa3a32a2d6
Use Key enum instead of plain integers 2021-08-10 16:26:55 -05:00
luz paz
3564c16cb8
Fix various typos with codespell
Found via `codespell -q 3 -S ./thirdparty,*.po,./DONORS.md -L ackward,ang,ans,ba,beng,cas,childs,childrens,dof,doubleclick,fave,findn,hist,inout,leapyear,lod,nd,numer,ois,ony,paket,seeked,sinc,switchs,te,uint`
2021-07-25 11:21:51 +02:00
bruvzg
618eb27e8b Move alert function from DisplayServer to OS. 2021-07-22 21:50:35 +03:00
PouleyKetchoupp
e030360b88 Fix popup closing immediately after showing on some Linux WMs
When a popup is going to be closed, switch focus to the parent only if
the popup is still being focused.

Fixes some cases with specific WMs where due to the order of events, a
new popup could be immediately unfocused because a previously opened
and closed popup is switching focus to the parent.
2021-07-21 12:28:39 -07:00
Hendrik Brucker
043ae91560 Restructure and reimplement vsync options
-Add a v-sync mode setting which allows to choose between DISABLED, ON, ADAPTIVE and MAILBOX
-Removed the V-Sync via Compositor option
2021-07-06 16:34:26 +02:00
Niklas Higi
0c83a23ab5
Add "Keep screen on" feature to DisplayServerX11 2021-06-20 21:57:33 +02:00
Aaron Franke
0ce49800ac
Use mouse and joypad enums instead of plain integers
Also MIDIMessage
2021-06-20 11:54:24 -04:00
Lightning_A
e28fd07b2b Rename instance()->instantiate() when it's a verb 2021-06-19 20:49:18 -06:00
Aaron Franke
98aa3b669e
Add MOUSE_MODE_CONFINED_HIDDEN
Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
2021-06-03 11:44:28 -04:00
Rémi Verschelde
6c367f8e0d
Merge pull request #48168 from LightningAA/control-to-ctrl-4.0 2021-05-17 17:38:02 +02:00
Hugo Locurcio
064ca9adae
Remove debugging prints in the Linux DisplayServer
Some Vulkan debugging prints were also changed to be printed only
in verbose mode.
2021-05-08 19:07:50 +02:00
Lightning_A
97fecd1b69 Rename "Control" key to "Ctrl" and add "_pressed" suffix to all InputEventWithModifiers properties/methods 2021-05-07 14:00:50 -06:00
Aaron Franke
0de9a7d803
Rename doubleclick to double_click 2021-05-04 04:38:08 -04:00
Rémi Verschelde
9bbe51dc27
Style: Apply clang-tidy's modernize-use-nullptr 2021-04-05 14:05:07 +02:00
Marcel Admiraal
fd30c36985 Rename Texture.get_data() to get_image() 2021-03-28 13:00:46 +01:00
Aaron Franke
10d7fccb54
Rename ButtonList enum and members to MouseButton 2021-03-23 07:13:23 -04:00
Rémi Verschelde
ae850177a3 Linux: Fix PRIME detection on Steam
To avoid trying to do PRIME detection on fake `libGL.so` as used by e.g.
Renderdoc or Primus, we skip detection if there's a `libGL.so` in
`LD_LIBRARY_PATH`... and our luck is that Steam defines it and includes
system paths too, thus the actual system `libGL`... 🤦

So if we detect Steam, we skip this check.

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-03-08 15:51:14 +01:00
Pedro Rodrigues
1cb21b6937 Fix out of bounds array access on DisplayServerX11 code
The problem happened on methods `screen_get_position`,
`screen_get_usable_rect` and `window_set_current_screen` when they were
passed a negative screen value.

Fixes:
- #46184
- #46185
- #46186
2021-02-28 16:43:46 +00:00
Pedro J. Estébanez
8e128726f0 Modernize atomics
- Based on C++11's `atomic`
- Reworked `SafeRefCount` (based on the rewrite by @hpvb)
- Replaced free atomic functions by the new `SafeNumeric<T>`
- Replaced wrong cases of `volatile bool` by the new `SafeFlag`
- Platform-specific implementations no longer needed

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-18 17:12:46 +01:00
Rémi Verschelde
5525cd85c6
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
2021-01-31 15:24:56 +01:00
Pedro J. Estébanez
99fe462452 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-01-29 12:02:13 +01:00
Aaron Franke
e829b7aee4
Unify URI encoding/decoding and add to C#
http_escape and percent_encode have been unified into uri_encode, and http_unescape and percent_decode have been unified into uri_decode.
2021-01-28 07:45:01 -05:00
Marcel Admiraal
2a74b388d0 Split OS::execute into two methods
1. execute(): Executes a command and returns the results.
2. create_process(): Creates a new process and returns the new process' id.
2021-01-09 10:03:23 +00:00
Rémi Verschelde
b5334d14f7
Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
Marcel Admiraal
5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
Marcel Admiraal
f9b83e90b2 Fix named anonymous struct warning 2020-12-16 07:42:16 +00:00
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