2022-12-30 13:25:28 +03:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* SDL Client
|
|
|
|
*
|
|
|
|
* Copyright 2022 Armin Novak <armin.novak@thincast.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-03-06 18:04:05 +03:00
|
|
|
#pragma once
|
2022-12-30 13:25:28 +03:00
|
|
|
|
2023-04-14 10:16:50 +03:00
|
|
|
#include <winpr/synch.h>
|
2023-01-18 10:50:55 +03:00
|
|
|
#include <winpr/wlog.h>
|
|
|
|
|
2022-12-30 13:25:28 +03:00
|
|
|
#include <SDL.h>
|
2024-02-21 13:37:28 +03:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2022-12-30 13:25:28 +03:00
|
|
|
|
2023-05-30 21:59:18 +03:00
|
|
|
class CriticalSection
|
2023-04-14 09:46:02 +03:00
|
|
|
{
|
|
|
|
public:
|
2023-05-30 21:59:18 +03:00
|
|
|
CriticalSection();
|
2024-09-18 23:44:04 +03:00
|
|
|
CriticalSection(const CriticalSection& other) = delete;
|
|
|
|
CriticalSection(CriticalSection&& other) = delete;
|
2023-05-30 21:59:18 +03:00
|
|
|
~CriticalSection();
|
|
|
|
|
2024-09-18 23:44:04 +03:00
|
|
|
CriticalSection& operator=(const CriticalSection& other) = delete;
|
|
|
|
CriticalSection& operator=(const CriticalSection&& other) = delete;
|
|
|
|
|
2023-05-30 21:59:18 +03:00
|
|
|
void lock();
|
|
|
|
void unlock();
|
2023-04-14 09:46:02 +03:00
|
|
|
|
|
|
|
private:
|
2024-08-29 16:10:33 +03:00
|
|
|
CRITICAL_SECTION _section{};
|
2023-04-14 09:46:02 +03:00
|
|
|
};
|
|
|
|
|
2023-05-30 21:59:18 +03:00
|
|
|
class WinPREvent
|
|
|
|
{
|
|
|
|
public:
|
2024-02-13 11:52:47 +03:00
|
|
|
explicit WinPREvent(bool initial = false);
|
2023-05-30 21:59:18 +03:00
|
|
|
~WinPREvent();
|
|
|
|
|
|
|
|
void set();
|
2023-05-30 22:04:53 +03:00
|
|
|
void clear();
|
2024-02-13 11:52:47 +03:00
|
|
|
[[nodiscard]] bool isSet() const;
|
2023-05-30 21:59:18 +03:00
|
|
|
|
2024-02-13 11:52:47 +03:00
|
|
|
[[nodiscard]] HANDLE handle() const;
|
2023-05-30 21:59:18 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
HANDLE _handle;
|
|
|
|
};
|
|
|
|
|
2023-02-14 13:12:18 +03:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
SDL_USEREVENT_UPDATE = SDL_USEREVENT + 1,
|
|
|
|
SDL_USEREVENT_CREATE_WINDOWS,
|
|
|
|
SDL_USEREVENT_WINDOW_RESIZEABLE,
|
|
|
|
SDL_USEREVENT_WINDOW_FULLSCREEN,
|
2024-09-10 13:03:37 +03:00
|
|
|
SDL_USEREVENT_WINDOW_MINIMIZE,
|
2023-02-14 13:12:18 +03:00
|
|
|
SDL_USEREVENT_POINTER_NULL,
|
|
|
|
SDL_USEREVENT_POINTER_DEFAULT,
|
|
|
|
SDL_USEREVENT_POINTER_POSITION,
|
2023-05-30 19:22:57 +03:00
|
|
|
SDL_USEREVENT_POINTER_SET,
|
2023-02-14 18:16:24 +03:00
|
|
|
SDL_USEREVENT_QUIT,
|
|
|
|
SDL_USEREVENT_CERT_DIALOG,
|
|
|
|
SDL_USEREVENT_SHOW_DIALOG,
|
|
|
|
SDL_USEREVENT_AUTH_DIALOG,
|
|
|
|
SDL_USEREVENT_SCARD_DIALOG,
|
2023-12-15 17:55:27 +03:00
|
|
|
SDL_USEREVENT_RETRY_DIALOG,
|
2023-02-14 18:16:24 +03:00
|
|
|
|
|
|
|
SDL_USEREVENT_CERT_RESULT,
|
|
|
|
SDL_USEREVENT_SHOW_RESULT,
|
|
|
|
SDL_USEREVENT_AUTH_RESULT,
|
|
|
|
SDL_USEREVENT_SCARD_RESULT
|
2023-02-14 13:12:18 +03:00
|
|
|
};
|
|
|
|
|
2023-02-14 18:16:24 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Uint32 type;
|
|
|
|
Uint32 timestamp;
|
|
|
|
char* title;
|
|
|
|
char* user;
|
|
|
|
char* domain;
|
|
|
|
char* password;
|
|
|
|
Sint32 result;
|
|
|
|
} SDL_UserAuthArg;
|
|
|
|
|
2023-02-14 13:12:18 +03:00
|
|
|
BOOL sdl_push_user_event(Uint32 type, ...);
|
|
|
|
|
2023-12-16 19:54:22 +03:00
|
|
|
bool sdl_push_quit();
|
|
|
|
|
2024-02-15 17:42:16 +03:00
|
|
|
std::string sdl_window_event_str(Uint8 ev);
|
2022-12-30 13:25:28 +03:00
|
|
|
const char* sdl_event_type_str(Uint32 type);
|
2023-01-18 10:50:55 +03:00
|
|
|
const char* sdl_error_string(Uint32 res);
|
|
|
|
|
2023-07-27 10:02:03 +03:00
|
|
|
#define sdl_log_error(res, log, what) sdl_log_error_ex(res, log, what, __FILE__, __LINE__, __func__)
|
2023-01-18 10:50:55 +03:00
|
|
|
BOOL sdl_log_error_ex(Uint32 res, wLog* log, const char* what, const char* file, size_t line,
|
|
|
|
const char* fkt);
|