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 void (*FUNC_RUSTDESK_FREE_ARGS)( char**, int);
|
||||
const char* uniLinksPrefix = "rustdesk://";
|
||||
|
||||
// auto bdw = bitsdojo_window_configure(BDW_CUSTOM_FRAME | BDW_HIDE_ON_STARTUP);
|
||||
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;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
std::vector<std::string> command_line_arguments =
|
||||
GetCommandLineArguments();
|
||||
|
||||
int args_len = 0;
|
||||
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
|
||||
// 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");
|
||||
if (hwnd != NULL) {
|
||||
DispatchToUniLinksDesktop(hwnd);
|
||||
@ -71,17 +75,19 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||
|
||||
flutter::DartProject project(L"data");
|
||||
|
||||
std::vector<std::string> command_line_arguments =
|
||||
GetCommandLineArguments();
|
||||
|
||||
// connection manager hide icon from taskbar
|
||||
bool showOnTaskBar = true;
|
||||
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());
|
||||
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
|
||||
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(800, 600);
|
||||
if (!window.CreateAndShow(L"RustDesk", origin, size))
|
||||
if (!window.CreateAndShow(L"RustDesk", origin, size, showOnTaskBar))
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "win32_window.h"
|
||||
|
||||
#include <flutter_windows.h>
|
||||
#include <shobjidl_core.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
@ -104,7 +105,7 @@ Win32Window::~Win32Window() {
|
||||
|
||||
bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size) {
|
||||
const Size& size, bool showOnTaskBar) {
|
||||
Destroy();
|
||||
|
||||
const wchar_t* window_class =
|
||||
@ -115,7 +116,7 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST);
|
||||
UINT dpi = FlutterDesktopGetDpiForMonitor(monitor);
|
||||
double scale_factor = dpi / 96.0;
|
||||
|
||||
|
||||
HWND window = CreateWindow(
|
||||
window_class, title.c_str(), WS_OVERLAPPEDWINDOW,
|
||||
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
|
||||
@ -126,6 +127,19 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,8 @@ class Win32Window {
|
||||
// true if the window was created successfully.
|
||||
bool CreateAndShow(const std::wstring& title,
|
||||
const Point& origin,
|
||||
const Size& size);
|
||||
const Size& size,
|
||||
bool showOnTaskBar = true);
|
||||
|
||||
// Release OS resources associated with window.
|
||||
void Destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user