FreeRDP
Loading...
Searching...
No Matches
SDLConnectionDialog Class Reference

#include <sdl_connection_dialog.hpp>

Public Member Functions

 SDLConnectionDialog (rdpContext *context)
 
 SDLConnectionDialog (const SDLConnectionDialog &other)=delete
 
 SDLConnectionDialog (const SDLConnectionDialog &&other)=delete
 
SDLConnectionDialogoperator= (const SDLConnectionDialog &other)=delete
 
SDLConnectionDialogoperator= (SDLConnectionDialog &&other)=delete
 
bool visible () const
 
bool setTitle (const char *fmt,...)
 
bool showInfo (const char *fmt,...)
 
bool showWarn (const char *fmt,...)
 
bool showError (const char *fmt,...)
 
bool show ()
 
bool hide ()
 
bool running () const
 
bool wait (bool ignoreRdpContextQuit=false)
 
bool handle (const SDL_Event &event)
 
 SDLConnectionDialog (rdpContext *context)
 
 SDLConnectionDialog (const SDLConnectionDialog &other)=delete
 
 SDLConnectionDialog (const SDLConnectionDialog &&other)=delete
 
SDLConnectionDialogoperator= (const SDLConnectionDialog &other)=delete
 
SDLConnectionDialogoperator= (SDLConnectionDialog &other)=delete
 
bool visible () const
 
bool setTitle (const char *fmt,...)
 
bool showInfo (const char *fmt,...)
 
bool showWarn (const char *fmt,...)
 
bool showError (const char *fmt,...)
 
bool show ()
 
bool hide ()
 
bool running () const
 
bool wait (bool ignoreRdpContextQuit=false)
 
bool handle (const SDL_Event &event)
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Client helper dialogs

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 34 of file SDL2/dialogs/sdl_connection_dialog.hpp.

Constructor & Destructor Documentation

◆ SDLConnectionDialog()

SDLConnectionDialog::SDLConnectionDialog ( rdpContext *  context)
explicit

Definition at line 36 of file SDL2/dialogs/sdl_connection_dialog.cpp.

36 : _context(context)
37{
38 SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
39 hide();
40}

◆ ~SDLConnectionDialog()

SDLConnectionDialog::~SDLConnectionDialog ( )
virtual

Definition at line 42 of file SDL2/dialogs/sdl_connection_dialog.cpp.

43{
44 resetTimer();
45 destroyWindow();
46 SDL_Quit();
47}

Member Function Documentation

◆ handle()

bool SDLConnectionDialog::handle ( const SDL_Event &  event)

Definition at line 206 of file SDL2/dialogs/sdl_connection_dialog.cpp.

207{
208 Uint32 windowID = 0;
209 if (_window)
210 {
211 windowID = SDL_GetWindowID(_window);
212 }
213
214 switch (event.type)
215 {
216 case SDL_USEREVENT_RETRY_DIALOG:
217 return update();
218 case SDL_QUIT:
219 resetTimer();
220 destroyWindow();
221 return false;
222 case SDL_KEYDOWN:
223 case SDL_KEYUP:
224 if (visible())
225 {
226 auto& ev = reinterpret_cast<const SDL_KeyboardEvent&>(event);
227 update(_renderer);
228 switch (event.key.keysym.sym)
229 {
230 case SDLK_RETURN:
231 case SDLK_RETURN2:
232 case SDLK_ESCAPE:
233 case SDLK_KP_ENTER:
234 if (event.type == SDL_KEYUP)
235 {
236 freerdp_abort_event(_context);
237 sdl_push_quit();
238 }
239 break;
240 case SDLK_TAB:
241 _buttons.set_highlight_next();
242 break;
243 default:
244 break;
245 }
246
247 return windowID == ev.windowID;
248 }
249 return false;
250 case SDL_MOUSEMOTION:
251 if (visible())
252 {
253 auto& ev = reinterpret_cast<const SDL_MouseMotionEvent&>(event);
254
255 _buttons.set_mouseover(event.button.x, event.button.y);
256 update(_renderer);
257 return windowID == ev.windowID;
258 }
259 return false;
260 case SDL_MOUSEBUTTONDOWN:
261 case SDL_MOUSEBUTTONUP:
262 if (visible())
263 {
264 auto& ev = reinterpret_cast<const SDL_MouseButtonEvent&>(event);
265 update(_renderer);
266
267 auto button = _buttons.get_selected(event.button);
268 if (button)
269 {
270 if (event.type == SDL_MOUSEBUTTONUP)
271 {
272 freerdp_abort_event(_context);
273 sdl_push_quit();
274 }
275 }
276
277 return windowID == ev.windowID;
278 }
279 return false;
280 case SDL_MOUSEWHEEL:
281 if (visible())
282 {
283 auto& ev = reinterpret_cast<const SDL_MouseWheelEvent&>(event);
284 update(_renderer);
285 return windowID == ev.windowID;
286 }
287 return false;
288 case SDL_FINGERUP:
289 case SDL_FINGERDOWN:
290 if (visible())
291 {
292 auto& ev = reinterpret_cast<const SDL_TouchFingerEvent&>(event);
293 update(_renderer);
294#if SDL_VERSION_ATLEAST(2, 0, 18)
295 return windowID == ev.windowID;
296#else
297 return false;
298#endif
299 }
300 return false;
301 case SDL_WINDOWEVENT:
302 {
303 auto& ev = reinterpret_cast<const SDL_WindowEvent&>(event);
304 switch (ev.event)
305 {
306 case SDL_WINDOWEVENT_CLOSE:
307 if (windowID == ev.windowID)
308 {
309 freerdp_abort_event(_context);
310 sdl_push_quit();
311 }
312 break;
313 default:
314 update(_renderer);
315 setModal();
316 break;
317 }
318
319 return windowID == ev.windowID;
320 }
321 default:
322 return false;
323 }
324}

