[Libreoffice-commits] core.git: vcl/unx

Caolán McNamara caolanm at redhat.com
Wed Sep 7 21:18:46 UTC 2016


 vcl/unx/generic/app/saldisp.cxx |   22 ++++++++++++++++++----
 vcl/unx/gtk/gtksalframe.cxx     |   22 ++++++++++++++++++++++
 vcl/unx/gtk3/gtk3gtkframe.cxx   |   22 ++++++++++++++++++++++
 3 files changed, 62 insertions(+), 4 deletions(-)

New commits:
commit 1c2ac71f80e271a6352384e0bce8c8f432bf37f6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Sep 7 22:03:21 2016 +0100

    Resolves: tdf#100443 handle sun keyboard copy/cut/paste keys
    
    Thanks to Charles Lindsey for these suggested changes
    
    Change-Id: I22d14f16ee560f189c40ba0b143718278e0a8b7d

diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx
index 6355303..881827b 100644
--- a/vcl/unx/generic/app/saldisp.cxx
+++ b/vcl/unx/generic/app/saldisp.cxx
@@ -908,6 +908,8 @@ OUString SalDisplay::GetKeyName( sal_uInt16 nKeyCode ) const
             break;
 
         #if !defined (SunXK_Undo)
+            // we don't intend to use SunXK_Undo, but if it has not been
+            // defined already, then we _do_ need the following:
             #define SunXK_Props     0x1005FF70
             #define SunXK_Front     0x1005FF71
             #define SunXK_Copy      0x1005FF72
@@ -915,6 +917,12 @@ OUString SalDisplay::GetKeyName( sal_uInt16 nKeyCode ) const
             #define SunXK_Paste     0x1005FF74
             #define SunXK_Cut       0x1005FF75
         #endif
+            // the following are for XF86 systems
+            #define XF86XK_Copy     0x1008FF57
+            #define XF86XK_Cut      0x1008FF58
+            #define XF86XK_Open     0x1008FF6B
+            #define XF86XK_Paste    0x1008FF6D
+            // which leaves Apollo and OSF systems in the lurch
 
         case KEY_REPEAT:
             nKeySym = XK_Redo;
@@ -929,19 +937,25 @@ OUString SalDisplay::GetKeyName( sal_uInt16 nKeyCode ) const
             nKeySym = SunXK_Front;
             break;
         case KEY_COPY:
-            nKeySym = SunXK_Copy;
+            nKeySym = GetServerVendor() == vendor_sun ? SunXK_Copy : XF86XK_Copy;
             break;
         case KEY_OPEN:
-            nKeySym = SunXK_Open;
+            nKeySym = GetServerVendor() == vendor_sun ? SunXK_Open : XF86XK_Open;
             break;
         case KEY_PASTE:
-            nKeySym = SunXK_Paste;
+            nKeySym = GetServerVendor() == vendor_sun ? SunXK_Paste : XF86XK_Paste;
             break;
         case KEY_FIND:
             nKeySym = XK_Find;
             break;
         case KEY_CUT:
+            nKeySym = GetServerVendor() == vendor_sun ? SunXK_Cut : XF86XK_Cut;
+            /* The original code here had:
             nKeySym = GetServerVendor() == vendor_sun ? SunXK_Cut   : XK_L10;
+            if anyone can remember which non-vendor_sun system used this
+            XK_L10 keysym, and why this hack only applied to KEY_CUT,
+            then please re-hack this code to put it back
+            */
             break;
         case KEY_ADD:
             aCustomKeyName = "+";
@@ -1163,7 +1177,7 @@ sal_uInt16 SalDisplay::GetKeyCode( KeySym keysym, char*pcPrintable ) const
             // - - - - - Sun X-Server keyboard ??? - - - - - - - - - - - -
             case XK_L1: // XK_F11:
                 nKey = KEY_F11; // on a sun keyboard this actually is usually SunXK_Stop = 0x0000FF69 (XK_Cancel),
-                // but VCL doesn't have a key definition for that
+                                // but VCL doesn't have a key definition for that
                 break;
             case XK_L2: // XK_F12:
                 if ( GetServerVendor() == vendor_sun )
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 1d46e7b8..0d872cf 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -136,6 +136,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
     else if( keyval >= GDK_KEY_a && keyval <= GDK_KEY_z )
         nCode = KEY_A + (keyval-GDK_KEY_a );
     else if( keyval >= GDK_KEY_F1 && keyval <= GDK_KEY_F26 )
