Fixed Bug 810211 - Cancel Control + space pressing Control key.

This commit is contained in:
Takao Fujiwara 2012-05-18 19:08:00 +09:00
parent 592233612e
commit 2f7b82ca3f
7 changed files with 270 additions and 64 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@ ibus-1.3.6.tar.gz
/ibus-gjs-3.3.90.20120317.tar.gz
/ibus-gjs-3.3.92.20120327.tar.gz
/ibus-gjs-3.4.1.20120428.tar.gz
/ibus-gjs-3.4.1.20120518.tar.gz

View File

@ -1,6 +1,6 @@
From 5de26fdf6f300a4e532a39f8c3778e94ff629125 Mon Sep 17 00:00:00 2001
From 8115592c491ed0bfd60df15d109dda2d7ae1dbc0 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Sat, 28 Apr 2012 13:07:30 +0900
Date: Wed, 9 May 2012 19:23:11 +0900
Subject: [PATCH] Add ibus-xkb and libgnomekbd.
---
@ -10,23 +10,25 @@ Subject: [PATCH] Add ibus-xkb and libgnomekbd.
engine/Makefile.am | 20 ++
engine/ibus-xkb-main.c | 111 +++++++++
engine/main.vala | 86 +++++++
engine/simple.xml.in.in | 531 +----------------------------------------
engine/simple.xml.in.in | 531 +---------------------------------------
engine/xkblib.c | 327 +++++++++++++++++++++++++
engine/xkblib.h | 41 ++++
ibus-1.0.pc.in | 4 +
setup/main.py | 25 +-
src/Makefile.am | 5 +
src/ibus.h | 1 +
src/ibusxkbxml.c | 466 ++++++++++++++++++++++++++++++++++++
src/ibusxkbxml.h | 187 +++++++++++++++
src/ibusxkbxml.c | 466 +++++++++++++++++++++++++++++++++++
src/ibusxkbxml.h | 187 ++++++++++++++
ui/gtk3/Gkbd-3.0.metadata | 1 +
ui/gtk3/Makefile.am | 48 ++++
ui/gtk3/Xkl-1.0.metadata | 3 +
ui/gtk3/gkbdlayout.vala.false | 63 +++++
ui/gtk3/gkbdlayout.vala.true | 111 +++++++++
ui/gtk3/panel.vala | 275 +++++++++++++++++++--
ui/gtk3/xkblayout.vala | 466 ++++++++++++++++++++++++++++++++++++
22 files changed, 2380 insertions(+), 555 deletions(-)
ui/gtk3/keybindingmanager.vala | 4 +
ui/gtk3/panel.vala | 279 +++++++++++++++++++--
ui/gtk3/switcher.vala | 53 +++-
ui/gtk3/xkblayout.vala | 466 +++++++++++++++++++++++++++++++++++
24 files changed, 2433 insertions(+), 563 deletions(-)
create mode 100644 engine/ibus-xkb-main.c
create mode 100644 engine/xkblib.c
create mode 100644 engine/xkblib.h
@ -2472,11 +2474,26 @@ index 0000000..adacd81
+ }
+ */
+}
diff --git a/ui/gtk3/keybindingmanager.vala b/ui/gtk3/keybindingmanager.vala
index dd3c7bd..4459ab2 100644
--- a/ui/gtk3/keybindingmanager.vala
+++ b/ui/gtk3/keybindingmanager.vala
@@ -133,6 +133,10 @@ public class KeybindingManager : GLib.Object {
m_bindings.remove (binding);
}
+ public GLib.List get_keybindings() {
+ return m_bindings.copy();
+ }
+
public static KeybindingManager get_instance () {
if (m_instance == null)
m_instance = new KeybindingManager ();
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index 251a65e..c08f188 100644
index 251a65e..ff83284 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -41,8 +41,16 @@ class Panel : IBus.PanelService {
@@ -41,8 +41,17 @@ class Panel : IBus.PanelService {
private GLib.Pid m_setup_pid = 0;
private Gtk.AboutDialog m_about_dialog;
private Gtk.CssProvider m_css_provider;
@ -2487,13 +2504,14 @@ index 251a65e..c08f188 100644
+ private int m_fallback_lock_id = -1;
+ private bool m_changed_xkb_option = false;
+ private GLib.Timer m_changed_layout_timer;
+ private GLib.List m_keybindings;
private const string ACCELERATOR_SWITCH_IME_FOREWARD = "<Control>space";
private const string ACCELERATOR_SWITCH_IME_BACKWARD = "<Control><Shift>space";
+ private string[] ACCELERATOR_IME_HOTKEYS = {};
public Panel(IBus.Bus bus) {
GLib.assert(bus.is_connected());
@@ -66,13 +74,6 @@ class Panel : IBus.PanelService {
@@ -66,13 +75,6 @@ class Panel : IBus.PanelService {
m_switcher = new Switcher();
@ -2507,7 +2525,7 @@ index 251a65e..c08f188 100644
m_property_manager = new PropertyManager();
m_property_manager.property_activate.connect((k, s) => {
property_activate(k, s);
@@ -83,8 +84,66 @@ class Panel : IBus.PanelService {
@@ -83,8 +85,67 @@ class Panel : IBus.PanelService {
~Panel() {
var keybinding_manager = KeybindingManager.get_instance();
@ -2573,10 +2591,11 @@ index 251a65e..c08f188 100644
+ (e) => handle_engine_switch(e, true));
+ }
+ }
+ m_keybindings = keybinding_manager.get_keybindings();
}
private void set_custom_font() {
@@ -152,12 +211,14 @@ class Panel : IBus.PanelService {
@@ -152,12 +213,14 @@ class Panel : IBus.PanelService {
}
m_config = config;
@ -2591,7 +2610,7 @@ index 251a65e..c08f188 100644
update_engines(m_config.get_value("general", "preload_engines"),
m_config.get_value("general", "engines_order"));
} else {
@@ -167,6 +228,192 @@ class Panel : IBus.PanelService {
@@ -167,6 +230,192 @@ class Panel : IBus.PanelService {
set_custom_font();
}
@ -2784,7 +2803,7 @@ index 251a65e..c08f188 100644
private void switch_engine(int i, bool force = false) {
GLib.assert(i >= 0 && i < m_engines.length);
@@ -186,15 +433,7 @@ class Panel : IBus.PanelService {
@@ -186,15 +435,7 @@ class Panel : IBus.PanelService {
return;
}
// set xkb layout
@ -2801,6 +2820,110 @@ index 251a65e..c08f188 100644
string[] names = {};
foreach(var desc in m_engines) {
@@ -234,7 +475,7 @@ class Panel : IBus.PanelService {
event, primary_modifiers);
if (pressed) {
int i = revert ? m_engines.length - 1 : 1;
- i = m_switcher.run(event, m_engines, i);
+ i = m_switcher.run(event, m_engines, i, m_keybindings);
if (i < 0) {
debug("switch cancelled");
} else {
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
index 81812ec..52b0577 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
@@ -23,14 +23,42 @@
using IBus;
using GLib;
using Gtk;
+using Gdk;
class Switcher : Gtk.Window {
+ private class Keybinding {
+ public Keybinding(string accelerator,
+ uint keysym,
+ Gdk.ModifierType modifiers) {
+ this.accelerator = accelerator;
+ this.keysym = keysym;
+ this.modifiers = modifiers;
+ }
+
+ public string accelerator { get; set; }
+ public uint keysym { get; set; }
+ public Gdk.ModifierType modifiers { get; set; }
+ }
+
+ public static const uint MODIFIER_FILTER =
+ Gdk.ModifierType.MODIFIER_MASK & ~(
+ Gdk.ModifierType.MOD2_MASK |
+ Gdk.ModifierType.LOCK_MASK |
+ Gdk.ModifierType.MOD4_MASK |
+ Gdk.ModifierType.MOD5_MASK |
+ Gdk.ModifierType.BUTTON1_MASK |
+ Gdk.ModifierType.BUTTON2_MASK |
+ Gdk.ModifierType.BUTTON3_MASK |
+ Gdk.ModifierType.BUTTON4_MASK |
+ Gdk.ModifierType.BUTTON5_MASK);
+
private Gtk.Box m_box;
private Gtk.Button[] m_buttons = {};
private IBus.EngineDesc[] m_engines;
private uint m_selected_engine;
private uint m_primary_modifier;
private GLib.MainLoop m_loop;
+ private unowned GLib.List<Keybinding> m_keybindings;
private int m_result;
public Switcher() {
@@ -49,7 +77,7 @@ class Switcher : Gtk.Window {
grab_focus();
}
- public int run(Gdk.Event event, IBus.EngineDesc[] engines, int index) {
+ public int run(Gdk.Event event, IBus.EngineDesc[] engines, int index, GLib.List keybindings) {
assert (m_loop == null);
assert (index < engines.length);
@@ -61,6 +89,7 @@ class Switcher : Gtk.Window {
m_result = 0;
m_selected_engine = index;
m_buttons[index].grab_focus();
+ m_keybindings = (GLib.List<Keybinding>) keybindings;
Gdk.Device device = event.get_device();
if (device == null) {
@@ -219,14 +248,24 @@ class Switcher : Gtk.Window {
public override bool key_press_event(Gdk.EventKey e) {
Gdk.EventKey *pe = &e;
- switch (pe->keyval) {
- case 0x0020: /* space */
- case 0xff80: /* KP_Space */
- if ((pe->state & Gdk.ModifierType.SHIFT_MASK) == 0)
+ Gdk.ModifierType state = pe->state & MODIFIER_FILTER;
+
+ for (unowned GLib.List<Keybinding> keybindings = m_keybindings;
+ keybindings != null;
+ keybindings = keybindings.next) {
+ Keybinding keybinding = keybindings.data;
+ if (pe->keyval == keybinding.keysym &&
+ state == keybinding.modifiers) {
+ if ((state & Gdk.ModifierType.SHIFT_MASK) == 0) {
next_engine();
- else
+ } else {
previous_engine();
- break;
+ }
+ return true;
+ }
+ }
+
+ switch (pe->keyval) {
case 0x08fb: /* leftarrow */
case 0xff51: /* Down */
break;
diff --git a/ui/gtk3/xkblayout.vala b/ui/gtk3/xkblayout.vala
new file mode 100644
index 0000000..8b75387

View File

@ -1 +1,37 @@
From 469335730bb9dc7ba1702cfc5108491b6993677b Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 9 May 2012 17:09:23 +0900
Subject: [PATCH] Fix not to switch engines by non-trigger keys.
---
ui/gtk3/switcher.vala | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
index 73b58d2..81812ec 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
@@ -58,6 +58,7 @@ class Switcher : Gtk.Window {
event.key.state & KeybindingManager.MODIFIER_FILTER);
update_engines(engines);
+ m_result = 0;
m_selected_engine = index;
m_buttons[index].grab_focus();
@@ -242,7 +243,11 @@ class Switcher : Gtk.Window {
break;
default:
debug("0x%04x", pe->keyval);
- break;
+ if (m_loop != null) {
+ m_loop.quit();
+ m_loop = null;
+ }
+ return false;
}
return true;
}
--
1.7.10

View File

@ -1,27 +1,34 @@
--- ibus-1.4.99.20120428/ui/gtk3/switcher.vala.orig 2012-04-28 13:49:41.000000000 +0900
+++ ibus-1.4.99.20120428/ui/gtk3/switcher.vala 2012-04-28 16:26:16.595996905 +0900
@@ -23,15 +23,20 @@
using IBus;
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
index 52b0577..7821221 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
@@ -24,6 +24,8 @@ using IBus;
using GLib;
using Gtk;
using Gdk;
+using Pango;
+using Atk;
class Switcher : Gtk.Window {
private class Keybinding {
@@ -53,6 +55,7 @@ class Switcher : Gtk.Window {
Gdk.ModifierType.BUTTON5_MASK);
private Gtk.Box m_box;
+ private Gtk.Label m_label;
private Gtk.Button[] m_buttons = {};
private IBus.EngineDesc[] m_engines;
private uint m_selected_engine;
private uint m_primary_modifier;
@@ -60,6 +63,8 @@ class Switcher : Gtk.Window {
private GLib.MainLoop m_loop;
private unowned GLib.List<Keybinding> m_keybindings;
private int m_result;
+ private int m_default_font_size = 16;
+ private const int m_desc_label_max_len = 20;
public Switcher() {
GLib.Object(
@@ -43,8 +48,23 @@ class Switcher : Gtk.Window {
@@ -71,8 +76,23 @@ class Switcher : Gtk.Window {
modal : true,
focus_visible : true
);
@ -47,15 +54,15 @@
grab_focus();
}
@@ -59,6 +79,7 @@ class Switcher : Gtk.Window {
@@ -88,6 +108,7 @@ class Switcher : Gtk.Window {
update_engines(engines);
m_result = 0;
m_selected_engine = index;
+ m_label.set_text(m_buttons[index].get_data("longname"));
m_buttons[index].grab_focus();
m_keybindings = (GLib.List<Keybinding>) keybindings;
Gdk.Device device = event.get_device();
@@ -138,6 +159,35 @@ class Switcher : Gtk.Window {
@@ -168,6 +189,35 @@ class Switcher : Gtk.Window {
return m_result;
}
@ -91,7 +98,7 @@
private void update_engines(IBus.EngineDesc[] engines) {
foreach (var button in m_buttons) {
button.destroy();
@@ -149,28 +199,15 @@ class Switcher : Gtk.Window {
@@ -179,28 +229,15 @@ class Switcher : Gtk.Window {
return;
}
@ -123,7 +130,7 @@
button.show();
button.enter_notify_event.connect((e) => {
@@ -186,12 +223,40 @@ class Switcher : Gtk.Window {
@@ -216,12 +253,40 @@ class Switcher : Gtk.Window {
return true;
});
@ -166,7 +173,7 @@
}
private void next_engine() {
@@ -199,6 +264,7 @@ class Switcher : Gtk.Window {
@@ -229,6 +294,7 @@ class Switcher : Gtk.Window {
m_selected_engine = 0;
else
m_selected_engine ++;
@ -174,7 +181,7 @@
set_focus(m_buttons[m_selected_engine]);
}
@@ -207,6 +273,7 @@ class Switcher : Gtk.Window {
@@ -237,6 +303,7 @@ class Switcher : Gtk.Window {
m_selected_engine = m_engines.length - 1;
else
m_selected_engine --;
@ -182,3 +189,25 @@
set_focus(m_buttons[m_selected_engine]);
}
@@ -267,18 +334,18 @@ class Switcher : Gtk.Window {
switch (pe->keyval) {
case 0x08fb: /* leftarrow */
- case 0xff51: /* Down */
+ case 0xff51: /* Left */
+ previous_engine();
break;
case 0x08fc: /* uparrow */
case 0xff52: /* Up */
- previous_engine();
break;
case 0x08fd: /* rightarrow */
case 0xff53: /* Right */
+ next_engine();
break;
case 0x08fe: /* downarrow */
case 0xff54: /* Down */
- next_engine();
break;
default:
debug("0x%04x", pe->keyval);

View File

@ -1,5 +1,5 @@
--- ibus-1.4.99.20120317/setup/main.py.orig 2012-03-16 14:58:17.228279261 +0900
+++ ibus-1.4.99.20120317/setup/main.py 2012-03-16 14:58:50.316202253 +0900
--- ibus-1.4.99.20120428/setup/main.py.orig 2012-05-01 12:11:29.055651061 +0900
+++ ibus-1.4.99.20120428/setup/main.py 2012-05-01 17:55:23.053440859 +0900
@@ -75,22 +75,30 @@ class Setup(object):
self.__init_ui()
@ -37,7 +37,7 @@
def __init_panel(self):
values = dict(self.__config.get_values("panel"))
@@ -446,6 +454,37 @@ class Setup(object):
@@ -443,6 +451,46 @@ class Setup(object):
entry.set_text(text)
entry.set_tooltip_text(text)
@ -55,18 +55,27 @@
+ orig_text = ';'.join(orig_list)
+ if text == orig_text:
+ return
+ is_valid = True
+ invalid_shortcut = None
+ for shortcut in shortcuts:
+ (key, mods) = Gtk.accelerator_parse(shortcut)
+ if shortcut.find('<') >= 0:
+ if mods <= 0:
+ invalid_shortcut = shortcut
+ break
+ if not Gtk.accelerator_valid(key, mods):
+ is_valid = False
+ invalid_shortcut = shortcut
+ break
+ # Alt_R could be supported as the trigger key.
+ else:
+ if key <= 0:
+ invalid_shortcut = shortcut
+ break
+ if invalid_shortcut != None:
+ dlg = Gtk.MessageDialog(type = Gtk.MessageType.ERROR,
+ buttons = Gtk.ButtonsType.CLOSE,
+ message_format = "Invalid key %s" % shortcut)
+ message_format = "Invalid key %s" % invalid_shortcut)
+ dlg.run()
+ dlg.destroy()
+ break
+ if not is_valid:
+ return
+ self.__config.set_value(section, name, GLib.Variant.new_strv(shortcuts))
+ text = '\n'.join(shortcuts)

View File

@ -14,7 +14,7 @@
%endif
%if (0%{?fedora} > 16 || 0%{?rhel} > 6)
%define ibus_gjs_version 3.4.1.20120428
%define ibus_gjs_version 3.4.1.20120518
%define ibus_gjs_build_failure 1
%else
%define ibus_gjs_version 3.2.1.20111230
@ -30,7 +30,7 @@
Name: ibus
Version: 1.4.99.20120428
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+
Group: System Environment/Libraries
@ -39,7 +39,7 @@ URL: http://code.google.com/p/ibus/
Source0: http://fujiwara.fedorapeople.org/ibus/gnome-shell/%{name}-%{version}.tar.gz
Source1: xinput-ibus
Source2: http://fujiwara.fedorapeople.org/ibus/gnome-shell/ibus-gjs-%{ibus_gjs_version}.tar.gz
# Patch0: ibus-HEAD.patch
Patch0: ibus-HEAD.patch
Patch1: ibus-541492-xkb.patch
Patch2: ibus-530711-preload-sys.patch
Patch3: ibus-xx-setup-frequent-lang.patch
@ -207,7 +207,7 @@ The ibus-devel-docs package contains developer documentation for ibus
zcat %SOURCE2 | tar xf -
%endif
# %patch0 -p1
%patch0 -p1
%patch92 -p1 -b .g-s-preedit
cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c ||
%if %with_xkbfile
@ -462,6 +462,14 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &>/dev/null || :
%{_datadir}/gtk-doc/html/*
%changelog
* Fri Apr 27 2012 Takao Fujiwara <tfujiwar@redhat.com> - 1.4.99.20120428-2
- Updated ibus-HEAD.patch
- Updated ibus-541492-xkb.patch
- Updated ibus-xx-branding-switcher-ui.patch
Fixed Bug 810211 - Cancel Control + space pressing Control key.
- Updated ibus-xx-no-use.diff
Enabled to customize trigger keys with non-modifier trigger keys.
* Fri Apr 27 2012 Takao Fujiwara <tfujiwar@redhat.com> - 1.4.99.20120428-1
- Bumped to 1.4.99.20120428
Fixed Bug 799571 - no IME list at the session login.

View File

@ -1,3 +1,3 @@
276f30a81b634feb9c4bcc3e564ac948 ibus-1.4.99.20120428.tar.gz
d7ce6d92da05c0701f31540e5b4a3eee ibus-gjs-3.4.1.20120428.tar.gz
2d2ad58e3e41429dbd883ba7e501c9b2 ibus-gjs-3.2.1.20111230.tar.gz
3fdef3e31c0354d927dc06df5dc02f9c ibus-gjs-3.4.1.20120518.tar.gz