◆ hide()

bool SDLConnectionDialog::hide ( )

Definition at line 104 of file SDL2/dialogs/sdl_connection_dialog.cpp.

105{
106 std::lock_guard lock(_mux);
107 return show(MSG_DISCARD);
108}

◆ running()

bool SDLConnectionDialog::running ( ) const

Definition at line 110 of file SDL2/dialogs/sdl_connection_dialog.cpp.

111{
112 std::lock_guard lock(_mux);
113 return _running;
114}

◆ setTitle()

bool SDLConnectionDialog::setTitle ( const char *  fmt,
  ... 
)

Definition at line 58 of file SDL2/dialogs/sdl_connection_dialog.cpp.

59{
60 std::lock_guard lock(_mux);
61 va_list ap = {};
62 va_start(ap, fmt);
63 _title = print(fmt, ap);
64 va_end(ap);
65
66 return show(MSG_NONE);
67}

◆ show()

bool SDLConnectionDialog::show ( )

Definition at line 98 of file SDL2/dialogs/sdl_connection_dialog.cpp.

99{
100 std::lock_guard lock(_mux);
101 return show(_type_active);
102}

◆ showError()

bool SDLConnectionDialog::showError ( const char *  fmt,
  ... 
)

Definition at line 87 of file SDL2/dialogs/sdl_connection_dialog.cpp.

88{
89 va_list ap = {};
90 va_start(ap, fmt);
91 auto rc = show(MSG_ERROR, fmt, ap);
92 va_end(ap);
93 if (!rc)
94 return rc;
95 return setTimer();
96}

◆ showInfo()

bool SDLConnectionDialog::showInfo ( const char *  fmt,
  ... 
)

Definition at line 69 of file SDL2/dialogs/sdl_connection_dialog.cpp.

70{
71 va_list ap = {};
72 va_start(ap, fmt);
73 auto rc = show(MSG_INFO, fmt, ap);
74 va_end(ap);
75 return rc;
76}

◆ showWarn()

bool SDLConnectionDialog::showWarn ( const char *  fmt,
  ... 
)

Definition at line 78 of file SDL2/dialogs/sdl_connection_dialog.cpp.

79{
80 va_list ap = {};
81 va_start(ap, fmt);
82 auto rc = show(MSG_WARN, fmt, ap);
83 va_end(ap);
84 return rc;
85}

◆ visible()

bool SDLConnectionDialog::visible ( ) const

Definition at line 49 of file SDL2/dialogs/sdl_connection_dialog.cpp.

50{
51 if (!_window || !_renderer)
52 return false;
53
54 auto flags = SDL_GetWindowFlags(_window);
55 return (flags & (SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED)) == 0;
56}

◆ wait()

bool SDLConnectionDialog::wait ( bool  ignoreRdpContextQuit = false)

Definition at line 192 of file SDL2/dialogs/sdl_connection_dialog.cpp.

193{
194 while (running())
195 {
196 if (!ignoreRdpContext)
197 {
198 if (freerdp_shall_disconnect_context(_context))
199 return false;
200 }
201 std::this_thread::yield();
202 }
203 return true;
204}

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