Skip to content

Commit

Permalink
Merge StdXApp, StdSDLApp and StdTApp into StdAppUnix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fulgen301 committed Feb 6, 2023
1 parent bbc0d94 commit bcedb99
Show file tree
Hide file tree
Showing 12 changed files with 838 additions and 1,326 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,12 @@ endif ()

if (WIN32)
append_filelist(CLONK_SOURCES EngineWin32.txt)
elseif (APPLE)
else ()
if (APPLE)
append_filelist(CLONK_SOURCES EngineApple.txt)
endif ()

list(APPEND CLONK_SOURCES src/StdAppUnix.cpp)
endif ()

if (USE_SDL_MAINLOOP OR USE_SDL_MIXER)
Expand Down
2 changes: 0 additions & 2 deletions cmake/filelists/EngineConsoleNonWin32.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
src/StdTApp.cpp
src/StdXPrivate.h
src/StdXWindow.cpp
1 change: 0 additions & 1 deletion cmake/filelists/EngineSdlMainloop.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
src/StdSDLApp.cpp
src/StdSDLWindow.cpp
2 changes: 0 additions & 2 deletions cmake/filelists/EngineX.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
src/StdXApp.cpp
src/StdXPrivate.h
src/StdXWindow.cpp
1 change: 0 additions & 1 deletion cmake/filelists/PchExclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ src/C4AudioSystemSdl.h
src/C4ToastLibNotify.h
src/C4ToastWinToastLib.h
src/StdWic.h
src/StdXPrivate.h
64 changes: 48 additions & 16 deletions src/StdApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

#ifdef _WIN32
const int SEC1_TIMER = 1, SEC1_MSEC = 1000;
#elif defined(USE_X11)
struct _XIC;
struct _XIM;
#include <unordered_map>
#endif

#ifdef WITH_GLIB
struct _GMainLoop;
struct _GIOChannel;
#endif

#include <thread>
Expand Down Expand Up @@ -119,6 +128,7 @@ const int SEC1_TIMER = 1, SEC1_MSEC = 1000;
// from X.h:
//#define ShiftMask (1 << 0)
//#define ControlMask (1 << 2)
#define MK_ALT (1 << 3)
#define MK_CONTROL (1 << 2)
#define MK_SHIFT (1 << 0)
#elif defined(USE_SDL_MAINLOOP)
Expand Down Expand Up @@ -239,7 +249,7 @@ class CStdApp
CStdApp();
virtual ~CStdApp();

bool Active;
bool Active{false};
bool MMTimer;

virtual void Clear();
Expand All @@ -253,7 +263,7 @@ class CStdApp
void SetDisplayMode(DisplayMode mode) { pWindow->SetDisplayMode(mode); }
void ResetTimer(unsigned int uDelay);
CStdWindow *pWindow;
bool fQuitMsgReceived; // if true, a quit message has been received and the application should terminate
bool fQuitMsgReceived{false}; // if true, a quit message has been received and the application should terminate
const char *GetCommandLine() { return szCmdLine; }

// Copy the text to the clipboard or the primary selection
Expand Down Expand Up @@ -308,16 +318,13 @@ class CStdApp
UINT idCriticalTimer;
UINT GetDelay() { return uCriticalTimerDelay; }
#else
#if defined(USE_X11)
Display *dpy = nullptr;
#ifdef USE_X11
Display *dpy{nullptr};
int xf86vmode_major_version, xf86vmode_minor_version;
#endif
#if defined(USE_SDL_MAINLOOP)
void HandleSDLEvent(SDL_Event &event);
#endif
const char *Location;
const char *Location{""};
void Init(int argc, char *argv[]);
bool DoNotDelay;
bool DoNotDelay{false};
void NextTick(bool fYield);
bool IsShiftDown() { return KeyMask & MK_SHIFT; }
bool IsControlDown() { return KeyMask & MK_CONTROL; }
Expand All @@ -330,21 +337,46 @@ class CStdApp
void OnXInput();
void OnPipeInput();
void OnStdInInput();
#endif

protected:
#if defined(USE_SDL_MAINLOOP)
int argc; char **argv;
#ifndef _WIN32
unsigned int Delay{27777}; // 36 FPS
timeval LastExecute;
int argc;
char **argv;
int Pipe[2];
unsigned int KeyMask{0};

#ifdef WITH_GLIB
_GMainLoop *loop{nullptr};
#ifdef USE_X11
_GIOChannel *xChannel{nullptr};
#endif
_GIOChannel *pipeChannel{nullptr};
#endif

#ifdef USE_X11
int detectable_autorepeat_supported;
_XIM *inputMethod{nullptr};
_XIC *inputContext{nullptr};
std::unordered_map<unsigned long, CStdWindow *> windows;
unsigned long LastEventTime{0};
std::string primarySelection;
std::string clipboardSelection;
#elif defined(USE_SDL_MAINLOOP)
int nextWidth, nextHeight, nextBPP;
std::optional<StdSdlSubSystem> sdlVideoSubSys;
#endif
class CStdAppPrivate *Priv;
void HandleXMessage();

unsigned int Delay;
timeval LastExecute;
unsigned int KeyMask;
#ifdef USE_X11
void NewWindow(CStdWindow *window);
void HandleXMessage();
#elif defined(USE_SDL_MAINLOOP)
void HandleSDLEvent(SDL_Event &event);
#endif
#endif

const char *szCmdLine;
std::thread::id mainThread{};
bool InitTimer();
Expand Down
Loading

0 comments on commit bcedb99

Please sign in to comment.