From d241dc009ca9a5e442bf9143e44ce367b3a91a97 Mon Sep 17 00:00:00 2001 From: Andreas Butti Date: Sun, 23 Dec 2018 15:37:18 +0100 Subject: [PATCH] Removed dead GTK2 Code --- src/control/Control.cpp | 8 +-- src/control/settings/Settings.cpp | 26 ---------- src/control/settings/Settings.h | 8 --- src/gui/widgets/XournalWidget.cpp | 1 - src/util/XInputUtils.cpp | 85 ------------------------------- src/util/XInputUtils.h | 51 ------------------- 6 files changed, 2 insertions(+), 177 deletions(-) delete mode 100644 src/util/XInputUtils.cpp delete mode 100644 src/util/XInputUtils.h diff --git a/src/control/Control.cpp b/src/control/Control.cpp index b623d223..4191de36 100644 --- a/src/control/Control.cpp +++ b/src/control/Control.cpp @@ -51,7 +51,6 @@ extern int currentToolType; #include #include #include -#include #include namespace bf = boost::filesystem; @@ -329,12 +328,9 @@ void Control::initWindow(MainWindow* win) win->setFontButtonFont(settings->getFont()); - XInputUtils::initUtils(win->getWindow()); - XInputUtils::setLeafEnterWorkaroundEnabled(settings->isEnableLeafEnterWorkaround()); - - //rotation snapping enabled by default + // rotation snapping enabled by default fireActionSelected(GROUP_SNAPPING,ACTION_ROTATION_SNAPPING); - //grid snapping enabled by default + // grid snapping enabled by default fireActionSelected(GROUP_GRID_SNAPPING,ACTION_GRID_SNAPPING); } diff --git a/src/control/settings/Settings.cpp b/src/control/settings/Settings.cpp index d5630500..4d358caa 100644 --- a/src/control/settings/Settings.cpp +++ b/src/control/settings/Settings.cpp @@ -84,8 +84,6 @@ void Settings::loadDefault() this->addHorizontalSpace = false; this->addVerticalSpace = false; - this->enableLeafEnterWorkaround = true; - this->defaultSaveName = _("%F-Note-%H-%M"); // Eraser @@ -389,10 +387,6 @@ void Settings::parseItem(xmlDocPtr doc, xmlNodePtr cur) { this->addHorizontalSpace = xmlStrcmp(value, (const xmlChar*) "true") ? false : true; } - else if (xmlStrcmp(name, (const xmlChar*) "enableLeafEnterWorkaround") == 0) - { - this->enableLeafEnterWorkaround = xmlStrcmp(value, (const xmlChar*) "true") ? false : true; - } else if (xmlStrcmp(name, (const xmlChar*) "scrollbarHideType") == 0) { if (xmlStrcmp(value, (const xmlChar*) "both") == 0) @@ -727,10 +721,6 @@ void Settings::save() WRITE_BOOL_PROP(addHorizontalSpace); WRITE_BOOL_PROP(addVerticalSpace); - WRITE_BOOL_PROP(enableLeafEnterWorkaround); - WRITE_COMMENT("If Xournal++ crashes if you e.g. unplug your mouse set this to true. " - "If you have input problems, you can turn it of with false."); - WRITE_INT_PROP(selectionColor); WRITE_INT_PROP(backgroundColor); @@ -972,22 +962,6 @@ void Settings::setAddHorizontalSpace(bool space) this->addHorizontalSpace = space; } -bool Settings::isEnableLeafEnterWorkaround() -{ - XOJ_CHECK_TYPE(Settings); - - return this->enableLeafEnterWorkaround; -} - -void Settings::setEnableLeafEnterWorkaround(bool enable) -{ - XOJ_CHECK_TYPE(Settings); - - this->enableLeafEnterWorkaround = enable; - - save(); -} - bool Settings::isShowBigCursor() { XOJ_CHECK_TYPE(Settings); diff --git a/src/control/settings/Settings.h b/src/control/settings/Settings.h index 0c4cf253..9cd295c9 100644 --- a/src/control/settings/Settings.h +++ b/src/control/settings/Settings.h @@ -225,9 +225,6 @@ public: bool getAddHorizontalSpace(); void setAddHorizontalSpace(bool space); - bool isEnableLeafEnterWorkaround(); - void setEnableLeafEnterWorkaround(bool enable); - bool isShowBigCursor(); void setShowBigCursor(bool b); @@ -458,11 +455,6 @@ private: */ bool addVerticalSpace; - /** - * Enable Bugfix to prevent crash on GTK 2.18 etc - */ - bool enableLeafEnterWorkaround; - /** * Default name if you save a new document */ diff --git a/src/gui/widgets/XournalWidget.cpp b/src/gui/widgets/XournalWidget.cpp index 0fc57905..e06a7c3d 100644 --- a/src/gui/widgets/XournalWidget.cpp +++ b/src/gui/widgets/XournalWidget.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include diff --git a/src/util/XInputUtils.cpp b/src/util/XInputUtils.cpp deleted file mode 100644 index 934cb483..00000000 --- a/src/util/XInputUtils.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "XInputUtils.h" - -#include - -#include - -int XInputUtils::screenWidth = 0; -int XInputUtils::screenHeight = 0; -int XInputUtils::enableLeafEnterWorkaround = true; - -XInputUtils::XInputUtils() -{ -} - -XInputUtils::~XInputUtils() -{ -} - -void XInputUtils::initUtils(GtkWidget* win) -{ - GdkScreen* screen = gtk_widget_get_screen(win); - XInputUtils::screenWidth = gdk_screen_get_width(screen); - XInputUtils::screenHeight = gdk_screen_get_height(screen); -} - -void XInputUtils::setLeafEnterWorkaroundEnabled(bool enabled) -{ - if (XInputUtils::enableLeafEnterWorkaround == true && enabled == false) - { - XInputUtils::onMouseEnterNotifyEvent(NULL, NULL); - } - - XInputUtils::enableLeafEnterWorkaround = enabled; -} - -#define EPSILON 1E-7 - -void XInputUtils::handleScrollEvent(GdkEventButton* event, GtkWidget* widget) -{ - GdkEvent scrollEvent; - /* with GTK+ 2.17 and later, the entire widget hierarchy is xinput-aware, - so the core button event gets discarded and the scroll event never - gets processed by the main window. This is arguably a GTK+ bug. - We work around it. */ - - scrollEvent.scroll.type = GDK_SCROLL; - scrollEvent.scroll.window = event->window; - scrollEvent.scroll.send_event = event->send_event; - scrollEvent.scroll.time = event->time; - scrollEvent.scroll.x = event->x; - scrollEvent.scroll.y = event->y; - scrollEvent.scroll.state = event->state; - scrollEvent.scroll.device = event->device; - scrollEvent.scroll.x_root = event->x_root; - scrollEvent.scroll.y_root = event->y_root; - if (event->button == 4) - { - scrollEvent.scroll.direction = GDK_SCROLL_UP; - } - else if (event->button == 5) - { - scrollEvent.scroll.direction = GDK_SCROLL_DOWN; - } - else if (event->button == 6) - { - scrollEvent.scroll.direction = GDK_SCROLL_LEFT; - } - else - { - scrollEvent.scroll.direction = GDK_SCROLL_RIGHT; - } - gtk_widget_event(widget, &scrollEvent); -} - -// TODO Remove -gboolean XInputUtils::onMouseEnterNotifyEvent(GtkWidget* widget, GdkEventCrossing* event) -{ - return FALSE; -} - -// TODO Remove -gboolean XInputUtils::onMouseLeaveNotifyEvent(GtkWidget* widget, GdkEventCrossing* event) -{ - return FALSE; -} diff --git a/src/util/XInputUtils.h b/src/util/XInputUtils.h deleted file mode 100644 index d9891abd..00000000 --- a/src/util/XInputUtils.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Xournal++ - * - * XInput util functions - * - * @author Xournal++ Team - * https://github.com/xournalpp/xournalpp - * - * @license GNU GPLv2 or later - */ - -#pragma once - -#include - -#include - -#ifdef DEBUG_INPUT -#define INPUTDBG(msg, ...) printf("INPUT:: " msg, __VA_ARGS__); printf(" on %s:%i\n", __FILE__, __LINE__) -#define INPUTDBG2(msg) printf("INPUT:: " msg " on %s:%i\n", __FILE__, __LINE__) -#else -#define INPUTDBG(msg, ...) -#define INPUTDBG2(msg) -#endif - -class XInputUtils -{ -private: - XInputUtils(); - virtual ~XInputUtils(); - -public: - static void handleScrollEvent(GdkEventButton* event, GtkWidget* widget); - - /** - * Avoid crash if e.g. a mouse is plugged out... - */ - static gboolean onMouseEnterNotifyEvent(GtkWidget* widget, GdkEventCrossing* event); - static gboolean onMouseLeaveNotifyEvent(GtkWidget* widget, GdkEventCrossing* event); - - static void initUtils(GtkWidget* win); - - static void setLeafEnterWorkaroundEnabled(bool enabled); - -private: - static int screenWidth; - static int screenHeight; - - static int enableLeafEnterWorkaround; - -};