From 800816379ee4458930b2f03bd318a3a697d933bb Mon Sep 17 00:00:00 2001
From: yzykov <yzykov97@gmail.com>
Date: Fri, 27 Mar 2020 21:22:18 -0700
Subject: [PATCH 1/2] =?UTF-8?q?GSOC2020:=20Ctrl-shift-U=20does=20not=20wor?=
 =?UTF-8?q?k=20work=20when=20editor=20is=20focused=C2=A0#9895?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/src/processing/app/Editor.java | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java
index 2ec29c498cb..e2ad9575150 100644
--- a/app/src/processing/app/Editor.java
+++ b/app/src/processing/app/Editor.java
@@ -169,6 +169,9 @@ public boolean test(SketchController controller) {
   /** Command-Option on Mac OS X, Ctrl-Alt on Windows and Linux */
   static final int SHORTCUT_ALT_KEY_MASK = ActionEvent.ALT_MASK |
     Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
+  /** Command-Option on Mac OS X, Ctrl-Shift on Windows and Linux */
+  static final int SHORTCUT_SHIFT_KEY_MASK = ActionEvent.SHIFT_MASK |
+    Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
 
   /**
    * true if this file has not yet been given a name by the user
@@ -670,7 +673,15 @@ private void buildSketchMenu(JMenu sketchMenu) {
     item.addActionListener(event -> handleExport(false));
     sketchMenu.add(item);
 
-    item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
+//  Since CTRL+SHIFT+U is not working on iBus keyboard input method
+//  Lets redirect the shorcut for Linux to CTRL+ALT+U
+//  Leaving the preexisting behaviour for Windows & Mac OS
+    String OS = System.getProperty("os.name").toLowerCase();
+    if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0){
+      item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U');
+    } else {
+      item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');
+    }
     item.addActionListener(event -> handleExport(true));
     sketchMenu.add(item);
 
@@ -1350,7 +1361,7 @@ static public JMenuItem newJMenuItem(String title, int what) {
   // Control + Shift + K seems to not be working on linux (Xubuntu 17.04, 2017-08-19)
   static public JMenuItem newJMenuItemShift(String title, int what) {
     JMenuItem menuItem = new JMenuItem(title);
-    menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_KEY_MASK | ActionEvent.SHIFT_MASK));
+    menuItem.setAccelerator(KeyStroke.getKeyStroke(what, SHORTCUT_SHIFT_KEY_MASK));
     return menuItem;
   }
 

From 1ab1651bbee4e8e5e706b6ddb02ef3dd4ec978f7 Mon Sep 17 00:00:00 2001
From: yzykov <yzykov97@gmail.com>
Date: Sun, 26 Apr 2020 19:11:03 -0700
Subject: [PATCH 2/2] OS recognition using helpers

---
 app/src/processing/app/Editor.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java
index e2ad9575150..777e08e1d00 100644
--- a/app/src/processing/app/Editor.java
+++ b/app/src/processing/app/Editor.java
@@ -676,8 +676,7 @@ private void buildSketchMenu(JMenu sketchMenu) {
 //  Since CTRL+SHIFT+U is not working on iBus keyboard input method
 //  Lets redirect the shorcut for Linux to CTRL+ALT+U
 //  Leaving the preexisting behaviour for Windows & Mac OS
-    String OS = System.getProperty("os.name").toLowerCase();
-    if (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") >= 0){
+    if (OSUtils.isLinux()) {
       item = newJMenuItemAlt(tr("Upload Using Programmer"), 'U');
     } else {
       item = newJMenuItemShift(tr("Upload Using Programmer"), 'U');