+    // KEY_F26 is the last function key known to keycodes.hxx
     {
         if( GetGtkSalData()->GetGtkDisplay()->IsNumLockFromXS() )
         {
@@ -146,6 +147,10 @@ static sal_uInt16 GetKeyCode( guint keyval )
             switch( keyval )
             {
                 // - - - - - Sun keyboard, see vcl/unx/source/app/saldisp.cxx
+                // althopugh GDK_KEY_F1 ... GDK_KEY_L10 are known to
+                // gdk/gdkkeysyms.h, they are unlikely to be generated
+                // except possibly by Solaris systems
+                // this whole section needs review
                 case GDK_KEY_L2:
                     if( GetGtkSalData()->GetGtkDisplay()->GetServerVendor() == vendor_sun )
                         nCode = KEY_REPEAT;
@@ -217,6 +222,9 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case GDK_KEY_Help:          nCode = KEY_HELP;       break;
             case GDK_KEY_Undo:          nCode = KEY_UNDO;       break;
             case GDK_KEY_Redo:          nCode = KEY_REPEAT;     break;
+            // on a sun keyboard this actually is usually SunXK_Stop = 0x0000FF69 (XK_Cancel),
+            // but VCL doesn't have a key definition for that
+            case GDK_KEY_Cancel:        nCode = KEY_F11;        break;
             case GDK_KEY_KP_Decimal:
             case GDK_KEY_KP_Separator:  nCode = KEY_DECIMAL;    break;
             case GDK_KEY_asciitilde:    nCode = KEY_TILDE;      break;
@@ -228,6 +236,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case GDK_KEY_quoteright:   nCode = KEY_QUOTERIGHT;   break;
             // some special cases, also see saldisp.cxx
             // - - - - - - - - - - - - -  Apollo - - - - - - - - - - - - - 0x1000
+            // These can be found in ap_keysym.h
             case 0x1000FF02: // apXK_Copy
                 nCode = KEY_COPY;
                 break;
@@ -242,10 +251,12 @@ static sal_uInt16 GetKeyCode( guint keyval )
                 break;
             // Exit, Save
             // - - - - - - - - - - - - - - D E C - - - - - - - - - - - - - 0x1000
+            // These can be found in DECkeysym.h
             case 0x1000FF00:
                 nCode = KEY_DELETE;
                 break;
             // - - - - - - - - - - - - - -  H P  - - - - - - - - - - - - - 0x1000
+            // These can be found in HPkeysym.h
             case 0x1000FF73: // hpXK_DeleteChar
                 nCode = KEY_DELETE;
                 break;
@@ -255,6 +266,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
                 break;
             // - - - - - - - - - - - - - - I B M - - - - - - - - - - - - -
             // - - - - - - - - - - - - - - O S F - - - - - - - - - - - - - 0x1004
+            // These also can be found in HPkeysym.h
             case 0x1004FF02: // osfXK_Copy
                 nCode = KEY_COPY;
                 break;
@@ -278,6 +290,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
             // - - - - - - - - - - - - - - S G I - - - - - - - - - - - - - 0x1007
             // - - - - - - - - - - - - - - S N I - - - - - - - - - - - - -
             // - - - - - - - - - - - - - - S U N - - - - - - - - - - - - - 0x1005
+            // These can be found in Sunkeysym.h
             case 0x1005FF10: // SunXK_F36
                 nCode = KEY_F11;
                 break;
@@ -302,6 +315,15 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case 0x1005FF75: // SunXK_Cut
                 nCode = KEY_CUT;
                 break;
+            // - - - - - - - - - - - - - X F 8 6 - - - - - - - - - - - - - 0x1008
+            // These can be found in XF86keysym.h
+            // but more importantly they are also available GTK/Gdk version 3
+            // and hence are already provided in gdk/gdkkeysyms.h, and hence
+            // in gdk/gdk.h
+            case GDK_KEY_Copy:          nCode = KEY_COPY;  break; // 0x1008ff57
+            case GDK_KEY_Cut:           nCode = KEY_CUT;   break; // 0x1008ff58
+            case GDK_KEY_Open:          nCode = KEY_OPEN;  break; // 0x1008ff6b
+            case GDK_KEY_Paste:         nCode = KEY_PASTE; break; // 0x1008ff6d
         }
     }
 
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 01bf6be..bdf0867 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -149,10 +149,15 @@ static sal_uInt16 GetKeyCode( guint keyval )
     else if( keyval >= GDK_KEY_a && keyval <= GDK_KEY_z )
         nCode = KEY_A + (keyval-GDK_KEY_a );
     else if( keyval >= GDK_KEY_F1 && keyval <= GDK_KEY_F26 )
+    // KEY_F26 is the last function key known to keycodes.hxx
     {
         switch( keyval )
         {
             // - - - - - Sun keyboard, see vcl/unx/source/app/saldisp.cxx
+            // althopugh GDK_KEY_F1 ... GDK_KEY_L10 are known to
+            // gdk/gdkkeysyms.h, they are unlikely to be generated
+            // except possibly by Solaris systems
+            // this whole section needs review
             case GDK_KEY_L2:
                     nCode = KEY_F12;
                 break;
@@ -220,6 +225,9 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case GDK_KEY_Help:          nCode = KEY_HELP;       break;
             case GDK_KEY_Undo:          nCode = KEY_UNDO;       break;
             case GDK_KEY_Redo:          nCode = KEY_REPEAT;     break;
+            // on a sun keyboard this actually is usually SunXK_Stop = 0x0000FF69 (XK_Cancel),
+            // but VCL doesn't have a key definition for that
+            case GDK_KEY_Cancel:        nCode = KEY_F11;        break;
             case GDK_KEY_KP_Decimal:
             case GDK_KEY_KP_Separator:  nCode = KEY_DECIMAL;    break;
             case GDK_KEY_asciitilde:    nCode = KEY_TILDE;      break;
@@ -231,6 +239,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case GDK_KEY_quoteright:   nCode = KEY_QUOTERIGHT;   break;
             // some special cases, also see saldisp.cxx
             // - - - - - - - - - - - - -  Apollo - - - - - - - - - - - - - 0x1000
+            // These can be found in ap_keysym.h
             case 0x1000FF02: // apXK_Copy
                 nCode = KEY_COPY;
                 break;
@@ -245,10 +254,12 @@ static sal_uInt16 GetKeyCode( guint keyval )
                 break;
             // Exit, Save
             // - - - - - - - - - - - - - - D E C - - - - - - - - - - - - - 0x1000
+            // These can be found in DECkeysym.h
             case 0x1000FF00:
                 nCode = KEY_DELETE;
                 break;
             // - - - - - - - - - - - - - -  H P  - - - - - - - - - - - - - 0x1000
+            // These can be found in HPkeysym.h
             case 0x1000FF73: // hpXK_DeleteChar
                 nCode = KEY_DELETE;
                 break;
@@ -258,6 +269,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
                 break;
             // - - - - - - - - - - - - - - I B M - - - - - - - - - - - - -
             // - - - - - - - - - - - - - - O S F - - - - - - - - - - - - - 0x1004
+            // These also can be found in HPkeysym.h
             case 0x1004FF02: // osfXK_Copy
                 nCode = KEY_COPY;
                 break;
@@ -281,6 +293,7 @@ static sal_uInt16 GetKeyCode( guint keyval )
             // - - - - - - - - - - - - - - S G I - - - - - - - - - - - - - 0x1007
             // - - - - - - - - - - - - - - S N I - - - - - - - - - - - - -
             // - - - - - - - - - - - - - - S U N - - - - - - - - - - - - - 0x1005
+            // These can be found in Sunkeysym.h
             case 0x1005FF10: // SunXK_F36
                 nCode = KEY_F11;
                 break;
@@ -305,6 +318,15 @@ static sal_uInt16 GetKeyCode( guint keyval )
             case 0x1005FF75: // SunXK_Cut
                 nCode = KEY_CUT;
                 break;
+            // - - - - - - - - - - - - - X F 8 6 - - - - - - - - - - - - - 0x1008
+            // These can be found in XF86keysym.h
+            // but more importantly they are also available GTK/Gdk version 3
+            // and hence are already provided in gdk/gdkkeysyms.h, and hence
+            // in gdk/gdk.h
+            case GDK_KEY_Copy:          nCode = KEY_COPY;  break; // 0x1008ff57
+            case GDK_KEY_Cut:           nCode = KEY_CUT;   break; // 0x1008ff58
+            case GDK_KEY_Open:          nCode = KEY_OPEN;  break; // 0x1008ff6b
+            case GDK_KEY_Paste:         nCode = KEY_PASTE; break; // 0x1008ff6d
         }
     }
 


More information about the Libreoffice-commits mailing list