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 452 of file SDL2/sdl_disp.cpp.

452 : _sdl(sdl)
453{
454 SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
455
456 WINPR_ASSERT(_sdl);
457 WINPR_ASSERT(_sdl->context()->settings);
458 WINPR_ASSERT(_sdl->context()->pubSub);
459
460 auto settings = _sdl->context()->settings;
461 auto pubSub = _sdl->context()->pubSub;
462
463 _lastSentWidth = _targetWidth =
464 WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
465 _lastSentHeight = _targetHeight =
466 WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
467 PubSub_SubscribeActivated(pubSub, sdlDispContext::OnActivated);
468 PubSub_SubscribeGraphicsReset(pubSub, sdlDispContext::OnGraphicsReset);
469 addTimer();
470}
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 472 of file SDL2/sdl_disp.cpp.

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

Member Function Documentation

◆ handle_window_event()

BOOL sdlDispContext::handle_window_event ( const SDL_WindowEvent *  ev)

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

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

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

◆ uninit()

bool sdlDispContext::uninit ( DispClientContext *  disp)

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

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

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