mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
Fix default display resolution to 720p and change resize strategy
This commit is contained in:
@@ -39,6 +39,7 @@ extern "C" {
|
|||||||
#include "x.h"
|
#include "x.h"
|
||||||
|
|
||||||
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
#define NV12_BUFFER_SIZE 1280 * 720 * 3 / 2
|
||||||
|
#define MOUSE_CONTROL 0
|
||||||
|
|
||||||
int screen_w = 1280, screen_h = 720;
|
int screen_w = 1280, screen_h = 720;
|
||||||
const int pixel_w = 1280, pixel_h = 720;
|
const int pixel_w = 1280, pixel_h = 720;
|
||||||
@@ -237,13 +238,14 @@ void ReceiveDataBuffer(const char *data, size_t size, const char *user_id,
|
|||||||
ip.mi.mouseData = 0;
|
ip.mi.mouseData = 0;
|
||||||
ip.mi.time = 0;
|
ip.mi.time = 0;
|
||||||
|
|
||||||
|
#if MOUSE_CONTROL
|
||||||
// Set cursor pos
|
// Set cursor pos
|
||||||
SetCursorPos(ip.mi.dx, ip.mi.dy);
|
SetCursorPos(ip.mi.dx, ip.mi.dy);
|
||||||
// Send the press
|
// Send the press
|
||||||
if (ip.mi.dwFlags != MOUSEEVENTF_MOVE) {
|
if (ip.mi.dwFlags != MOUSEEVENTF_MOVE) {
|
||||||
SendInput(1, &ip, sizeof(INPUT));
|
SendInput(1, &ip, sizeof(INPUT));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// std::cout << "Receive data from [" << user << "], " << ip.type << " "
|
// std::cout << "Receive data from [" << user << "], " << ip.type << " "
|
||||||
// << ip.mi.dwFlags << " " << ip.mi.dx << " " << ip.mi.dy
|
// << ip.mi.dwFlags << " " << ip.mi.dx << " " << ip.mi.dy
|
||||||
// << std::endl;
|
// << std::endl;
|
||||||
@@ -393,9 +395,23 @@ int main() {
|
|||||||
// Create window with SDL_Renderer graphics context
|
// Create window with SDL_Renderer graphics context
|
||||||
SDL_WindowFlags window_flags =
|
SDL_WindowFlags window_flags =
|
||||||
(SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
(SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example",
|
window = SDL_CreateWindow("Remote Desk", SDL_WINDOWPOS_CENTERED,
|
||||||
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
SDL_WINDOWPOS_CENTERED, screen_w, screen_h,
|
||||||
1280, 720, window_flags);
|
window_flags);
|
||||||
|
|
||||||
|
// int new_screen_w = 0;
|
||||||
|
// int new_screen_h = 0;
|
||||||
|
// SDL_GetWindowSize(window, &new_screen_w, &new_screen_h);
|
||||||
|
|
||||||
|
// if (new_screen_w != screen_w) {
|
||||||
|
// screen_w = new_screen_w;
|
||||||
|
// screen_h = new_screen_w * 9 / 16;
|
||||||
|
// } else if (new_screen_h != screen_h) {
|
||||||
|
// screen_w = new_screen_h * 16 / 9;
|
||||||
|
// screen_h = new_screen_h;
|
||||||
|
// }
|
||||||
|
// SDL_SetWindowSize(window, screen_w, screen_h);
|
||||||
|
|
||||||
sdlRenderer = SDL_CreateRenderer(
|
sdlRenderer = SDL_CreateRenderer(
|
||||||
window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
|
||||||
if (sdlRenderer == nullptr) {
|
if (sdlRenderer == nullptr) {
|
||||||
@@ -409,15 +425,11 @@ int main() {
|
|||||||
sdlTexture = SDL_CreateTexture(sdlRenderer, pixformat,
|
sdlTexture = SDL_CreateTexture(sdlRenderer, pixformat,
|
||||||
SDL_TEXTUREACCESS_STREAMING, pixel_w, pixel_h);
|
SDL_TEXTUREACCESS_STREAMING, pixel_w, pixel_h);
|
||||||
|
|
||||||
// SDL_RendererInfo info;
|
|
||||||
// SDL_GetRendererInfo(sdlRenderer, &info);
|
|
||||||
// SDL_Log("Current SDL_Renderer: %s", info.name);
|
|
||||||
|
|
||||||
// Setup Dear ImGui context
|
// Setup Dear ImGui context
|
||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO &io = ImGui::GetIO();
|
ImGuiIO &io = ImGui::GetIO();
|
||||||
(void)io;
|
|
||||||
io.ConfigFlags |=
|
io.ConfigFlags |=
|
||||||
ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||||
io.ConfigFlags |=
|
io.ConfigFlags |=
|
||||||
@@ -450,7 +462,7 @@ int main() {
|
|||||||
|
|
||||||
const ImGuiViewport *main_viewport = ImGui::GetMainViewport();
|
const ImGuiViewport *main_viewport = ImGui::GetMainViewport();
|
||||||
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_Once);
|
||||||
ImGui::SetNextWindowSize(ImVec2(180, 200));
|
ImGui::SetNextWindowSize(ImVec2(180, 225));
|
||||||
|
|
||||||
ImGui::Begin("Menu", nullptr, ImGuiWindowFlags_NoResize);
|
ImGui::Begin("Menu", nullptr, ImGuiWindowFlags_NoResize);
|
||||||
|
|
||||||
@@ -496,9 +508,6 @@ int main() {
|
|||||||
rect.right = GetSystemMetrics(SM_CXSCREEN);
|
rect.right = GetSystemMetrics(SM_CXSCREEN);
|
||||||
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
rect.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
|
||||||
screen_w = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
screen_h = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
|
|
||||||
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
last_frame_time_ = std::chrono::high_resolution_clock::now();
|
||||||
screen_capture->Init(
|
screen_capture->Init(
|
||||||
rect, 60,
|
rect, 60,
|
||||||
@@ -574,6 +583,24 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
{
|
||||||
|
if (ImGui::Button("Fix ratio")) {
|
||||||
|
SDL_GetWindowSize(window, &screen_w, &screen_h);
|
||||||
|
|
||||||
|
if (screen_h != screen_w * 9 / 16) {
|
||||||
|
screen_w = screen_h * 16 / 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetWindowSize(window, screen_w, screen_h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,19 +616,9 @@ int main() {
|
|||||||
done = true;
|
done = true;
|
||||||
} else if (event.type == SDL_WINDOWEVENT &&
|
} else if (event.type == SDL_WINDOWEVENT &&
|
||||||
event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||||
// int new_screen_w = 0;
|
SDL_GetWindowSize(window, &screen_w, &screen_h);
|
||||||
// int new_screen_h = 0;
|
SDL_SetWindowSize(window, screen_w, screen_h);
|
||||||
// SDL_GetWindowSize(window, &new_screen_w, &new_screen_h);
|
// printf("Resize windows: %dx%d\n", screen_w, screen_h);
|
||||||
|
|
||||||
// if (new_screen_w != screen_w) {
|
|
||||||
// screen_w = new_screen_w;
|
|
||||||
// screen_h = new_screen_w * 9 / 16;
|
|
||||||
// } else if (new_screen_h != screen_h) {
|
|
||||||
// screen_w = new_screen_h * 16 / 9;
|
|
||||||
// screen_h = new_screen_h;
|
|
||||||
// }
|
|
||||||
// SDL_SetWindowSize(window, screen_w, screen_h);
|
|
||||||
printf("Resize windows: %dx%d\n", screen_w, screen_h);
|
|
||||||
} else if (event.type == SDL_WINDOWEVENT &&
|
} else if (event.type == SDL_WINDOWEVENT &&
|
||||||
event.window.event == SDL_WINDOWEVENT_CLOSE &&
|
event.window.event == SDL_WINDOWEVENT_CLOSE &&
|
||||||
event.window.windowID == SDL_GetWindowID(window)) {
|
event.window.windowID == SDL_GetWindowID(window)) {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ target("screen_capture")
|
|||||||
add_includedirs("screen_capture/linux", {public = true})
|
add_includedirs("screen_capture/linux", {public = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
target("remote_desk_gui")
|
target("remote_desk")
|
||||||
set_kind("binary")
|
set_kind("binary")
|
||||||
add_deps("projectx", "screen_capture")
|
add_deps("projectx", "screen_capture")
|
||||||
add_packages("log", "imgui", "sdl2")
|
add_packages("log", "imgui", "sdl2")
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ int NvidiaVideoDecoder::Decode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((*(data + 4) & 0x1f) == 0x07) {
|
if ((*(data + 4) & 0x1f) == 0x07) {
|
||||||
LOG_WARN("Receive key frame");
|
// LOG_WARN("Receive key frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_frame_returned = decoder->Decode(data, size);
|
int num_frame_returned = decoder->Decode(data, size);
|
||||||
|
|||||||
Reference in New Issue
Block a user