FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
sdlDispContext Class Reference

#include <sdl_disp.hpp>

Public Member Functions

 sdlDispContext (SdlContext *sdl)
 
 sdlDispContext (const sdlDispContext &other)=delete
 
 sdlDispContext (sdlDispContext &&other)=delete
 
sdlDispContextoperator= (const sdlDispContext &other)=delete
 
sdlDispContextoperator= (sdlDispContext &&other)=delete
 
BOOL init (DispClientContext *disp)
 
BOOL uninit (DispClientContext *disp)
 
BOOL handle_window_event (const SDL_WindowEvent *ev)
 
 sdlDispContext (SdlContext *sdl)
 
 sdlDispContext (const sdlDispContext &other)=delete
 
 sdlDispContext (sdlDispContext &&other)=delete
 
sdlDispContextoperator= (const sdlDispContext &other)=delete
 
sdlDispContextoperator= (sdlDispContext &&other)=delete
 
bool init (DispClientContext *disp)
 
bool uninit (DispClientContext *disp)
 
bool handle_display_event (const SDL_DisplayEvent *ev)
 
bool handle_window_event (const SDL_WindowEvent *ev)
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Display Control Channel

Copyright 2023 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

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.

Definition at line 29 of file SDL2/sdl_disp.hpp.

Constructor & Destructor Documentation

◆ sdlDispContext()

sdlDispContext::sdlDispContext ( SdlContext sdl)
explicit

Definition at line 453 of file SDL2/sdl_disp.cpp.

453 : _sdl(sdl)
454{
455 SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
456
457 WINPR_ASSERT(_sdl);
458 WINPR_ASSERT(_sdl->context()->settings);
459 WINPR_ASSERT(_sdl->context()->pubSub);
460
461 auto settings = _sdl->context()->settings;
462 auto pubSub = _sdl->context()->pubSub;
463
464 _lastSentWidth = _targetWidth =
465 WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
466 _lastSentHeight = _targetHeight =
467 WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
468 PubSub_SubscribeActivated(pubSub, sdlDispContext::OnActivated);
469 PubSub_SubscribeGraphicsReset(pubSub, sdlDispContext::OnGraphicsReset);
470 addTimer();
471}
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.

◆ ~sdlDispContext()

sdlDispContext::~sdlDispContext ( )

Definition at line 473 of file SDL2/sdl_disp.cpp.

474{
475 wPubSub* pubSub = _sdl->context()->pubSub;
476 WINPR_ASSERT(pubSub);
477
478 PubSub_UnsubscribeActivated(pubSub, sdlDispContext::OnActivated);
479 PubSub_UnsubscribeGraphicsReset(pubSub, sdlDispContext::OnGraphicsReset);
480 SDL_RemoveTimer(_timer);
481 SDL_Quit();
482}

Member Function Documentation

◆ handle_display_event()

bool sdlDispContext::handle_display_event ( const SDL_DisplayEvent *  ev)

Definition at line 339 of file SDL3/sdl_disp.cpp.

340{
341 WINPR_ASSERT(ev);
342
343 switch (ev->type)
344 {
345 case SDL_EVENT_DISPLAY_ADDED:
346 SDL_Log("A new display with id %u was connected", ev->displayID);
347 return updateMonitors(ev->type);
348 case SDL_EVENT_DISPLAY_REMOVED:
349 SDL_Log("The display with id %u was disconnected", ev->displayID);
350 return updateMonitors(ev->type);
351 case SDL_EVENT_DISPLAY_ORIENTATION:
352 SDL_Log("The orientation of display with id %u was changed", ev->displayID);
353 return updateMonitors(ev->type);
354 case SDL_EVENT_DISPLAY_MOVED:
355 SDL_Log("The display with id %u was moved", ev->displayID);
356 return updateMonitors(ev->type);
357 case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
358 SDL_Log("The display with id %u changed scale", ev->displayID);
359 return updateMonitors(ev->type);
360 case SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED:
361 SDL_Log("The display with id %u changed mode", ev->displayID);
362 return updateMonitors(ev->type);
363 case SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED:
364 SDL_Log("The display with id %u changed desktop mode", ev->displayID);
365 return updateMonitors(ev->type);
366 default:
367 return true;
368 }
369}

◆ handle_window_event()

bool sdlDispContext::handle_window_event ( const SDL_WindowEvent *  ev)

Definition at line 339 of file SDL2/sdl_disp.cpp.

340{
341 WINPR_ASSERT(ev);
342#if defined(WITH_DEBUG_SDL_EVENTS)
343 SDL_Log("got windowEvent %s [0x%08" PRIx32 "]", sdl_window_event_str(ev->event).c_str(),
344 ev->event);
345#endif
346 auto bordered = freerdp_settings_get_bool(_sdl->context()->settings, FreeRDP_Decorations)
347 ? SDL_TRUE
348 : SDL_FALSE;
349
350 auto it = _sdl->windows.find(ev->windowID);
351 if (it != _sdl->windows.end())
352 it->second.setBordered(bordered);
353
354 switch (ev->event)
355 {
356 case SDL_WINDOWEVENT_HIDDEN:
357 case SDL_WINDOWEVENT_MINIMIZED:
358 gdi_send_suppress_output(_sdl->context()->gdi, TRUE);
359 return TRUE;
360
361 case SDL_WINDOWEVENT_EXPOSED:
362 case SDL_WINDOWEVENT_SHOWN:
363 case SDL_WINDOWEVENT_MAXIMIZED:
364 case SDL_WINDOWEVENT_RESTORED:
365 gdi_send_suppress_output(_sdl->context()->gdi, FALSE);
366 return TRUE;
367
368 case SDL_WINDOWEVENT_RESIZED:
369 case SDL_WINDOWEVENT_SIZE_CHANGED:
370 _targetWidth = ev->data1;
371 _targetHeight = ev->data2;
372 return addTimer();
373
374 case SDL_WINDOWEVENT_LEAVE:
375 WINPR_ASSERT(_sdl);
376 _sdl->input.keyboard_grab(ev->windowID, false);
377 return TRUE;
378 case SDL_WINDOWEVENT_ENTER:
379 WINPR_ASSERT(_sdl);
380 _sdl->input.keyboard_grab(ev->windowID, true);
381 return _sdl->input.keyboard_focus_in();
382 case SDL_WINDOWEVENT_FOCUS_GAINED:
383 case SDL_WINDOWEVENT_TAKE_FOCUS:
384 return _sdl->input.keyboard_focus_in();
385
386 default:
387 return TRUE;
388 }
389}
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.

◆ init()

bool sdlDispContext::init ( DispClientContext *  disp)

Definition at line 421 of file SDL2/sdl_disp.cpp.

422{
423 if (!disp)
424 return FALSE;
425
426 auto settings = _sdl->context()->settings;
427
428 if (!settings)
429 return FALSE;
430
431 _disp = disp;
432 disp->custom = this;
433
434 if (freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate))
435 {
436 disp->DisplayControlCaps = sdlDispContext::DisplayControlCaps;
437 }
438
439 _sdl->update_resizeable(TRUE);
440 return TRUE;
441}

◆ uninit()

bool sdlDispContext::uninit ( DispClientContext *  disp)

Definition at line 443 of file SDL2/sdl_disp.cpp.

444{
445 if (!disp)
446 return FALSE;
447
448 _disp = nullptr;
449 _sdl->update_resizeable(FALSE);
450 return TRUE;
451}

The documentation for this class was generated from the following files: