FreeRDP
Loading...
Searching...
No Matches
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 handleEvent (const SDL_DisplayEvent &ev)
 
bool handleEvent (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}
WINPR_ATTR_NODISCARD 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_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}
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.

◆ handleEvent() [1/2]

bool sdlDispContext::handleEvent ( const SDL_DisplayEvent &  ev)

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

324{
325 switch (ev.type)
326 {
327 case SDL_EVENT_DISPLAY_ADDED:
328 SDL_Log("A new display with id %u was connected", ev.displayID);
329 return updateMonitors(ev.type, ev.displayID);
330 case SDL_EVENT_DISPLAY_REMOVED:
331 SDL_Log("The display with id %u was disconnected", ev.displayID);
332 return updateMonitors(ev.type, ev.displayID);
333 case SDL_EVENT_DISPLAY_ORIENTATION:
334 SDL_Log("The orientation of display with id %u was changed", ev.displayID);
335 return updateMonitors(ev.type, ev.displayID);
336 case SDL_EVENT_DISPLAY_MOVED:
337 SDL_Log("The display with id %u was moved", ev.displayID);
338 return updateMonitors(ev.type, ev.displayID);
339 case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
340 SDL_Log("The display with id %u changed scale", ev.displayID);
341 return updateMonitors(ev.type, ev.displayID);
342 case SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED:
343 SDL_Log("The display with id %u changed mode", ev.displayID);
344 return updateMonitors(ev.type, ev.displayID);
345 case SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED:
346 SDL_Log("The display with id %u changed desktop mode", ev.displayID);
347 return updateMonitors(ev.type, ev.displayID);
348 default:
349 return true;
350 }
351}

◆ handleEvent() [2/2]

bool sdlDispContext::handleEvent ( const SDL_WindowEvent &  ev)

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

354{
355 auto window = _sdl->getWindowForId(ev.windowID);
356 if (!window)
357 return true;
358
359 auto bordered = freerdp_settings_get_bool(_sdl->context()->settings, FreeRDP_Decorations);
360 window->setBordered(bordered);
361
362 switch (ev.type)
363 {
364 case SDL_EVENT_WINDOW_HIDDEN:
365 case SDL_EVENT_WINDOW_MINIMIZED:
366 return _sdl->redraw(true);
367 case SDL_EVENT_WINDOW_ENTER_FULLSCREEN:
368 return updateMonitor(ev.windowID);
369 case SDL_EVENT_WINDOW_LEAVE_FULLSCREEN:
370 return updateMonitor(ev.windowID);
371
372 case SDL_EVENT_WINDOW_EXPOSED:
373 case SDL_EVENT_WINDOW_SHOWN:
374 case SDL_EVENT_WINDOW_MAXIMIZED:
375 case SDL_EVENT_WINDOW_RESTORED:
376 if (!_sdl->redraw())
377 return false;
378
379 /* fallthrough */
380 WINPR_FALLTHROUGH
381 case SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED:
382 case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
383 case SDL_EVENT_WINDOW_RESIZED:
384 return updateMonitor(ev.windowID);
385 case SDL_EVENT_WINDOW_MOUSE_LEAVE:
386 WINPR_ASSERT(_sdl);
387 return _sdl->getInputChannelContext().keyboard_grab(ev.windowID, false);
388 case SDL_EVENT_WINDOW_MOUSE_ENTER:
389 WINPR_ASSERT(_sdl);
390 if (!_sdl->getInputChannelContext().keyboard_grab(ev.windowID, true))
391 return false;
392 return _sdl->getInputChannelContext().keyboard_focus_in();
393 case SDL_EVENT_WINDOW_FOCUS_GAINED:
394 return _sdl->getInputChannelContext().keyboard_focus_in();
395
396 default:
397 return true;
398 }
399}

◆ 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: