summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am2
-rw-r--r--src/eventsmanager.cpp28
-rw-r--r--src/eventsmanager.h2
-rw-r--r--src/progs/dyecmd/client.cpp9
-rw-r--r--src/progs/manaplus/client.cpp9
-rw-r--r--src/utils/x11logger.cpp97
-rw-r--r--src/utils/x11logger.h38
8 files changed, 173 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2894c5d0d..4049b940c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -962,6 +962,8 @@ SET(SRCS
utils/timer.cpp
utils/timer.h
utils/vector.h
+ utils/x11logger.cpp
+ utils/x11logger.h
fs/virtfs/file.cpp
fs/virtfs/file.h
utils/mutex.h
@@ -1885,6 +1887,8 @@ SET(DYE_CMD_SRCS
utils/timer.cpp
utils/timer.h
utils/vector.h
+ utils/x11logger.cpp
+ utils/x11logger.h
fs/virtfs/virtfile.cpp
fs/virtfs/virtfile.h
utils/xml.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 23883c487..c82a336e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -648,6 +648,8 @@ BASE_SRC += client.h \
utils/timer.cpp \
utils/timer.h \
utils/vector.h \
+ utils/x11logger.cpp \
+ utils/x11logger.h \
fs/virtfs/file.cpp \
fs/virtfs/file.h \
utils/mutex.h \
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index 36c6e2d23..9a4c8b0f2 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -38,6 +38,8 @@
#include "input/inputmanager.h"
#ifdef USE_SDL2
+#include "utils/x11logger.h"
+
#include "render/graphics.h"
#else // USE_SDL2
#include "logger.h"
@@ -67,6 +69,17 @@ void EventsManager::init()
config.addListener("logInput", this);
}
+void EventsManager::enableEvents()
+{
+ // disable unused SDL events
+#ifndef USE_SDL2
+ SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
+#endif // USE_SDL2
+
+ SDL_EventState(SDL_SYSWMEVENT, mLogInput ? SDL_ENABLE : SDL_IGNORE);
+ SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
+}
+
void EventsManager::shutdown()
{
config.removeListeners(this);
@@ -435,8 +448,23 @@ void EventsManager::logEvent(const SDL_Event &event)
logger->log("event: SDL_QUIT");
break;
case SDL_SYSWMEVENT:
+ {
+#ifdef USE_SDL2
+ bool res = false;
+#ifdef USE_X11
+ res = X11Logger::logEvent(event);
+#endif // USE_X11
+
+ if (res == false)
+ logger->assertLog("event: SDL_SYSWMEVENT: not supported:");
+ break;
+#else // USE_SDL2
+
logger->log("event: SDL_SYSWMEVENT");
+#endif // USE_SDL2
+
break;
+ }
case SDL_USEREVENT:
logger->log("event: SDL_USEREVENT");
break;
diff --git a/src/eventsmanager.h b/src/eventsmanager.h
index 02a118448..725040ca4 100644
--- a/src/eventsmanager.h
+++ b/src/eventsmanager.h
@@ -41,6 +41,8 @@ class EventsManager final : public ConfigListener
void init();
+ void enableEvents();
+
void shutdown();
bool handleEvents() const;
diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp
index 8685cc024..a46227f08 100644
--- a/src/progs/dyecmd/client.cpp
+++ b/src/progs/dyecmd/client.cpp
@@ -243,14 +243,7 @@ void Client::gameInit()
#endif // USE_SDL2
WindowManager::applyKeyRepeat();
-
- // disable unused SDL events
-#ifndef USE_SDL2
- SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
-#endif // USE_SDL2
-
- SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
- SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
+ eventsManager.enableEvents();
#ifdef WIN32
Dirs::extractDataDir();
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp
index aaacdc7a6..6526fc82a 100644
--- a/src/progs/manaplus/client.cpp
+++ b/src/progs/manaplus/client.cpp
@@ -372,14 +372,7 @@ void Client::gameInit()
#endif // USE_SDL2
WindowManager::applyKeyRepeat();
-
- // disable unused SDL events
-#ifndef USE_SDL2
- SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
-#endif // USE_SDL2
-
- SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
- SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
+ eventsManager.enableEvents();
#ifdef WIN32
Dirs::extractDataDir();
diff --git a/src/utils/x11logger.cpp b/src/utils/x11logger.cpp
new file mode 100644
index 000000000..a61a940b7
--- /dev/null
+++ b/src/utils/x11logger.cpp
@@ -0,0 +1,97 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef USE_SDL2
+#ifdef USE_X11
+
+#include "utils/x11logger.h"
+
+#include "logger.h"
+
+PRAGMA48(GCC diagnostic push)
+PRAGMA48(GCC diagnostic ignored "-Wshadow")
+#include <SDL_events.h>
+#include <SDL_syswm.h>
+PRAGMA48(GCC diagnostic pop)
+
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+#define logType(val, str) \
+ case val: \
+ typeStr = str; \
+ break
+
+bool X11Logger::logEvent(const SDL_Event &event)
+{
+ if (event.syswm.msg->subsystem != SDL_SYSWM_X11)
+ return false;
+ std::string typeStr;
+
+ const int type = event.syswm.msg->msg.x11.event.type;
+ switch (type)
+ {
+ logType(2, "KeyPress");
+ logType(3, "KeyRelease");
+ logType(4, "ButtonPress");
+ logType(5, "ButtonRelease");
+ logType(6, "MotionNotify");
+ logType(7, "EnterNotify");
+ logType(8, "LeaveNotify");
+ logType(9, "FocusIn");
+ logType(10, "FocusOut");
+ logType(11, "KeymapNotify");
+ logType(12, "Expose");
+ logType(13, "GraphicsExpose");
+ logType(14, "NoExpose");
+ logType(15, "VisibilityNotify");
+ logType(16, "CreateNotify");
+ logType(17, "DestroyNotify");
+ logType(18, "UnmapNotify");
+ logType(19, "MapNotify");
+ logType(20, "MapRequest");
+ logType(21, "ReparentNotify");
+ logType(22, "ConfigureNotify");
+ logType(23, "ConfigureRequest");
+ logType(24, "GravityNotify");
+ logType(25, "ResizeRequest");
+ logType(26, "CirculateNotify");
+ logType(27, "CirculateRequest");
+ logType(28, "PropertyNotify");
+ logType(29, "SelectionClear");
+ logType(30, "SelectionRequest");
+ logType(31, "SelectionNotify");
+ logType(32, "ColormapNotify");
+ logType(33, "ClientMessage");
+ logType(34, "MappingNotify");
+ logType(35, "GenericEvent");
+ default:
+ typeStr = strprintf("Unknown: %d", type);
+ break;
+ }
+
+ logger->log("event: SDL_SYSWMEVENT: X11: %s",
+ typeStr.c_str());
+ return true;
+}
+
+#endif // USE_X11
+#endif // USE_SDL2
diff --git a/src/utils/x11logger.h b/src/utils/x11logger.h
new file mode 100644
index 000000000..e7307ce51
--- /dev/null
+++ b/src/utils/x11logger.h
@@ -0,0 +1,38 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2017 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UTILS_X11LOGGER_H
+#define UTILS_X11LOGGER_H
+
+#ifdef USE_SDL2
+#ifdef USE_X11
+
+#include "localconsts.h"
+
+union SDL_Event;
+
+namespace X11Logger
+{
+ bool logEvent(const SDL_Event &event);
+} // namespace X11Logger
+
+#endif // USE_X11
+#endif // USE_SDL2
+#endif // UTILS_X11LOGGER_H