Merge pull request #590 from andreasb242/master

Removed dead GTK2 Code
presentation
andreasb242 7 years ago committed by GitHub
commit d38382b99d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/control/Control.cpp
  2. 26
      src/control/settings/Settings.cpp
  3. 8
      src/control/settings/Settings.h
  4. 1
      src/gui/widgets/XournalWidget.cpp
  5. 85
      src/util/XInputUtils.cpp
  6. 51
      src/util/XInputUtils.h

@ -51,7 +51,6 @@ extern int currentToolType;
#include <serializing/ObjectInputStream.h>
#include <Stacktrace.h>
#include <Util.h>
#include <XInputUtils.h>
#include <boost/filesystem.hpp>
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);
}

@ -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);

@ -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
*/

@ -13,7 +13,6 @@
#include <config-debug.h>
#include <Rectangle.h>
#include <Util.h>
#include <XInputUtils.h>
#include <gdk/gdk.h>

@ -1,85 +0,0 @@
#include "XInputUtils.h"
#include <config-dev.h>
#include <math.h>
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;
}

@ -1,51 +0,0 @@
/*
* Xournal++
*
* XInput util functions
*
* @author Xournal++ Team
* https://github.com/xournalpp/xournalpp
*
* @license GNU GPLv2 or later
*/
#pragma once
#include <config-debug.h>
#include <gtk/gtk.h>
#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;
};
Loading…
Cancel
Save