Hi Denis,
This is a patch to support "Use touch always as hand tool". The idea is
that if you have a stylus, then the stylus can be set to any tool, but
you can scroll with your hand.
It is not 100% bugfree. Sometimes linux and windows confuse the
events.
In Linux (not very frequent) all you have to do is move both devices
away (your hand and the stylus) for a couple of seconds, and try again.
In Windows (frequent), move both devices away, touch outside the canvas
(touch the scrollbar alone is sufficient) and then try again. One way to
avoid it is to move the stylus away before you use your hand. that
reduces the frequency of the problem.
I think the device for touch is OS dependent. On the windows tablet it
is "Core Pointer", in my (linux) thinkpad it is "touch". I defined a
macro in xournal.h to distinguish it and made it compilation dependent
on the WIN32 macro.
The attached patch does the following:
- implements the feature
- sets an option in the menu for this
- adds a variable for this ui.touch_as_handtool
- saves/restores it from the config file.
the core of the code is in on_canvas_button_press_event. You'll be able
to determine is this was the best way to do it ;)
This option alone was the reason I really wanted to be able to recompile
under windows.
diff --git a/src/main.c b/src/main.c
index e5962be..e9e60b0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -230,6 +230,8 @@ void init_stuff (int argc, char *argv[])
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsLeftHanded")), ui.left_handed);
gtk_check_menu_item_set_active(
+ GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsTouchAsHandTool")),
ui.touch_as_handtool);
+ gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsShortenMenus")),
ui.shorten_menus);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsAutoSavePrefs")),
ui.auto_save_prefs);
diff --git a/src/xo-callbacks.c b/src/xo-callbacks.c
index 054d2c4..138371a 100644
--- a/src/xo-callbacks.c
+++ b/src/xo-callbacks.c
@@ -2489,8 +2504,11 @@ on_canvas_button_press_event (GtkWidget
*widget,
if (ui.cur_layer == NULL) {
/* warn */
- dialog = gtk_message_dialog_new(GTK_WINDOW(winMain), GTK_DIALOG_MODAL,
- GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("Drawing is not allowed on the "
+ dialog = gtk_message_dialog_new(GTK_WINDOW(winMain),
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ _("Drawing is not allowed on the "
"background layer.\n Switching to Layer 1."));
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
@@ -2524,8 +2542,8 @@ on_canvas_button_press_event (GtkWidget
*widget,
reset_selection();
// process the event
-
- if (ui.toolno[mapping] == TOOL_HAND) {
+if (ui.toolno[mapping] == TOOL_HAND ||
+ (ui.touch_as_handtool && strstr(event->device->name, DEVICE_FOR_TOUCH)
!= NULL)) {
ui.cur_item_type = ITEM_HAND;
get_pointer_coords((GdkEvent *)event, ui.hand_refpt);
ui.hand_refpt[0] += ui.cur_page->hoffset;
@@ -3605,6 +3623,14 @@ on_optionsLeftHanded_activate (GtkMenuItem
*menuitem,
}
void
+on_optionsTouchAsHandTool_activate (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ end_text();
+ ui.touch_as_handtool = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
(menuitem));
+}
+
+void
on_optionsShortenMenus_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
diff --git a/src/xo-callbacks.h b/src/xo-callbacks.h
index 6b2768b..7a2be83 100644
--- a/src/xo-callbacks.h
+++ b/src/xo-callbacks.h
@@ -626,6 +626,10 @@ on_optionsLeftHanded_activate (GtkMenuItem
*menuitem,
gpointer user_data);
void
+on_optionsTouchAsHandTool_activate (GtkMenuItem *menuitem,
+ gpointer user_data);
+
+void
on_optionsShortenMenus_activate (GtkMenuItem *menuitem,
gpointer user_data);
diff --git a/src/xo-file.c b/src/xo-file.c
index cf2b77a..8dc8ac5 100644
--- a/src/xo-file.c
+++ b/src/xo-file.c
@@ -1664,6 +1664,9 @@ void save_config_to_file(void)
update_keyval("general", "interface_lefthanded",
_(" interface has left-handed scrollbar (true/false)"),
g_strdup(ui.left_handed?"true":"false"));
+ update_keyval("general", "touch_screen_as_hand_tool",
+ _(" always use the touch screen as the hand tool (true/false) requires
stylus tool to draw"),
+ g_strdup(ui.touch_as_handtool?"true":"false"));
update_keyval("general", "shorten_menus",
_(" hide some unwanted menu or toolbar items (true/false)"),
g_strdup(ui.shorten_menus?"true":"false"));
@@ -2042,6 +2045,7 @@ void load_config_from_file(void)
parse_keyval_vorderlist("general", "interface_order", ui.vertical_order[0]);
parse_keyval_vorderlist("general", "interface_fullscreen",
ui.vertical_order[1]);
parse_keyval_boolean("general", "interface_lefthanded", &ui.left_handed);
+ parse_keyval_boolean("general", "touch_screen_as_hand_tool",
&ui.touch_as_handtool);
parse_keyval_boolean("general", "shorten_menus", &ui.shorten_menus);
if (parse_keyval_string("general", "shorten_menu_items", &str))
if (str!=NULL) { g_free(ui.shorten_menu_items); ui.shorten_menu_items =
str; }
diff --git a/src/xo-interface.c b/src/xo-interface.c
index 3264d62..f4d5d44 100644
--- a/src/xo-interface.c
+++ b/src/xo-interface.c
@@ -251,6 +251,7 @@ create_winMain (void)
GtkWidget *optionsLeftHanded;
GtkWidget *optionsShortenMenus;
GtkWidget *optionsPenCursor;
+ GtkWidget *optionsTouchAsHandTool;
GtkWidget *separator21;
GtkWidget *optionsAutoSavePrefs;
GtkWidget *optionsSavePreferences;
@@ -1399,6 +1400,10 @@ create_winMain (void)
gtk_widget_show (optionsLeftHanded);
gtk_container_add (GTK_CONTAINER (menuOptions_menu), optionsLeftHanded);
+ optionsTouchAsHandTool = gtk_check_menu_item_new_with_mnemonic (_("Always
use _Touch screen as hand tool"));
+ gtk_widget_show (optionsTouchAsHandTool);
+ gtk_container_add (GTK_CONTAINER (menuOptions_menu), optionsTouchAsHandTool);
+
optionsShortenMenus = gtk_check_menu_item_new_with_mnemonic (_("Shorten
_Menus"));
gtk_widget_show (optionsShortenMenus);
gtk_container_add (GTK_CONTAINER (menuOptions_menu), optionsShortenMenus);
@@ -2395,6 +2400,9 @@ create_winMain (void)
g_signal_connect ((gpointer) optionsLeftHanded, "toggled",
G_CALLBACK (on_optionsLeftHanded_activate),
NULL);
+ g_signal_connect ((gpointer) optionsTouchAsHandTool, "activate",
+ G_CALLBACK (on_optionsTouchAsHandTool_activate),
+ NULL);
g_signal_connect ((gpointer) optionsShortenMenus, "toggled",
G_CALLBACK (on_optionsShortenMenus_activate),
NULL);
@@ -2769,6 +2777,7 @@ create_winMain (void)
GLADE_HOOKUP_OBJECT (winMain, optionsPrintRuling, "optionsPrintRuling");
GLADE_HOOKUP_OBJECT (winMain, optionsAutoloadPdfXoj,
"optionsAutoloadPdfXoj");
GLADE_HOOKUP_OBJECT (winMain, optionsLeftHanded, "optionsLeftHanded");
+ GLADE_HOOKUP_OBJECT (winMain, optionsTouchAsHandTool,
"optionsTouchAsHandTool");
GLADE_HOOKUP_OBJECT (winMain, optionsShortenMenus, "optionsShortenMenus");
GLADE_HOOKUP_OBJECT (winMain, optionsPenCursor, "optionsPenCursor");
GLADE_HOOKUP_OBJECT (winMain, separator21, "separator21");
diff --git a/src/xournal.h b/src/xournal.h
index 8a1036b..885842f 100644
--- a/src/xournal.h
+++ b/src/xournal.h
@@ -43,8 +43,10 @@
#ifdef WIN32
#define VERSION_STRING VERSION "-win32"
+#define DEVICE_FOR_TOUCH "Core Pointer"
#else
#define VERSION_STRING VERSION
+#define DEVICE_FOR_TOUCH "touch"
#endif
// DATA STRUCTURES AND CONSTANTS
@@ -313,6 +315,7 @@ typedef struct UIData {
gdouble hiliter_opacity;
guint hiliter_alpha_mask;
gboolean left_handed; // left-handed mode?
+ gboolean touch_as_handtool; // do we always use the touch screen as handtool
gboolean auto_save_prefs; // auto-save preferences ?
gboolean shorten_menus; // shorten menus ?
gchar *shorten_menu_items; // which items to hide
--
Daniel M. German "We die. That may be the meaning of life.
But we do language. That may be
Toni Morrison -> the measure of our lives."
http://turingmachine.org/
http://silvernegative.com/
dmg (at) uvic (dot) ca
replace (at) with @ and (dot) with .
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Xournal-devel mailing list
Xournal-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xournal-devel