diff options
author | László Németh <laszlo.nemeth@collabora.com> | 2015-11-06 19:26:29 +0100 |
---|---|---|
committer | László Németh <laszlo.nemeth@collabora.com> | 2015-11-06 19:33:14 +0100 |
commit | 63d2d50ecb3f3a83374a1a01713edce14ba378ed (patch) | |
tree | fcd04be9b2b5c0ce24f8e87b20c0577eba03ebe5 | |
parent | 51c14b1c262bced0cb61c943caad044be9e95c15 (diff) |
gtktiledviewer: add Ctrl, Alt, Shift shortcut support
For example in Writer:
Ctrl-B for bold text
Ctrl-Shift-B/P for subscript/superscript
Ctrl-Alt-C insert comment
Ctrl-1 apply Heading 1 paragraph style
Change-Id: Iaeb8341f2cb273980b637ff2fed89585094e0d9d
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 9aaa5eff1b79..475f388d53f8 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -337,7 +337,7 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent) return FALSE; } - priv->m_nKeyModifier = 0; + priv->m_nKeyModifier &= KEY_MOD2; switch (pEvent->keyval) { case GDK_KEY_BackSpace: @@ -381,6 +381,8 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent) case GDK_KEY_Alt_R: if (pEvent->type == GDK_KEY_PRESS) priv->m_nKeyModifier |= KEY_MOD2; + else + priv->m_nKeyModifier &= ~KEY_MOD2; break; default: if (pEvent->keyval >= GDK_KEY_F1 && pEvent->keyval <= GDK_KEY_F26) @@ -395,6 +397,25 @@ signalKey (GtkWidget* pWidget, GdkEventKey* pEvent) if (pEvent->state & GDK_SHIFT_MASK) nKeyCode |= KEY_SHIFT; + if (pEvent->state & GDK_CONTROL_MASK) + nKeyCode |= KEY_MOD1; + + if (priv->m_nKeyModifier & KEY_MOD2) + nKeyCode |= KEY_MOD2; + + if (nKeyCode & (KEY_SHIFT | KEY_MOD1 | KEY_MOD2)) { + if (pEvent->keyval >= GDK_KEY_a && pEvent->keyval <= GDK_KEY_z) + { + nKeyCode |= 512 + (pEvent->keyval - GDK_KEY_a); + } + else if (pEvent->keyval >= GDK_KEY_A && pEvent->keyval <= GDK_KEY_Z) { + nKeyCode |= 512 + (pEvent->keyval - GDK_KEY_A); + } + else if (pEvent->keyval >= GDK_KEY_0 && pEvent->keyval <= GDK_KEY_9) { + nKeyCode |= 256 + (pEvent->keyval - GDK_KEY_0); + } + } + if (pEvent->type == GDK_KEY_RELEASE) { GTask* task = g_task_new(pDocView, NULL, NULL, NULL); |