mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-19 05:36:32 +08:00
Compare commits
3 Commits
757ca330b8
...
f94ef49210
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f94ef49210 | ||
|
|
5d0a4d1385 | ||
|
|
dd482cee60 |
@@ -51,7 +51,16 @@ int KeyboardCapturer::Hook(OnKeyAction on_key_action, void* user_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int KeyboardCapturer::Unhook() {
|
int KeyboardCapturer::Unhook() {
|
||||||
|
g_on_key_action = nullptr;
|
||||||
|
g_user_ptr = nullptr;
|
||||||
|
|
||||||
running_ = false;
|
running_ = false;
|
||||||
|
|
||||||
|
if (display_) {
|
||||||
|
XSelectInput(display_, DefaultRootWindow(display_), 0);
|
||||||
|
XFlush(display_);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ static void* g_user_ptr = nullptr;
|
|||||||
|
|
||||||
CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type,
|
CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type,
|
||||||
CGEventRef event, void* userInfo) {
|
CGEventRef event, void* userInfo) {
|
||||||
|
if (!g_on_key_action) {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
KeyboardCapturer* keyboard_capturer = (KeyboardCapturer*)userInfo;
|
KeyboardCapturer* keyboard_capturer = (KeyboardCapturer*)userInfo;
|
||||||
if (!keyboard_capturer) {
|
if (!keyboard_capturer) {
|
||||||
LOG_ERROR("keyboard_capturer is nullptr");
|
LOG_ERROR("keyboard_capturer is nullptr");
|
||||||
@@ -120,12 +124,23 @@ int KeyboardCapturer::Hook(OnKeyAction on_key_action, void* user_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int KeyboardCapturer::Unhook() {
|
int KeyboardCapturer::Unhook() {
|
||||||
|
g_on_key_action = nullptr;
|
||||||
|
g_user_ptr = nullptr;
|
||||||
|
|
||||||
|
if (event_tap_) {
|
||||||
|
CGEventTapEnable(event_tap_, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (run_loop_source_) {
|
if (run_loop_source_) {
|
||||||
|
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_source_,
|
||||||
|
kCFRunLoopCommonModes);
|
||||||
CFRelease(run_loop_source_);
|
CFRelease(run_loop_source_);
|
||||||
|
run_loop_source_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event_tap_) {
|
if (event_tap_) {
|
||||||
CFRelease(event_tap_);
|
CFRelease(event_tap_);
|
||||||
|
event_tap_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -39,7 +39,12 @@ int KeyboardCapturer::Hook(OnKeyAction on_key_action, void* user_ptr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int KeyboardCapturer::Unhook() {
|
int KeyboardCapturer::Unhook() {
|
||||||
UnhookWindowsHookEx(keyboard_hook_);
|
if (keyboard_hook_) {
|
||||||
|
g_on_key_action = nullptr;
|
||||||
|
g_user_ptr = nullptr;
|
||||||
|
UnhookWindowsHookEx(keyboard_hook_);
|
||||||
|
keyboard_hook_ = nullptr;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1340,6 +1340,7 @@ void Render::ProcessSdlEvent(const SDL_Event& event) {
|
|||||||
is_client_mode_ = false;
|
is_client_mode_ = false;
|
||||||
reload_recent_connections_ = true;
|
reload_recent_connections_ = true;
|
||||||
fullscreen_button_pressed_ = false;
|
fullscreen_button_pressed_ = false;
|
||||||
|
start_keyboard_capturer_ = false;
|
||||||
just_created_ = false;
|
just_created_ = false;
|
||||||
recent_connection_image_save_time_ = SDL_GetTicks();
|
recent_connection_image_save_time_ = SDL_GetTicks();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include "device_controller.h"
|
#include "device_controller.h"
|
||||||
#include "localization.h"
|
#include "localization.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
@@ -101,28 +103,39 @@ int Render::ProcessMouseEvent(const SDL_Event& event) {
|
|||||||
last_mouse_event.button.y >= props->stream_render_rect_.y &&
|
last_mouse_event.button.y >= props->stream_render_rect_.y &&
|
||||||
last_mouse_event.button.y <= props->stream_render_rect_.y +
|
last_mouse_event.button.y <= props->stream_render_rect_.y +
|
||||||
props->stream_render_rect_.h) {
|
props->stream_render_rect_.h) {
|
||||||
int scroll_x = event.wheel.x;
|
float scroll_x = event.wheel.x;
|
||||||
int scroll_y = event.wheel.y;
|
float scroll_y = event.wheel.y;
|
||||||
if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
|
if (event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED) {
|
||||||
scroll_x = -scroll_x;
|
scroll_x = -scroll_x;
|
||||||
scroll_y = -scroll_y;
|
scroll_y = -scroll_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
remote_action.type = ControlType::mouse;
|
remote_action.type = ControlType::mouse;
|
||||||
if (scroll_x == 0) {
|
|
||||||
|
auto roundUp = [](float value) -> int {
|
||||||
|
if (value > 0) {
|
||||||
|
return static_cast<int>(std::ceil(value));
|
||||||
|
} else if (value < 0) {
|
||||||
|
return static_cast<int>(std::floor(value));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (std::abs(scroll_y) >= std::abs(scroll_x)) {
|
||||||
remote_action.m.flag = MouseFlag::wheel_vertical;
|
remote_action.m.flag = MouseFlag::wheel_vertical;
|
||||||
remote_action.m.s = scroll_y;
|
remote_action.m.s = roundUp(scroll_y);
|
||||||
} else if (scroll_y == 0) {
|
} else {
|
||||||
remote_action.m.flag = MouseFlag::wheel_horizontal;
|
remote_action.m.flag = MouseFlag::wheel_horizontal;
|
||||||
remote_action.m.s = scroll_x;
|
remote_action.m.s = roundUp(scroll_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_width = props->stream_render_rect_.w;
|
render_width = props->stream_render_rect_.w;
|
||||||
render_height = props->stream_render_rect_.h;
|
render_height = props->stream_render_rect_.h;
|
||||||
remote_action.m.x =
|
remote_action.m.x =
|
||||||
(float)(event.button.x - props->stream_render_rect_.x) / render_width;
|
(float)(last_mouse_event.button.x - props->stream_render_rect_.x) /
|
||||||
|
render_width;
|
||||||
remote_action.m.y =
|
remote_action.m.y =
|
||||||
(float)(event.button.y - props->stream_render_rect_.y) /
|
(float)(last_mouse_event.button.y - props->stream_render_rect_.y) /
|
||||||
render_height;
|
render_height;
|
||||||
|
|
||||||
std::string msg = remote_action.to_json();
|
std::string msg = remote_action.to_json();
|
||||||
@@ -225,8 +238,6 @@ void Render::OnReceiveVideoBufferCb(const XVideoFrame* video_frame,
|
|||||||
props->video_height_ = video_frame->height;
|
props->video_height_ = video_frame->height;
|
||||||
props->video_size_ = video_frame->size;
|
props->video_size_ = video_frame->size;
|
||||||
|
|
||||||
LOG_ERROR("receive: {}x{}", props->video_width_, props->video_height_);
|
|
||||||
|
|
||||||
if (need_to_update_render_rect) {
|
if (need_to_update_render_rect) {
|
||||||
render->UpdateRenderRect();
|
render->UpdateRenderRect();
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule submodules/minirtc updated: 0461314f9b...bb892a1f9d
Reference in New Issue
Block a user