FreeRDP/client/SDL/sdl_utils.hpp

70 lines
1.8 KiB
C++
Raw Normal View History

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.
*/
#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 <stdbool.h>
#include <SDL.h>
2023-04-14 10:16:50 +03:00
#include "sdl_types.hpp"
class CriticalSectionLock
{
public:
CriticalSectionLock(CRITICAL_SECTION& section) : _section(section)
{
EnterCriticalSection(&_section);
}
~CriticalSectionLock()
{
LeaveCriticalSection(&_section);
}
private:
CRITICAL_SECTION _section;
};
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,
SDL_USEREVENT_POINTER_NULL,
SDL_USEREVENT_POINTER_DEFAULT,
SDL_USEREVENT_POINTER_POSITION,
SDL_USEREVENT_POINTER_SET
};
BOOL update_resizeable(sdlContext* sdl, BOOL enable);
BOOL update_fullscreen(sdlContext* sdl, BOOL enter);
2023-02-14 13:12:18 +03:00
BOOL sdl_push_user_event(Uint32 type, ...);
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-01-25 14:30:50 +03:00
#define sdl_log_error(res, log, what) \
sdl_log_error_ex(res, log, what, __FILE__, __LINE__, __FUNCTION__)
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);