Romain Vimont
9712cb8123
Do not minimize on focus loss
...
The default behavior seems annoying.
Fixes <https://github.com/Genymobile/scrcpy/issues/554 >
2019-05-31 16:18:00 +02:00
Romain Vimont
ad55a9addc
Prefix server logs
...
Sometimes, it is not obvious whether a log is generated by the server or
by the client. Prefix server logs for clarity.
2019-05-31 16:18:00 +02:00
Romain Vimont
28980bbc90
Rename "event" to "message"
...
After the recent refactorings, a "control event" is not necessarily an
"event" (it may be a "command"). Similarly, the unique "device event"
used to send the device clipboard content is more a "reponse" to the
request from the client than an "event".
Rename both to "message", and rename the message types to better
describe their intent.
2019-05-31 16:18:00 +02:00
Romain Vimont
f710d76c9e
Merge pull request #568 from npes87184/dev
...
Correct return value type in handle_event
2019-05-31 15:27:35 +02:00
Yu-Chen Lin
2a8a3e6ed5
Correct return value type in handle_event
...
handle_event return the type enum event_result not bool
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-05-31 20:57:06 +08:00
Yu-Chen Lin
c2cef8d501
server/meson.build: Prevent using input field for directory
...
This will fix build warning in newer meson.
Fix #540 .
Signed-off-by: Yu-Chen Lin <npes87184@gmail.com>
2019-05-30 23:06:52 +02:00
Romain Vimont
0125af1e46
Update DEVELOP after recent refactorings
2019-05-30 22:46:52 +02:00
Romain Vimont
c13a24389c
Implement computer-to-device clipboard copy
...
It was already possible to _paste_ (with Ctrl+v) the content of the
computer clipboard on the device. Technically, it injects a sequence of
events to generate the text.
Add a new feature (Ctrl+Shift+v) to copy to the device clipboard
instead, without injecting the content. Contrary to events injection,
this preserves the UTF-8 content exactly, so the text is not broken by
special characters.
<https://github.com/Genymobile/scrcpy/issues/413 >
2019-05-30 22:46:52 +02:00
Romain Vimont
2322069656
Extract control event String parsing
...
Parsing a String from a serialized control event, encoded as length (2
bytes) + data, will be necessary in several events.
Extract it to a separate method.
2019-05-30 22:46:52 +02:00
Romain Vimont
61f5f96b42
Fix control event String parsing
...
At least 2 bytes must be available to read the length of the String.
2019-05-30 22:46:52 +02:00
Romain Vimont
63c078ee6c
Implement device-to-computer clipboard copy
...
On Ctrl+C:
- the client sends a GET_CLIPBOARD command to the device;
- the device retrieve its current clipboard text and sends it in a
GET_CLIPBOARD device event;
- the client sets this text as the system clipboard text, so that it
can be pasted in another application.
Fixes <https://github.com/Genymobile/scrcpy/issues/145 >
2019-05-30 22:46:52 +02:00
Romain Vimont
3149e2cf4a
Add device event sender
...
Create a separate component to send device events, managed by the
controller.
2019-05-30 22:46:52 +02:00
Romain Vimont
6112095e75
Add device event receiver
...
Create a separate component to handle device events, managed by the
controller.
2019-05-30 22:46:52 +02:00
Romain Vimont
f9d2d99166
Add GET_CLIPBOARD device event
...
Add the first device event, used to forward the device clipboard to the
computer.
2019-05-30 22:36:22 +02:00
Romain Vimont
ec71a3f66a
Use two sockets for video and control
...
The socket used the device-to-computer direction to stream the video and
the computer-to-device direction to send control events.
Some features, like copy-paste from device to computer, require to send
non-video data from the device to the computer.
To make them possible, use two sockets:
- one for streaming the video from the device to the client;
- one for control/events in both directions.
2019-05-30 22:35:41 +02:00
Romain Vimont
69360c7407
Extract control event string serialization
...
A string is serialized as a length (2 bytes) followed by the string data
(non nul-terminated).
For now, it is used only once, but we will need to serialize strings in
other events.
2019-05-30 22:35:04 +02:00
Romain Vimont
6ec2ddd2d1
Truncate UTF-8 properly
...
This will avoid to produce invalid UTF-8 results (although unlikely).
2019-05-30 22:34:59 +02:00
Romain Vimont
0a7fe7ad57
Add helpers to truncate UTF-8 at code points
...
This will help to avoid truncating a UTF-8 string in the middle of a
code point, producing an invalid UTF-8 result.
2019-05-30 22:30:18 +02:00
Romain Vimont
3aa5426cad
Add unit tests for control events serialization
...
Add missing tests for serialization and deserialization of control
events.
2019-05-30 22:30:18 +02:00
Romain Vimont
63207d9cd5
Fix wrong comment in unit test
2019-05-30 22:30:18 +02:00
Romain Vimont
ad4c061cd2
Use custom class Point
...
The framework class android.graphics.Point cannot be used in unit tests.
Implement our own Point.
2019-05-30 22:30:18 +02:00
Romain Vimont
63909fd10d
Merge commands with other control events
...
Several commands were grouped under the same event type "command", with
a separate field to indicate the actual command.
Move these commands at the same level as other control events. It will
allow to implement commands with arguments.
2019-05-30 22:30:18 +02:00
Romain Vimont
3b4366e5bf
Stop stream immediately on quit
...
If the stream is stopped, av_read_frame() will be woken up and yield a
corrupted packet. Do not try to decode or record it.
2019-05-30 22:30:18 +02:00
Romain Vimont
47f1003200
Close server socket before killing process
...
The sockets may be closed and shutdown on server_stop(). This will
interrupt the stream and controller threads more quickly and gracefully.
2019-05-30 22:30:18 +02:00
Romain Vimont
bfb86ca2c2
Simplify cleanup
...
The cleanup is not linear: for example, the server must be stopped and
its sockets must be shutdown after the stream and controller are stopped
(so that they don't continue processing garbage), but before they are
joined, to avoid a deadlock if they are blocked on a socket read.
Simplify the spaghetti-cleanup by keeping trace of initialization at
runtime.
2019-05-30 22:30:18 +02:00
Romain Vimont
0dee9b04b2
Use net_recv() to read only one byte
...
Partial read is impossible for 1 byte, so net_recv_all() is useless.
2019-05-30 22:30:18 +02:00
Romain Vimont
8fc58bde75
Simplify server_connect_to()
...
Only use 2 branches, using either forward or remote tunnel.
2019-05-30 22:30:18 +02:00
Romain Vimont
5a431cdf9b
Make server_connect_to() return a bool
...
The resulting socket is accessible from the server instance, there is no
need to return it.
This paves the way to use several sockets in parallel.
2019-05-30 22:30:18 +02:00
Romain Vimont
6edb1294f0
Add missing return 0 in unit test
2019-05-30 22:30:18 +02:00
Romain Vimont
073181b294
Use cbuf for file handler request queue
...
Replace the file_handler_request_queue implementation by cbuf.
2019-05-30 22:30:18 +02:00
Romain Vimont
241a3dcba5
Use cbuf for control event queue
...
Replace the control_event_queue implementation by cbuf.
2019-05-30 22:30:18 +02:00
Romain Vimont
b38292cd69
Add generic circular buffer
...
Add a circular buffer implementation, to factorize multiple specific
queues implementation.
2019-05-30 22:30:18 +02:00
Romain Vimont
7475550ae8
Add buffer_read16be()
...
Add a function to read 16 bits in big-endian to a uint16_t.
2019-05-30 22:30:18 +02:00
Romain Vimont
7fc8793d5b
Make buffer util functions accept const buffers
...
So that they can be used both on const and non-const input buffers.
2019-05-30 22:30:18 +02:00
Romain Vimont
bf5e54b2e9
Make control_event_serialize() return size_t
...
control_event_serialize() returns the number of bytes written, so the
type should be size_t.
2019-05-30 22:30:18 +02:00
Romain Vimont
507b0bcccf
Fix memory leak on error
...
The variable condition was not destroyed on strdup() failure.
2019-05-30 22:30:18 +02:00
Romain Vimont
e1afd9f8b0
Fix event ownership comment
2019-05-30 22:30:18 +02:00
Romain Vimont
b08dada6c1
Prefix control event constants by namespace
...
This will avoid conflicts with future device events.
2019-05-30 22:30:18 +02:00
Romain Vimont
999c964689
Make macro expansion-safe
...
Use parentheses to avoid unexpected results.
For example, make:
2 * SERIALIZED_EVENT_MAX_SIZE
expand to:
2 * (3 + TEXT_MAX_LENGTH)
instead of:
2 * 3 + TEXT_MAX_LENGTH
2019-05-30 22:30:18 +02:00
Romain Vimont
befe455e44
Remove unused includes
...
The struct control_event does not use mutexes, and net.h does not need
SDL_platform.h.
2019-05-30 22:30:18 +02:00
Romain Vimont
d2504f974c
Fix indentation
...
Previous refactorings broke indentation.
2019-05-30 22:30:18 +02:00
Romain Vimont
0fbab42f8c
Format meson.build for readability
2019-05-30 22:30:18 +02:00
Romain Vimont
08f506b24f
Replace SDL_bool by bool in tests
...
Commit dfed1b250e
replaced SDL types by
standard types in sources, but tests were not updated.
2019-05-30 22:30:18 +02:00
Romain Vimont
3bc1c51b91
Always use SDL_malloc() and SDL_free()
...
To avoid mixing SDL_malloc()/SDL_strdup() with free(), or malloc() with
SDL_free(), always use the SDL version.
2019-05-30 22:30:08 +02:00
Romain Vimont
7ed976967f
Fix checkstyle warning
...
Checkstyle wants a specific order of imports.
2019-05-30 00:22:05 +02:00
Romain Vimont
b75f0e9427
Merge branch 'master' into dev
2019-05-28 13:31:37 +02:00
Romain Vimont
5d473efeb5
Bind Home key to MOVE_HOME
...
On pressing Home key on the computer, move the cursor to the beginning
of the line instead of going back to the home screen.
<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME >
<https://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_MOVE_HOME >
Fixes (part of) <https://github.com/Genymobile/scrcpy/issues/555 >.
2019-05-27 10:24:47 +02:00
Romain Vimont
a41dd6c79f
Make owned filename a pointer-to-non-const
...
The file handler owns the filename string, so it needs to free it.
Therefore, it should not be a pointer-to-const.
2019-05-24 17:25:31 +02:00
Romain Vimont
c3779d8513
Make owned serial a pointer-to-non-const
...
The file handler owns the serial, so it needs to free it. Therefore, it
should not be a pointer-to-const.
2019-05-24 17:24:17 +02:00
Romain Vimont
b3bd5f1b80
Remove useless casts to (void *)
2019-05-24 17:23:21 +02:00