Compare commits

..

17 Commits

Author SHA1 Message Date
Romain Vimont
173ac56880 Make message buffer static
Now that the message max size is 256k, do not put the buffer on the
stack.
2020-06-04 23:50:08 +02:00
Romain Vimont
913a9f3694 Increase clipboard size from 4k to 256k
Beyond 256k, SDL_GetClipboardText() returns an empty string on my
computer.

Fixes #1117 <https://github.com/Genymobile/scrcpy/issues/1117>
2020-06-04 23:37:28 +02:00
Romain Vimont
d9fd3117ff Fix receiver on partial device messages
If a single device message was read in several chunks from the control
socket, the communication was broken.
2020-06-04 23:33:21 +02:00
Romain Vimont
18ea1a442b Serialize text size on 4 bytes
This will allow to send text having a size greater than 65535 bytes.
2020-06-04 23:33:21 +02:00
Romain Vimont
13f95865dc Rename MSG_SERIALIZED_MAX_SIZE to MSG_MAX_SIZE
For simplicity and consistency with the server part.
2020-06-04 21:45:02 +02:00
Romain Vimont
808a9cad90 Add unit test for big clipboard device message
Test clipboard synchronization from the device to the computer.
2020-06-04 21:45:02 +02:00
Romain Vimont
80e799a6f4 Rename test names from "event" to "msg"
The meson test names had not been changed when "event" had been renamed
to "message".

Ref: 28980bbc90
2020-06-04 21:45:02 +02:00
Romain Vimont
914b4dbebc Reorganize message size constants
Make the max clipboard text length depend on the max message size.
2020-06-04 21:36:40 +02:00
Romain Vimont
64749c4a44 Avoid additional copy on Java text parsing
Directly pass the buffer range to the String constructor.
2020-06-04 21:04:49 +02:00
Romain Vimont
a162725f0e Update copy-paste section in README
Update documentation regarding the recent copy-paste changes.
2020-06-04 21:04:49 +02:00
Romain Vimont
cc6a43f033 Forward copy-cut shortcuts
For convenience, forward RCtrl+c (or Cmd+c) and and RCtrl+x (or Cmd+x)
as LCtrl+c and LCtrl+x to the device.

This allows to use the "natural" keys for copy-paste (especially on
macOS).
2020-06-04 21:04:49 +02:00
Romain Vimont
2fcb1ce58c Change "resize to fit" shortcut to RCtrl+w
For convenience, RCtrl+x (and Cmd+x) will be used for "cut text to
clipboard", in addition to LCtrl+x.
2020-06-04 21:04:49 +02:00
Romain Vimont
ded6215362 Accept Cmd for shortcuts on macOS
For convenience (and to keep the existing behavior), also accept
shortcuts using Cmd instead of RCtrl.
2020-06-04 21:04:49 +02:00
Romain Vimont
a253164237 Reformulate RCtrl+v description
RCtrl+v is the only scrcpy shortcut related to copy-paste. Since it's
not a real "paste", reformulate to indicate that it injects the
clipboard content as text events.
2020-06-04 21:04:49 +02:00
Romain Vimont
2df8c33f62 Remove "paste on set clipboard" feature
Now that content is pasted on Ctrl+v, the hack to send the PASTE keycode
(for Android >= 7 only) is obsolete. Remove it.

This reverts fc1dec0270.
2020-06-04 21:04:49 +02:00
Romain Vimont
793db5a77e Remove RCtrl+c copy shortcut
Now that Ctrl+c is forwarded to the device, and that every device
clipboard change is automatically synchronized to the computer, RCtrl+c
is useless.
2020-06-04 21:03:36 +02:00
Romain Vimont
8700ad74b9 Remove RCtrl+Shift+v paste shortcut
Now that LCtrl+v synchronize the computer clipboard to the device
clipboard, RCtrl+Shift+v is not needed anymore.

Note: RCtrl+v is kept to send the computer clipboard content as a
sequence of keys.
2020-06-04 21:02:35 +02:00
4 changed files with 5 additions and 22 deletions

View File

@@ -496,12 +496,8 @@ computer clipboard.
`Ctrl`+`c` (copy), `Ctrl`+`x` (cut) and `LCtrl`+`v` (paste) work as you expect.
In addition, `RCtrl`+`v` allows to inject the computer clipboard content as a
sequence of text events . This is useful when the component does not accept text
pasting (for example in _Termux_), but it can break non-ASCII content.
Another shortcut, `RCtrl`+`Shift`+`v`, only copies the computer clipboard to the
device clipboard. This is useful when `Ctrl`+`v` does not paste on the device
(for example, again, in _Termux_).
sequence of text event. Even if it can break non-ASCII content, this is
sometimes necessary when pasting directly is not possible.
#### Text injection preference
@@ -589,7 +585,6 @@ system).
| Expand notification panel | `RCtrl`+`n`
| Collapse notification panel | `RCtrl`+`Shift`+`n`
| Inject computer clipboard text | `RCtrl`+`v`
| Copy computer clipboard to device | `RCtrl`+`Shift`+`v`
| Enable/disable FPS counter (on stdout) | `RCtrl`+`i`
_¹Double-click on black borders to remove them._

View File

@@ -281,10 +281,6 @@ Collapse notification panel
.B RCtrl+v
Inject computer clipboard text
.TP
.B RCtrl+Shift+v
Copy computer clipboard to device
.TP
.B RCtrl+i
Enable/disable FPS counter (print frames/second in logs)

View File

@@ -245,9 +245,6 @@ scrcpy_print_usage(const char *arg0) {
" RCtrl+v\n"
" Inject computer clipboard text\n"
"\n"
" RCtrl+Shift+v\n"
" Copy computer clipboard to device\n"
"\n"
" RCtrl+i\n"
" Enable/disable FPS counter (print frames/second in logs)\n"
"\n"

View File

@@ -359,14 +359,9 @@ input_manager_process_key(struct input_manager *im,
}
return;
case SDLK_v:
if (control && !repeat && down) {
if (shift) {
// store the text in the device clipboard
set_device_clipboard(controller);
} else {
// inject the text as input events
clipboard_paste(controller);
}
if (control && !shift && !repeat && down) {
// Inject the text as input events
clipboard_paste(controller);
}
return;
case SDLK_f: