feat: --cm hide task bar
This commit is contained in:
parent
2301d09303
commit
6f2ef398bf
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
typedef char** (*FUNC_RUSTDESK_CORE_MAIN)(int*);
|
typedef char** (*FUNC_RUSTDESK_CORE_MAIN)(int*);
|
||||||
typedef void (*FUNC_RUSTDESK_FREE_ARGS)( char**, int);
|
typedef void (*FUNC_RUSTDESK_FREE_ARGS)( char**, int);
|
||||||
|
const char* uniLinksPrefix = "rustdesk://";
|
||||||
|
|
||||||
// auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
// auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||||
@ -36,6 +37,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
std::cout << "Failed to get free_c_args" << std::endl;
|
std::cout << "Failed to get free_c_args" << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
std::vector<std::string> command_line_arguments =
|
||||||
|
GetCommandLineArguments();
|
||||||
|
|
||||||
int args_len = 0;
|
int args_len = 0;
|
||||||
char** c_args = rustdesk_core_main(&args_len);
|
char** c_args = rustdesk_core_main(&args_len);
|
||||||
@ -49,7 +52,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
|
|
||||||
// uni links dispatch
|
// uni links dispatch
|
||||||
// only do uni links when dispatch a rustdesk links
|
// only do uni links when dispatch a rustdesk links
|
||||||
if (!rust_args.empty() && rust_args.front().compare("rustdesk://") == 0) {
|
auto prefix = std::string(uniLinksPrefix);
|
||||||
|
if (!command_line_arguments.empty() && command_line_arguments.front().compare(0, prefix.size(), prefix.c_str()) == 0) {
|
||||||
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"rustdesk");
|
HWND hwnd = ::FindWindow(L"FLUTTER_RUNNER_WIN32_WINDOW", L"rustdesk");
|
||||||
if (hwnd != NULL) {
|
if (hwnd != NULL) {
|
||||||
DispatchToUniLinksDesktop(hwnd);
|
DispatchToUniLinksDesktop(hwnd);
|
||||||
@ -71,17 +75,19 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
|||||||
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
flutter::DartProject project(L"data");
|
flutter::DartProject project(L"data");
|
||||||
|
// connection manager hide icon from taskbar
|
||||||
std::vector<std::string> command_line_arguments =
|
bool showOnTaskBar = true;
|
||||||
GetCommandLineArguments();
|
auto cmParam = std::string("--cm");
|
||||||
|
if (!command_line_arguments.empty() && command_line_arguments.front().compare(0, cmParam.size(), cmParam.c_str()) == 0) {
|
||||||
|
showOnTaskBar = false;
|
||||||
|
}
|
||||||
command_line_arguments.insert(command_line_arguments.end(), rust_args.begin(), rust_args.end());
|
command_line_arguments.insert(command_line_arguments.end(), rust_args.begin(), rust_args.end());
|
||||||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
||||||
|
|
||||||
FlutterWindow window(project);
|
FlutterWindow window(project);
|
||||||
Win32Window::Point origin(10, 10);
|
Win32Window::Point origin(10, 10);
|
||||||
Win32Window::Size size(800, 600);
|
Win32Window::Size size(800, 600);
|
||||||
if (!window.CreateAndShow(L"RustDesk", origin, size))
|
if (!window.CreateAndShow(L"RustDesk", origin, size, showOnTaskBar))
|
||||||
{
|
{
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "win32_window.h"
|
#include "win32_window.h"
|
||||||
|
|
||||||
#include <flutter_windows.h>
|
#include <flutter_windows.h>
|
||||||
|
#include <shobjidl_core.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ Win32Window::~Win32Window() {
|
|||||||
|
|
||||||
bool Win32Window::CreateAndShow(const std::wstring& title,
|
bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||||
const Point& origin,
|
const Point& origin,
|
||||||
const Size& size) {
|
const Size& size, bool showOnTaskBar) {
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
const wchar_t* window_class =
|
const wchar_t* window_class =
|
||||||
@ -115,7 +116,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
|||||||
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
||||||
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
||||||
double scale_factor = dpi / 96.0;
|
double scale_factor = dpi / 96.0;
|
||||||
|
|
||||||
HWND window = CreateWindow(
|
HWND window = CreateWindow(
|
||||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
|
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
|
||||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||||
@ -126,6 +127,19 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!showOnTaskBar) {
|
||||||
|
// hide from taskbar
|
||||||
|
HRESULT hr;
|
||||||
|
ITaskbarList* pTaskbarList;
|
||||||
|
hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER,IID_ITaskbarList,(void**)&pTaskbarList);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
hr = pTaskbarList->HrInit();
|
||||||
|
hr = pTaskbarList->DeleteTab(window);
|
||||||
|
hr = pTaskbarList->Release();
|
||||||
|
}
|
||||||
|
|
||||||
return OnCreate();
|
return OnCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@ class Win32Window {
|
|||||||
// true if the window was created successfully.
|
// true if the window was created successfully.
|
||||||
bool CreateAndShow(const std::wstring& title,
|
bool CreateAndShow(const std::wstring& title,
|
||||||
const Point& origin,
|
const Point& origin,
|
||||||
const Size& size);
|
const Size& size,
|
||||||
|
bool showOnTaskBar = true);
|
||||||
|
|
||||||
// Release OS resources associated with window.
|
// Release OS resources associated with window.
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user