[feat] enable window grab when mouse control enabled

This commit is contained in:
dijunkun
2024-11-04 17:29:26 +08:00
parent 44f9e6a8c9
commit 863070a8a7
4 changed files with 69 additions and 48 deletions

View File

@@ -881,7 +881,7 @@ int Render::Run() {
SDL_UpdateTexture(stream_texture_, NULL, dst_buffer_, texture_width_);
} else {
if (connection_established_) {
ProcessMouseKeyEven(event);
ProcessMouseKeyEvent(event);
}
}
}
@@ -889,6 +889,15 @@ int Render::Run() {
if (connection_established_ && streaming_) {
CreateStreamWindow();
SetupStreamWindow();
if (!stream_window_grabbed_ && control_mouse_) {
SDL_SetWindowGrab(stream_window_, SDL_TRUE);
stream_window_grabbed_ = true;
LOG_INFO("Grabbing input events");
} else if (stream_window_grabbed_ && !control_mouse_) {
SDL_SetWindowGrab(stream_window_, SDL_FALSE);
stream_window_grabbed_ = false;
}
}
DrawMainWindow();