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

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

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

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

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

◆ handleEvent() [2/2]

bool sdlDispContext::handleEvent ( const SDL_WindowEvent &  ev)

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

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

◆ init()

bool sdlDispContext::init ( DispClientContext *  disp)

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

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

◆ uninit()

bool sdlDispContext::uninit ( DispClientContext *  disp)

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

439{
440 if (!disp)
441 return FALSE;
442
443 _disp = nullptr;
444 _sdl->update_resizeable(FALSE);
445 return TRUE;
446}

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