GLVis
v4.2
Accurate and flexible finite element visualization
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Pages
glvis
lib
sdl_x11.hpp
Go to the documentation of this file.
1
// Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3
// LICENSE and NOTICE for details. LLNL-CODE-443271.
4
//
5
// This file is part of the GLVis visualization tool and library. For more
6
// information and source code availability see https://glvis.org.
7
//
8
// GLVis is free software; you can redistribute it and/or modify it under the
9
// terms of the BSD-3 license. We welcome feedback and contributions, see file
10
// CONTRIBUTING.md for details.
11
12
#ifndef GLVIS_SDL_X11_HPP
13
#define GLVIS_SDL_X11_HPP
14
15
#include "
sdl_helper.hpp
"
16
17
#ifdef SDL_VIDEO_DRIVER_X11
18
19
#include <unordered_map>
20
21
#include <poll.h>
22
23
#include <unistd.h>
// pipe, fcntl, write
24
#include <fcntl.h>
// fcntl
25
#include <cerrno>
// errno, EAGAIN
26
#include <cstdio>
// perror
27
28
class
SdlX11Platform
final :
public
SdlNativePlatform
29
{
30
public
:
31
SdlX11Platform
()
32
{
33
// Create pipe for external events
34
if
(pipe(event_pfd) == -1)
35
{
36
perror(
"pipe()"
);
37
exit(EXIT_FAILURE);
38
}
39
int
flag = fcntl(event_pfd[0], F_GETFL);
40
fcntl(event_pfd[0], F_SETFL, flag | O_NONBLOCK);
41
}
42
43
~SdlX11Platform
()
44
{
45
close(event_pfd[0]);
46
close(event_pfd[1]);
47
}
48
49
void
RegisterWindow
(SDL_Window* window);
50
51
void
UnregisterWindow
(SDL_Window* window);
52
53
void
WaitEvent
();
54
55
void
SendEvent
()
56
{
57
char
c =
's'
;
58
if
(write(event_pfd[1], &c,
sizeof
(c)) != 1)
59
{
60
perror(
"write()"
);
61
exit(EXIT_FAILURE);
62
}
63
}
64
65
private
:
66
int
event_pfd[2];
// pfd[0] -- reading, pfd[1] -- writing
67
std::unordered_map<SDL_Window*, int> display_fds;
68
};
69
70
#endif // SDL_VIDEO_DRIVER_X11
71
72
#endif // GLVIS_SDL_X11_HPP
SdlX11Platform::SendEvent
void SendEvent()
Definition:
sdl_x11.hpp:55
SdlX11Platform::WaitEvent
void WaitEvent()
Definition:
sdl_x11.cpp:98
SdlNativePlatform
Definition:
sdl_helper.hpp:18
SdlX11Platform::RegisterWindow
void RegisterWindow(SDL_Window *window)
Definition:
sdl_x11.cpp:32
SdlX11Platform
Definition:
sdl_x11.hpp:28
SdlX11Platform::~SdlX11Platform
~SdlX11Platform()
Definition:
sdl_x11.hpp:43
SdlX11Platform::SdlX11Platform
SdlX11Platform()
Definition:
sdl_x11.hpp:31
SdlX11Platform::UnregisterWindow
void UnregisterWindow(SDL_Window *window)
Definition:
sdl_x11.cpp:93
sdl_helper.hpp
Generated on Tue May 24 2022 09:49:54 for GLVis by
1.8.5