diff --git a/data/keyboards/Makefile.am b/data/keyboards/Makefile.am
index 6c0ffc32..45efd4a8 100644
--- a/data/keyboards/Makefile.am
+++ b/data/keyboards/Makefile.am
@@ -1,2 +1,2 @@
keyboarddir = $(pkgdatadir)/keyboards
-dist_keyboard_DATA = us-qwerty.xml
+dist_keyboard_DATA = us.xml
diff --git a/data/keyboards/us-qwerty.xml b/data/keyboards/us.xml
similarity index 54%
rename from data/keyboards/us-qwerty.xml
rename to data/keyboards/us.xml
index 0b48994e..b1bd5742 100644
--- a/data/keyboards/us-qwerty.xml
+++ b/data/keyboards/us.xml
@@ -1,8 +1,115 @@
- 0.000000,0.000000,410.000000,190.000000
-
- 10.000000,50.000000,390.000000,129.000000
+ 0.000000,0.000000,640.000000,296.585366
+
+ 15.609756,15.609756,640.000000,39.024390
+ 0
+
+ 16
+ 1
+
+
+ 3.121951,1.560976,37.463415,37.463415
+ outline2
+
+ Escape
+
+
+
+ 84.292683,1.560976,37.463415,37.463415
+ outline2
+
+ F1
+ F9
+
+
+
+ 124.878049,1.560976,37.463415,37.463415
+ outline2
+
+ F2
+ F10
+
+
+
+ 165.463415,1.560976,37.463415,37.463415
+ outline2
+
+ F3
+ F11
+
+
+
+ 206.048780,1.560976,37.463415,37.463415
+ outline2
+
+ F4
+ F12
+
+
+
+ 266.926829,1.560976,37.463415,37.463415
+ outline2
+
+ F5
+ (null)
+
+
+
+ 307.512195,1.560976,37.463415,37.463415
+ outline2
+
+ F6
+ (null)
+
+
+
+ 348.097561,1.560976,37.463415,37.463415
+ outline2
+
+ F7
+ (null)
+
+
+
+ 388.682927,1.560976,37.463415,37.463415
+ outline2
+
+ F8
+ (null)
+
+
+
+ 449.560976,1.560976,37.463415,37.463415
+ outline2
+
+ Left
+
+
+
+ 490.146341,1.560976,37.463415,37.463415
+ outline2
+
+ Up
+
+
+
+ 530.731707,1.560976,37.463415,37.463415
+ outline2
+
+ Down
+
+
+
+ 571.317073,1.560976,37.463415,37.463415
+ outline2
+
+ Right
+
+
+
+
+ 15.609756,78.048780,608.780488,201.365854
0
14
@@ -24,679 +131,558 @@
8
1
-
- 359.000000,104.000000,31.000000,24.000000
- outline10
-
- Control_R
-
-
-
- 326.000000,104.000000,31.000000,24.000000
- outline10
-
- Menu
-
-
-
- 294.000000,104.000000,31.000000,24.000000
- outline10
-
- Super_R
-
-
-
- 261.000000,104.000000,31.000000,24.000000
- outline10
-
- ISO_Level3_Shift
-
-
-
- 106.000000,104.000000,153.000000,24.000000
- outline11
-
- space
-
-
-
- 73.000000,104.000000,31.000000,24.000000
- outline10
-
- Alt_L
- Meta_L
-
-
-
- 40.000000,104.000000,31.000000,24.000000
- outline10
-
- Super_L
-
-
-
- 2.000000,104.000000,36.000000,24.000000
- outline9
-
- Control_L
-
-
-
- 320.000000,78.000000,70.000000,24.000000
- outline8
-
- Shift_R
-
-
-
- 294.000000,78.000000,24.000000,24.000000
- outline1
-
- slash
- question
-
-
-
- 268.000000,78.000000,24.000000,24.000000
- outline1
-
- period
- greater
-
-
-
- 242.000000,78.000000,24.000000,24.000000
- outline1
-
- comma
- less
-
-
-
- 216.000000,78.000000,24.000000,24.000000
- outline1
-
- m
- M
-
-
-
- 190.000000,78.000000,24.000000,24.000000
- outline1
-
- n
- N
-
-
-
- 164.000000,78.000000,24.000000,24.000000
- outline1
-
- b
- B
-
-
-
- 138.000000,78.000000,24.000000,24.000000
- outline1
-
- v
- V
-
-
-
- 113.000000,78.000000,24.000000,24.000000
- outline1
-
- c
- C
-
-
-
- 87.000000,78.000000,24.000000,24.000000
- outline1
-
- x
- X
-
-
-
- 61.000000,78.000000,24.000000,24.000000
- outline1
-
- z
- Z
-
-
-
- 2.000000,78.000000,57.000000,24.000000
- outline7
-
- Shift_L
-
-
-
- 333.000000,53.000000,57.000000,24.000000
- outline6
-
- Return
-
-
-
- 307.000000,53.000000,24.000000,24.000000
- outline1
-
- quoteright
- quotedbl
-
-
-
- 281.000000,53.000000,24.000000,24.000000
- outline1
-
- semicolon
- colon
-
-
-
- 256.000000,53.000000,24.000000,24.000000
- outline1
-
- l
- L
-
-
-
- 230.000000,53.000000,24.000000,24.000000
- outline1
-
- k
- K
-
-
-
- 204.000000,53.000000,24.000000,24.000000
- outline1
-
- j
- J
-
-
-
- 178.000000,53.000000,24.000000,24.000000
- outline1
-
- h
- H
-
-
-
- 152.000000,53.000000,24.000000,24.000000
- outline1
-
- g
- G
-
-
-
- 126.000000,53.000000,24.000000,24.000000
- outline1
-
- f
- F
-
-
-
- 100.000000,53.000000,24.000000,24.000000
- outline1
-
- d
- D
-
-
-
- 74.000000,53.000000,24.000000,24.000000
- outline1
-
- s
- S
-
-
-
- 49.000000,53.000000,24.000000,24.000000
- outline1
-
- a
- A
-
-
-
- 2.000000,53.000000,44.000000,24.000000
- outline5
-
- Control_L
-
-
-
- 352.000000,27.000000,38.000000,24.000000
- outline4
-
- backslash
- bar
-
-
-
- 326.000000,27.000000,24.000000,24.000000
- outline1
-
- bracketright
- braceright
-
-
-
- 300.000000,27.000000,24.000000,24.000000
- outline1
-
- bracketleft
- braceleft
-
-
-
- 275.000000,27.000000,24.000000,24.000000
- outline1
-
- p
- P
-
-
-
- 249.000000,27.000000,24.000000,24.000000
- outline1
-
- o
- O
-
-
-
- 223.000000,27.000000,24.000000,24.000000
- outline1
-
- i
- I
-
-
-
- 197.000000,27.000000,24.000000,24.000000
- outline1
-
- u
- U
-
-
-
- 171.000000,27.000000,24.000000,24.000000
- outline1
-
- y
- Y
-
-
-
- 145.000000,27.000000,24.000000,24.000000
- outline1
-
- t
- T
-
-
-
- 119.000000,27.000000,24.000000,24.000000
- outline1
-
- r
- R
-
-
-
- 93.000000,27.000000,24.000000,24.000000
- outline1
-
- e
- E
-
-
-
- 68.000000,27.000000,24.000000,24.000000
- outline1
-
- w
- W
-
-
-
- 42.000000,27.000000,24.000000,24.000000
- outline1
-
- q
- Q
-
-
-
- 2.000000,27.000000,38.000000,24.000000
- outline3
-
- Tab
- ISO_Left_Tab
-
-
-
- 339.000000,1.000000,51.000000,24.000000
+
+ 3.121951,1.560976,37.463415,37.463415
outline2
-
- BackSpace
-
-
-
- 313.000000,1.000000,24.000000,24.000000
- outline1
-
- equal
- plus
-
-
-
- 287.000000,1.000000,24.000000,24.000000
- outline1
-
- minus
- underscore
-
-
-
- 261.000000,1.000000,24.000000,24.000000
- outline1
-
- 0
- parenright
-
-
-
- 235.000000,1.000000,24.000000,24.000000
- outline1
-
- 9
- parenleft
-
-
-
- 209.000000,1.000000,24.000000,24.000000
- outline1
-
- 8
- asterisk
-
-
-
- 183.000000,1.000000,24.000000,24.000000
- outline1
-
- 7
- ampersand
-
-
-
- 157.000000,1.000000,24.000000,24.000000
- outline1
-
- 6
- asciicircum
-
-
-
- 132.000000,1.000000,24.000000,24.000000
- outline1
-
- 5
- percent
-
-
-
- 106.000000,1.000000,24.000000,24.000000
- outline1
-
- 4
- dollar
-
-
-
- 80.000000,1.000000,24.000000,24.000000
- outline1
-
- 3
- numbersign
-
-
-
- 54.000000,1.000000,24.000000,24.000000
- outline1
-
- 2
- at
-
-
-
- 28.000000,1.000000,24.000000,24.000000
- outline1
-
- 1
- exclam
-
-
-
- 2.000000,1.000000,24.000000,24.000000
- outline1
quoteleft
asciitilde
-
-
- 10.000000,10.000000,410.000000,25.000000
- 0
-
- 16
- 1
-
-
- 366.000000,1.000000,24.000000,24.000000
+
+ 43.707317,1.560976,37.463415,37.463415
+ outline2
+
+ 1
+ exclam
+
+
+
+ 84.292683,1.560976,37.463415,37.463415
+ outline2
+
+ 2
+ at
+
+
+
+ 124.878049,1.560976,37.463415,37.463415
+ outline2
+
+ 3
+ numbersign
+
+
+
+ 165.463415,1.560976,37.463415,37.463415
+ outline2
+
+ 4
+ dollar
+
+
+
+ 206.048780,1.560976,37.463415,37.463415
+ outline2
+
+ 5
+ percent
+
+
+
+ 245.073171,1.560976,37.463415,37.463415
+ outline2
+
+ 6
+ asciicircum
+
+
+
+ 285.658537,1.560976,37.463415,37.463415
+ outline2
+
+ 7
+ ampersand
+
+
+
+ 326.243902,1.560976,37.463415,37.463415
+ outline2
+
+ 8
+ asterisk
+
+
+
+ 366.829268,1.560976,37.463415,37.463415
+ outline2
+
+ 9
+ parenleft
+
+
+
+ 407.414634,1.560976,37.463415,37.463415
+ outline2
+
+ 0
+ parenright
+
+
+
+ 448.000000,1.560976,37.463415,37.463415
+ outline2
+
+ minus
+ underscore
+
+
+
+ 488.585366,1.560976,37.463415,37.463415
+ outline2
+
+ equal
+ plus
+
+
+
+ 529.170732,1.560976,79.609756,37.463415
+ outline13
+
+ BackSpace
+
+
+
+ 3.121951,42.146341,59.317073,37.463415
+ outline4
+
+ Tab
+ ISO_Left_Tab
+
+
+
+ 65.560976,42.146341,37.463415,37.463415
+ outline2
+
+ q
+ Q
+
+
+
+ 106.146341,42.146341,37.463415,37.463415
+ outline2
+
+ w
+ W
+
+
+
+ 145.170732,42.146341,37.463415,37.463415
+ outline2
+
+ e
+ E
+
+
+
+ 185.756098,42.146341,37.463415,37.463415
+ outline2
+
+ r
+ R
+
+
+
+ 226.341463,42.146341,37.463415,37.463415
+ outline2
+
+ t
+ T
+
+
+
+ 266.926829,42.146341,37.463415,37.463415
+ outline2
+
+ y
+ Y
+
+
+
+ 307.512195,42.146341,37.463415,37.463415
+ outline2
+
+ u
+ U
+
+
+
+ 348.097561,42.146341,37.463415,37.463415
+ outline2
+
+ i
+ I
+
+
+
+ 388.682927,42.146341,37.463415,37.463415
+ outline2
+
+ o
+ O
+
+
+
+ 429.268293,42.146341,37.463415,37.463415
+ outline2
+
+ p
+ P
+
+
+
+ 468.292683,42.146341,37.463415,37.463415
+ outline2
+
+ bracketleft
+ braceleft
+
+
+
+ 508.878049,42.146341,37.463415,37.463415
+ outline2
+
+ bracketright
+ braceright
+
+
+
+ 549.463415,42.146341,59.317073,37.463415
+ outline5
+
+ backslash
+ bar
+
+
+
+ 3.121951,82.731707,68.682927,37.463415
+ outline6
+
+ Control_L
+
+
+
+ 76.487805,82.731707,37.463415,37.463415
+ outline2
+
+ a
+ A
+
+
+
+ 115.512195,82.731707,37.463415,37.463415
+ outline2
+
+ s
+ S
+
+
+
+ 156.097561,82.731707,37.463415,37.463415
+ outline2
+
+ d
+ D
+
+
+
+ 196.682927,82.731707,37.463415,37.463415
+ outline2
+
+ f
+ F
+
+
+
+ 237.268293,82.731707,37.463415,37.463415
+ outline2
+
+ g
+ G
+
+
+
+ 277.853659,82.731707,37.463415,37.463415
+ outline2
+
+ h
+ H
+
+
+
+ 318.439024,82.731707,37.463415,37.463415
+ outline2
+
+ j
+ J
+
+
+
+ 359.024390,82.731707,37.463415,37.463415
+ outline2
+
+ k
+ K
+
+
+
+ 399.609756,82.731707,37.463415,37.463415
+ outline2
+
+ l
+ L
+
+
+
+ 438.634146,82.731707,37.463415,37.463415
+ outline2
+
+ semicolon
+ colon
+
+
+
+ 479.219512,82.731707,37.463415,37.463415
+ outline2
+
+ quoteright
+ quotedbl
+
+
+
+ 519.804878,82.731707,88.975610,37.463415
+ outline7
+
+ Return
+
+
+
+ 3.121951,121.756098,88.975610,37.463415
+ outline8
+
+ Shift_L
+
+
+
+ 95.219512,121.756098,37.463415,37.463415
+ outline2
+
+ z
+ Z
+
+
+
+ 135.804878,121.756098,37.463415,37.463415
+ outline2
+
+ x
+ X
+
+
+
+ 176.390244,121.756098,37.463415,37.463415
+ outline2
+
+ c
+ C
+
+
+
+ 215.414634,121.756098,37.463415,37.463415
+ outline2
+
+ v
+ V
+
+
+
+ 256.000000,121.756098,37.463415,37.463415
+ outline2
+
+ b
+ B
+
+
+
+ 296.585366,121.756098,37.463415,37.463415
+ outline2
+
+ n
+ N
+
+
+
+ 337.170732,121.756098,37.463415,37.463415
+ outline2
+
+ m
+ M
+
+
+
+ 377.756098,121.756098,37.463415,37.463415
+ outline2
+
+ comma
+ less
+
+
+
+ 418.341463,121.756098,37.463415,37.463415
+ outline2
+
+ period
+ greater
+
+
+
+ 458.926829,121.756098,37.463415,37.463415
+ outline2
+
+ slash
+ question
+
+
+
+ 499.512195,121.756098,109.268293,37.463415
+ outline9
+
+ Shift_R
+
+
+
+ 3.121951,162.341463,56.195122,37.463415
+ outline10
+
+ Control_L
+
+
+
+ 62.439024,162.341463,48.390244,37.463415
outline1
- Right
+ Super_L
-
- 340.000000,1.000000,24.000000,24.000000
+
+ 113.951220,162.341463,48.390244,37.463415
+ outline1
+
+ Alt_L
+ Meta_L
+
+
+
+ 165.463415,162.341463,238.829268,37.463415
+ outline3
+
+ space
+
+
+
+ 407.414634,162.341463,48.390244,37.463415
outline1
- Down
+ ISO_Level3_Shift
-
- 314.000000,1.000000,24.000000,24.000000
+
+ 458.926829,162.341463,48.390244,37.463415
outline1
- Up
+ Super_R
-
- 288.000000,1.000000,24.000000,24.000000
+
+ 508.878049,162.341463,48.390244,37.463415
outline1
- Left
+ Menu
-
- 249.000000,1.000000,24.000000,24.000000
- outline1
-
- F8
- (null)
-
-
-
- 223.000000,1.000000,24.000000,24.000000
- outline1
-
- F7
- (null)
-
-
-
- 197.000000,1.000000,24.000000,24.000000
- outline1
-
- F6
- (null)
-
-
-
- 171.000000,1.000000,24.000000,24.000000
- outline1
-
- F5
- (null)
-
-
-
- 132.000000,1.000000,24.000000,24.000000
- outline1
-
- F4
- F12
-
-
-
- 106.000000,1.000000,24.000000,24.000000
- outline1
-
- F3
- F11
-
-
-
- 80.000000,1.000000,24.000000,24.000000
- outline1
-
- F2
- F10
-
-
-
- 54.000000,1.000000,24.000000,24.000000
- outline1
-
- F1
- F9
-
-
-
- 2.000000,1.000000,24.000000,24.000000
+
+ 560.390244,162.341463,48.390244,37.463415
outline1
- Escape
+ Control_R
+
+ 1.000000
+ 0.000000,0.000000
+ 37.463415,0.000000
+ 37.463415,37.463415
+ 0.000000,37.463415
+
1.000000
0.000000,0.000000
- 24.000000,0.000000
- 24.000000,24.000000
- 0.000000,24.000000
-
-
- 1.000000
- 0.000000,0.000000
- 38.000000,0.000000
- 38.000000,24.000000
- 0.000000,24.000000
+ 48.390244,0.000000
+ 48.390244,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 38.000000,0.000000
- 38.000000,24.000000
- 0.000000,24.000000
+ 59.317073,0.000000
+ 59.317073,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 44.000000,0.000000
- 44.000000,24.000000
- 0.000000,24.000000
+ 59.317073,0.000000
+ 59.317073,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 57.000000,0.000000
- 57.000000,24.000000
- 0.000000,24.000000
+ 68.682927,0.000000
+ 68.682927,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 57.000000,0.000000
- 57.000000,24.000000
- 0.000000,24.000000
+ 88.975610,0.000000
+ 88.975610,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 70.000000,0.000000
- 70.000000,24.000000
- 0.000000,24.000000
+ 88.975610,0.000000
+ 88.975610,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 36.000000,0.000000
- 36.000000,24.000000
- 0.000000,24.000000
+ 109.268293,0.000000
+ 109.268293,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 31.000000,0.000000
- 31.000000,24.000000
- 0.000000,24.000000
-
-
- 1.000000
- 0.000000,0.000000
- 153.000000,0.000000
- 153.000000,24.000000
- 0.000000,24.000000
-
-
- 1.000000
- 0.000000,0.000000
- 24.000000,0.000000
- 24.000000,50.000000
- 0.000000,50.000000
+ 56.195122,0.000000
+ 56.195122,37.463415
+ 0.000000,37.463415
1.000000
0.000000,0.000000
- 50.000000,0.000000
- 50.000000,24.000000
- 0.000000,24.000000
+ 79.609756,0.000000
+ 79.609756,37.463415
+ 0.000000,37.463415
-
+
1.000000
0.000000,0.000000
- 51.000000,0.000000
- 51.000000,24.000000
- 0.000000,24.000000
+ 238.829268,0.000000
+ 238.829268,37.463415
+ 0.000000,37.463415
diff --git a/eek/eek-xkl-layout.c b/eek/eek-xkl-layout.c
index d345525d..8bbc4053 100644
--- a/eek/eek-xkl-layout.c
+++ b/eek/eek-xkl-layout.c
@@ -84,11 +84,6 @@ eek_xkl_layout_dispose (GObject *object)
priv->config = NULL;
}
- if (priv->engine) {
- g_object_unref (priv->engine);
- priv->engine = NULL;
- }
-
G_OBJECT_CLASS (eek_xkl_layout_parent_class)->dispose (object);
}
diff --git a/eekboard/Makefile.am b/eekboard/Makefile.am
index 61c8a172..4ff33aaa 100644
--- a/eekboard/Makefile.am
+++ b/eekboard/Makefile.am
@@ -21,12 +21,24 @@ lib_LTLIBRARIES = libeekboard.la
libeekboard_headers = \
eekboard.h \
eekboard-eekboard.h \
- eekboard-context.h
+ eekboard-context.h
+libeekboard_private_headers = \
+ eekboard-marshalers.h
libeekboard_sources = \
eekboard-eekboard.c \
eekboard-context.c
-libeekboard_la_SOURCES = $(libeekboard_sources)
+libeekboard_marshalers_sources = \
+ eekboard-marshalers.c \
+ eekboard-marshalers.h
+
+BUILT_SOURCES = \
+ $(libeekboard_marshalers_sources)
+
+libeekboard_la_SOURCES = \
+ $(libeekboard_sources) \
+ eekboard-marshalers.c
+
libeekboard_la_CFLAGS = -DEEKBOARD_COMPILATION=1 -I$(top_srcdir) $(GIO2_CFLAGS)
libeekboard_la_LIBADD = $(top_builddir)/eek/libeek.la $(GIO2_LIBS)
@@ -37,10 +49,23 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
eekboard-$(EEK_API_VERSION).pc
DISTCLEANFILES = \
+ $(BUILT_SOURCES) \
$(pkgconfig_DATA)
CLEANFILES =
+EXTRA_DIST = eekboard-marshalers.list
+
+# gen marshal
+eekboard-marshalers.h: eekboard-marshalers.list
+ $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_eekboard_marshal $(srcdir)/eekboard-marshalers.list --header --internal > $@.tmp && \
+ mv $@.tmp $@
+
+eekboard-marshalers.c: eekboard-marshalers.list eekboard-marshalers.h
+ $(AM_V_GEN) (echo "#include \"eekboard-marshalers.h\""; \
+ $(GLIB_GENMARSHAL) --prefix=_eekboard_marshal $(srcdir)/eekboard-marshalers.list --body --internal) > $@.tmp && \
+ mv $@.tmp $@
+
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(builddir) --add-include-path=$(top_builddir)/eek
diff --git a/eekboard/eekboard-context.c b/eekboard/eekboard-context.c
index b2c7d80a..ed400dd4 100644
--- a/eekboard/eekboard-context.c
+++ b/eekboard/eekboard-context.c
@@ -29,6 +29,7 @@
#endif /* HAVE_CONFIG_H */
#include "eekboard/eekboard-context.h"
+#include "eekboard/eekboard-marshalers.h"
#define I_(string) g_intern_static_string (string)
@@ -36,7 +37,6 @@ enum {
ENABLED,
DISABLED,
KEY_PRESSED,
- KEY_RELEASED,
DESTROYED,
LAST_SIGNAL
};
@@ -56,11 +56,10 @@ G_DEFINE_TYPE (EekboardContext, eekboard_context, G_TYPE_DBUS_PROXY);
struct _EekboardContextPrivate
{
- EekKeyboard *keyboard;
- GHashTable *keyboard_hash;
gboolean keyboard_visible;
gboolean enabled;
gboolean fullscreen;
+ gint group;
};
static void
@@ -83,21 +82,24 @@ eekboard_context_real_g_signal (GDBusProxy *self,
}
if (g_strcmp0 (signal_name, "KeyPressed") == 0) {
- guint keycode;
- g_variant_get (parameters, "(u)", &keycode);
- g_signal_emit_by_name (context, "key-pressed", keycode);
- return;
- }
+ guint keycode = 0;
+ GVariant *variant = NULL;
+ guint modifiers = 0;
+ EekSerializable *serializable;
- if (g_strcmp0 (signal_name, "KeyReleased") == 0) {
- guint keycode;
- g_variant_get (parameters, "(u)", &keycode);
- g_signal_emit_by_name (context, "key-released", keycode);
+ g_variant_get (parameters, "(uvu)", &keycode, &variant, &modifiers);
+ g_return_if_fail (variant != NULL);
+
+ serializable = eek_serializable_deserialize (variant);
+ g_return_if_fail (EEK_IS_SYMBOL(serializable));
+
+ g_signal_emit_by_name (context, "key-pressed",
+ keycode, EEK_SYMBOL(serializable), modifiers);
return;
}
if (g_strcmp0 (signal_name, "KeyboardVisibilityChanged") == 0) {
- gboolean keyboard_visible;
+ gboolean keyboard_visible = FALSE;
g_variant_get (parameters, "(b)", &keyboard_visible);
if (keyboard_visible != priv->keyboard_visible) {
@@ -107,6 +109,17 @@ eekboard_context_real_g_signal (GDBusProxy *self,
return;
}
+ if (g_strcmp0 (signal_name, "GroupChanged") == 0) {
+ gint group = 0;
+
+ g_variant_get (parameters, "(i)", &group);
+ if (group != priv->group) {
+ priv->group = group;
+ //g_object_notify (G_OBJECT(context), "group");
+ }
+ return;
+ }
+
g_return_if_reached ();
}
@@ -126,32 +139,15 @@ eekboard_context_real_disabled (EekboardContext *self)
static void
eekboard_context_real_key_pressed (EekboardContext *self,
- guint keycode)
+ guint keycode,
+ EekSymbol *symbol,
+ guint modifiers)
{
- EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
- if (priv->keyboard) {
- EekKey *key = eek_keyboard_find_key_by_keycode (priv->keyboard,
- keycode);
- g_signal_emit_by_name (key, "pressed");
- }
-}
-
-static void
-eekboard_context_real_key_released (EekboardContext *self,
- guint keycode)
-{
- EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
- if (priv->keyboard) {
- EekKey *key = eek_keyboard_find_key_by_keycode (priv->keyboard,
- keycode);
- g_signal_emit_by_name (key, "released");
- }
}
static void
eekboard_context_real_destroyed (EekboardContext *self)
{
- // g_debug ("eekboard_context_real_destroyed");
}
static void
@@ -173,22 +169,6 @@ eekboard_context_get_property (GObject *object,
}
}
-static void
-eekboard_context_dispose (GObject *self)
-{
- EekboardContextPrivate *priv = EEKBOARD_CONTEXT_GET_PRIVATE (self);
-
- if (priv->keyboard) {
- g_object_unref (priv->keyboard);
- priv->keyboard = NULL;
- }
-
- if (priv->keyboard_hash) {
- g_hash_table_destroy (priv->keyboard_hash);
- priv->keyboard_hash = NULL;
- }
-}
-
static void
eekboard_context_class_init (EekboardContextClass *klass)
{
@@ -202,13 +182,11 @@ eekboard_context_class_init (EekboardContextClass *klass)
klass->enabled = eekboard_context_real_enabled;
klass->disabled = eekboard_context_real_disabled;
klass->key_pressed = eekboard_context_real_key_pressed;
- klass->key_released = eekboard_context_real_key_released;
klass->destroyed = eekboard_context_real_destroyed;
proxy_class->g_signal = eekboard_context_real_g_signal;
gobject_class->get_property = eekboard_context_get_property;
- gobject_class->dispose = eekboard_context_dispose;
/**
* EekboardContext:keyboard-visible:
@@ -262,6 +240,8 @@ eekboard_context_class_init (EekboardContextClass *klass)
* EekboardContext::key-pressed:
* @context: an #EekboardContext
* @keycode: keycode
+ * @symbol: an #EekSymbol
+ * @modifiers: modifiers
*
* The ::key-pressed signal is emitted each time a key is pressed
* in @context.
@@ -273,29 +253,11 @@ eekboard_context_class_init (EekboardContextClass *klass)
G_STRUCT_OFFSET(EekboardContextClass, key_pressed),
NULL,
NULL,
- g_cclosure_marshal_VOID__UINT,
+ _eekboard_marshal_VOID__UINT_OBJECT_UINT,
G_TYPE_NONE,
- 1,
- G_TYPE_UINT);
-
- /**
- * EekboardContext::key-released:
- * @context: an #EekboardContext
- * @keycode: keycode
- *
- * The ::key-released signal is emitted each time a key is released
- * in @context.
- */
- signals[KEY_RELEASED] =
- g_signal_new (I_("key-released"),
- G_TYPE_FROM_CLASS(gobject_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(EekboardContextClass, key_released),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE,
- 1,
+ 3,
+ G_TYPE_UINT,
+ G_TYPE_OBJECT,
G_TYPE_UINT);
/**
@@ -320,17 +282,7 @@ eekboard_context_class_init (EekboardContextClass *klass)
static void
eekboard_context_init (EekboardContext *self)
{
- EekboardContextPrivate *priv;
-
- priv = self->priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
- priv->keyboard = NULL;
- priv->keyboard_visible = FALSE;
- priv->enabled = FALSE;
- priv->keyboard_hash =
- g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- (GDestroyNotify)g_object_unref);
+ self->priv = EEKBOARD_CONTEXT_GET_PRIVATE(self);
}
static void
@@ -415,38 +367,29 @@ context_async_ready_callback (GObject *source_object,
/**
* eekboard_context_add_keyboard:
* @context: an #EekboardContext
- * @keyboard: an #EekKeyboard
+ * @keyboard: a string representing keyboard
* @cancellable: a #GCancellable
*
* Register @keyboard in @context.
*/
guint
eekboard_context_add_keyboard (EekboardContext *context,
- EekKeyboard *keyboard,
+ const gchar *keyboard,
GCancellable *cancellable)
{
- EekboardContextPrivate *priv;
- GVariant *variant, *result;
+ GVariant *result;
GError *error;
g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
- g_return_val_if_fail (EEK_IS_KEYBOARD(keyboard), 0);
-
- priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
-
- variant = eek_serializable_serialize (EEK_SERIALIZABLE(keyboard));
- if (g_variant_is_floating (variant))
- g_variant_ref_sink (variant);
error = NULL;
result = g_dbus_proxy_call_sync (G_DBUS_PROXY(context),
"AddKeyboard",
- g_variant_new ("(v)", variant),
+ g_variant_new ("(s)", keyboard),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
&error);
- g_variant_unref (variant);
if (result) {
guint keyboard_id;
@@ -454,11 +397,6 @@ eekboard_context_add_keyboard (EekboardContext *context,
g_variant_get (result, "(u)", &keyboard_id);
g_variant_unref (result);
- if (keyboard_id != 0) {
- g_hash_table_insert (priv->keyboard_hash,
- GUINT_TO_POINTER(keyboard_id),
- g_object_ref (keyboard));
- }
return keyboard_id;
}
return 0;
@@ -477,20 +415,8 @@ eekboard_context_remove_keyboard (EekboardContext *context,
guint keyboard_id,
GCancellable *cancellable)
{
- EekboardContextPrivate *priv;
- EekKeyboard *keyboard;
-
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
- priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
-
- keyboard = g_hash_table_lookup (priv->keyboard_hash,
- GUINT_TO_POINTER(keyboard_id));
- if (keyboard == priv->keyboard)
- priv->keyboard = NULL;
-
- g_hash_table_remove (priv->keyboard_hash, GUINT_TO_POINTER(keyboard_id));
-
g_dbus_proxy_call (G_DBUS_PROXY(context),
"RemoveKeyboard",
g_variant_new ("(u)", keyboard_id),
@@ -514,20 +440,8 @@ eekboard_context_set_keyboard (EekboardContext *context,
guint keyboard_id,
GCancellable *cancellable)
{
- EekboardContextPrivate *priv;
- EekKeyboard *keyboard;
-
g_return_if_fail (EEKBOARD_IS_CONTEXT(context));
- priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
-
- keyboard = g_hash_table_lookup (priv->keyboard_hash,
- GUINT_TO_POINTER(keyboard_id));
- if (!keyboard || keyboard == priv->keyboard)
- return;
-
- priv->keyboard = keyboard;
-
g_dbus_proxy_call (G_DBUS_PROXY(context),
"SetKeyboard",
g_variant_new ("(u)", keyboard_id),
@@ -557,10 +471,7 @@ eekboard_context_set_group (EekboardContext *context,
priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
- g_return_if_fail (priv->keyboard);
-
- if (eek_element_get_group (EEK_ELEMENT(priv->keyboard)) != group) {
- eek_element_set_group (EEK_ELEMENT(priv->keyboard), group);
+ if (priv->group != group) {
g_dbus_proxy_call (G_DBUS_PROXY(context),
"SetGroup",
g_variant_new ("(i)", group),
@@ -572,6 +483,25 @@ eekboard_context_set_group (EekboardContext *context,
}
}
+/**
+ * eekboard_context_get_group:
+ * @context: an #EekboardContext
+ * @cancellable: a #GCancellable
+ *
+ * Get the keyboard group of @context.
+ */
+gint
+eekboard_context_get_group (EekboardContext *context,
+ GCancellable *cancellable)
+{
+ EekboardContextPrivate *priv;
+
+ g_return_val_if_fail (EEKBOARD_IS_CONTEXT(context), 0);
+
+ priv = EEKBOARD_CONTEXT_GET_PRIVATE (context);
+ return priv->group;
+}
+
/**
* eekboard_context_show_keyboard:
* @context: an #EekboardContext
diff --git a/eekboard/eekboard-context.h b/eekboard/eekboard-context.h
index 79fcb004..8cd76322 100644
--- a/eekboard/eekboard-context.h
+++ b/eekboard/eekboard-context.h
@@ -57,7 +57,6 @@ struct _EekboardContext {
* @enabled: class handler for #EekboardContext::enabled signal
* @disabled: class handler for #EekboardContext::disabled signal
* @key_pressed: class handler for #EekboardContext::key-pressed signal
- * @key_released: class handler for #EekboardContext::key-released signal
*/
struct _EekboardContextClass {
/*< private >*/
@@ -68,14 +67,14 @@ struct _EekboardContextClass {
void (*enabled) (EekboardContext *self);
void (*disabled) (EekboardContext *self);
void (*key_pressed) (EekboardContext *self,
- guint keycode);
- void (*key_released) (EekboardContext *self,
- guint keycode);
+ guint keycode,
+ EekSymbol *symbol,
+ guint modifiers);
void (*destroyed) (EekboardContext *self);
/*< private >*/
/* padding */
- gpointer pdummy[23];
+ gpointer pdummy[24];
};
GType eekboard_context_get_type (void) G_GNUC_CONST;
@@ -84,7 +83,7 @@ EekboardContext *eekboard_context_new (GDBusConnection *connection,
const gchar *object_path,
GCancellable *cancellable);
guint eekboard_context_add_keyboard (EekboardContext *context,
- EekKeyboard *keyboard,
+ const gchar *keyboard,
GCancellable *cancellable);
void eekboard_context_remove_keyboard (EekboardContext *context,
guint keyboard_id,
diff --git a/eekboard/eekboard-marshalers.list b/eekboard/eekboard-marshalers.list
new file mode 100644
index 00000000..b4bcf03d
--- /dev/null
+++ b/eekboard/eekboard-marshalers.list
@@ -0,0 +1 @@
+VOID:UINT,OBJECT,UINT
diff --git a/src/Makefile.am b/src/Makefile.am
index b3a77946..70baa637 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,14 +69,19 @@ eekboard_server_CFLAGS = \
-I$(top_srcdir) \
$(GIO2_CFLAGS) \
$(GTK_CFLAGS) \
- -DTHEMEDIR=\"$(pkgdatadir)/themes\"
+ $(LIBXKLAVIER_CFLAGS) \
+ -DTHEMEDIR=\"$(pkgdatadir)/themes\" \
+ -DKEYBOARDDIR=\"$(pkgdatadir)/keyboards\"
eekboard_server_LDADD = \
+ $(builddir)/libxklutil.la \
$(top_builddir)/eekboard/libeekboard.la \
$(top_builddir)/eek/libeek.la \
$(top_builddir)/eek/libeek-gtk.la \
+ $(top_builddir)/eek/libeek-xkl.la \
$(GIO2_LIBS) \
- $(GTK_LIBS)
+ $(GTK_LIBS) \
+ $(LIBXKLAVIER_LIBS)
if ENABLE_CLUTTER_GTK
eekboard_server_CFLAGS += $(CLUTTER_GTK_CFLAGS)
diff --git a/src/client-main.c b/src/client-main.c
index a7abcfdf..0420db38 100644
--- a/src/client-main.c
+++ b/src/client-main.c
@@ -32,7 +32,7 @@
#include "eekboard/eekboard.h"
#include "client.h"
-#define DEFAULT_LAYOUT "us-qwerty"
+#define DEFAULT_KEYBOARD "us"
static gboolean opt_system = FALSE;
static gboolean opt_session = FALSE;
@@ -44,10 +44,6 @@ static gboolean opt_keystroke = FALSE;
static gchar *opt_keyboard = NULL;
-static gchar *opt_model = NULL;
-static gchar *opt_layouts = NULL;
-static gchar *opt_options = NULL;
-
static gboolean opt_fullscreen = FALSE;
static const GOptionEntry options[] = {
@@ -69,12 +65,6 @@ static const GOptionEntry options[] = {
#endif /* HAVE_ATSPI */
{"keyboard", 'k', 0, G_OPTION_ARG_STRING, &opt_keyboard,
N_("Specify keyboard")},
- {"model", '\0', 0, G_OPTION_ARG_STRING, &opt_model,
- N_("Specify model")},
- {"layouts", '\0', 0, G_OPTION_ARG_STRING, &opt_layouts,
- N_("Specify layouts")},
- {"options", '\0', 0, G_OPTION_ARG_STRING, &opt_options,
- N_("Specify options")},
{"fullscreen", 'F', 0, G_OPTION_ARG_NONE, &opt_fullscreen,
N_("Create window in fullscreen mode")},
{NULL}
@@ -138,6 +128,13 @@ main (int argc, char **argv)
exit (1);
}
+ /* preload Eek* types for EekKeyboard deserialization */
+ g_type_class_ref (EEK_TYPE_KEYBOARD);
+ g_type_class_ref (EEK_TYPE_SECTION);
+ g_type_class_ref (EEK_TYPE_KEY);
+ g_type_class_ref (EEK_TYPE_SYMBOL);
+ g_type_class_ref (EEK_TYPE_KEYSYM);
+
option_context = g_option_context_new ("eekboard-desktop-client");
g_option_context_add_main_entries (option_context, options, NULL);
g_option_context_parse (option_context, &argc, &argv, NULL);
@@ -254,7 +251,7 @@ main (int argc, char **argv)
}
#endif /* HAVE_IBUS */
- if (opt_use_system_layout && (opt_keyboard || opt_model || opt_layouts || opt_options)) {
+ if (opt_use_system_layout && opt_keyboard) {
g_printerr ("Can't use --use-system-layout option with keyboard options\n");
g_object_unref (client);
exit (1);
@@ -266,35 +263,6 @@ main (int argc, char **argv)
exit (1);
}
- if (opt_use_system_layout || opt_model || opt_layouts || opt_options) {
- if (!eekboard_client_load_keyboard_from_xkl (client,
- opt_model,
- opt_layouts,
- opt_options)) {
- g_printerr ("Can't load keyboard from xklavier config\n");
- g_object_unref (client);
- exit (1);
- }
- } else {
- gchar *file;
- gboolean success;
-
- if (!opt_keyboard)
- opt_keyboard = DEFAULT_LAYOUT;
-
- if (g_str_has_suffix (opt_keyboard, ".xml"))
- file = g_strdup (opt_keyboard);
- else
- file = g_strdup_printf ("%s/%s.xml", KEYBOARDDIR, opt_keyboard);
- success = eekboard_client_load_keyboard_from_file (client, file);
- g_free (file);
- if (!success) {
- g_printerr ("Can't load keyboard file %s\n", file);
- g_object_unref (client);
- exit (1);
- }
- }
-
#ifdef HAVE_XTEST
if (!eekboard_client_enable_xtest (client)) {
g_printerr ("Can't init xtest\n");
@@ -303,6 +271,8 @@ main (int argc, char **argv)
}
#endif /* HAVE_XTEST */
+ eekboard_client_set_keyboard (client, opt_keyboard ? opt_keyboard : DEFAULT_KEYBOARD);
+
loop = g_main_loop_new (NULL, FALSE);
if (!opt_focus) {
g_object_get (client, "context", &context, NULL);
diff --git a/src/client.c b/src/client.c
index 9dd627d5..e2284899 100644
--- a/src/client.c
+++ b/src/client.c
@@ -68,7 +68,6 @@ struct _EekboardClient {
XklEngine *xkl_engine;
XklConfigRegistry *xkl_config_registry;
gboolean use_xkl_layout;
- gint group;
gulong xkl_config_changed_handler;
gulong xkl_state_changed_handler;
@@ -123,13 +122,7 @@ static gboolean keystroke_listener_cb (const AtspiDeviceEvent *stroke,
void *user_data);
#endif /* HAVE_ATSPI */
static gboolean set_keyboard (EekboardClient *client,
- gboolean show,
- EekLayout *layout);
-static gboolean set_keyboard_from_xkl (EekboardClient *client,
- gboolean show,
- const gchar *model,
- const gchar *layouts,
- const gchar *options);
+ const gchar *keyboard);
#ifdef HAVE_XTEST
static void update_modifier_keycodes
(EekboardClient *client);
@@ -232,11 +225,6 @@ eekboard_client_dispose (GObject *object)
client->eekboard = NULL;
}
- if (client->keyboard) {
- g_object_unref (client->keyboard);
- client->keyboard = NULL;
- }
-
if (client->settings) {
g_object_unref (client->settings);
client->settings = NULL;
@@ -286,50 +274,25 @@ eekboard_client_class_init (EekboardClientClass *klass)
static void
eekboard_client_init (EekboardClient *client)
{
- client->eekboard = NULL;
- client->context = NULL;
- client->xkl_engine = NULL;
- client->xkl_config_registry = NULL;
- client->keyboard = NULL;
- client->key_pressed_handler = 0;
- client->key_released_handler = 0;
- client->xkl_config_changed_handler = 0;
- client->xkl_state_changed_handler = 0;
-#if ENABLE_FOCUS_LISTENER
- client->follows_focus = FALSE;
- client->hide_keyboard_timeout_id = 0;
-#endif /* ENABLE_FOCUS_LISTENER */
-#ifdef HAVE_ATSPI
- client->keystroke_listener = NULL;
-#endif /* HAVE_ATSPI */
-#ifdef HAVE_IBUS
- client->ibus_bus = NULL;
- client->ibus_focus_message_filter = 0;
-#endif /* HAVE_IBUS */
client->settings = g_settings_new ("org.fedorahosted.eekboard");
}
-gboolean
-eekboard_client_load_keyboard_from_xkl (EekboardClient *client,
- const gchar *model,
- const gchar *layouts,
- const gchar *options)
-{
- client->use_xkl_layout = TRUE;
-
#if ENABLE_FOCUS_LISTENER
- return set_keyboard_from_xkl (client,
- !client->follows_focus,
- model,
- layouts,
- options);
+#define IS_KEYBOARD_VISIBLE(client) (!client->follows_focus)
#else /* ENABLE_FOCUS_LISTENER */
- return set_keyboard_from_xkl (client,
- TRUE,
- model,
- layouts,
- options);
+#define IS_KEYBOARD_VISIBLE(client) TRUE
#endif /* !ENABLE_FOCUS_LISTENER */
+
+gboolean
+eekboard_client_set_keyboard (EekboardClient *client,
+ const gchar *keyboard)
+{
+ gboolean retval;
+
+ retval = set_keyboard (client, keyboard);
+ if (IS_KEYBOARD_VISIBLE (client))
+ eekboard_context_show_keyboard (client->context, NULL);
+ return retval;
}
gboolean
@@ -550,24 +513,17 @@ keystroke_listener_cb (const AtspiDeviceEvent *stroke,
void *user_data)
{
EekboardClient *client = user_data;
- EekKey *key;
- /* Ignore modifiers since the keystroke listener does not called
- when a modifier key is released. */
- key = eek_keyboard_find_key_by_keycode (client->keyboard,
- stroke->hw_code);
- if (key) {
- EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
- if (symbol && eek_symbol_is_modifier (symbol))
- return FALSE;
- }
-
- if (stroke->type == ATSPI_KEY_PRESSED) {
+ switch (stroke->type) {
+ case ATSPI_KEY_PRESSED:
eekboard_context_press_key (client->context, stroke->hw_code, NULL);
- } else {
+ break;
+ case ATSPI_KEY_RELEASED:
eekboard_context_release_key (client->context, stroke->hw_code, NULL);
+ break;
+ default:
+ g_return_val_if_reached (FALSE);
}
-
return TRUE;
}
#endif /* HAVE_ATSPI */
@@ -725,7 +681,19 @@ on_xkl_config_changed (XklEngine *xklengine,
gboolean retval;
if (client->use_xkl_layout) {
- retval = set_keyboard_from_xkl (client, FALSE, NULL, NULL, NULL);
+ XklConfigRec *rec;
+ gchar *layout, *keyboard;
+
+ rec = xkl_config_rec_new ();
+ xkl_config_rec_get_from_server (rec, client->xkl_engine);
+ layout = eekboard_xkl_config_rec_to_string (rec);
+ g_object_unref (rec);
+
+ keyboard = g_strdup_printf ("xkl:%s", layout);
+ g_free (layout);
+ retval = set_keyboard (client, keyboard);
+ g_free (keyboard);
+
g_return_if_fail (retval);
}
@@ -736,88 +704,17 @@ on_xkl_config_changed (XklEngine *xklengine,
static gboolean
set_keyboard (EekboardClient *client,
- gboolean show,
- EekLayout *layout)
+ const gchar *keyboard)
{
- gchar *keyboard_name;
- static gint keyboard_serial = 0;
guint keyboard_id;
- client->keyboard = eek_keyboard_new (layout, CSW, CSH);
- eek_keyboard_set_modifier_behavior (client->keyboard,
- EEK_MODIFIER_BEHAVIOR_LATCH);
-
- keyboard_name = g_strdup_printf ("keyboard%d", keyboard_serial++);
- eek_element_set_name (EEK_ELEMENT(client->keyboard), keyboard_name);
- g_free (keyboard_name);
-
keyboard_id = eekboard_context_add_keyboard (client->context,
- client->keyboard,
+ keyboard,
NULL);
eekboard_context_set_keyboard (client->context, keyboard_id, NULL);
- if (show)
- eekboard_context_show_keyboard (client->context, NULL);
return TRUE;
}
-static gboolean
-set_keyboard_from_xkl (EekboardClient *client,
- gboolean show,
- const gchar *model,
- const gchar *layouts,
- const gchar *options)
-{
- EekLayout *layout;
- gboolean retval;
-
- if (client->keyboard)
- g_object_unref (client->keyboard);
- layout = eek_xkl_layout_new ();
-
- if (model) {
- if (!eek_xkl_layout_set_model (EEK_XKL_LAYOUT(layout), model)) {
- g_object_unref (layout);
- return FALSE;
- }
- }
-
- if (layouts) {
- XklConfigRec *rec;
-
- rec = eekboard_xkl_config_rec_new_from_string (layouts);
- if (!eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(layout),
- rec->layouts)) {
- g_object_unref (rec);
- g_object_unref (layout);
- return FALSE;
- }
-
- if (!eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(layout),
- rec->variants)) {
- g_object_unref (rec);
- g_object_unref (layout);
- return FALSE;
- }
-
- g_object_unref (rec);
- }
-
- if (options) {
- gchar **_options;
-
- _options = g_strsplit (options, ",", -1);
- if (!eek_xkl_layout_set_options (EEK_XKL_LAYOUT(layout), _options)) {
- g_strfreev (_options);
- g_object_unref (layout);
- return FALSE;
- }
- }
-
- retval = set_keyboard (client, show, layout);
- g_object_unref (layout);
- return retval;
-}
-
static void
on_xkl_state_changed (XklEngine *xklengine,
XklEngineStateChange type,
@@ -827,14 +724,9 @@ on_xkl_state_changed (XklEngine *xklengine,
{
EekboardClient *client = user_data;
- if (type == GROUP_CHANGED && client->keyboard) {
- if (client->use_xkl_layout) {
- gint group = eek_element_get_group (EEK_ELEMENT(client->keyboard));
- if (group != value) {
- eekboard_context_set_group (client->context, value, NULL);
- }
- }
- client->group = value;
+ if (type == GROUP_CHANGED) {
+ if (client->use_xkl_layout)
+ eekboard_context_set_group (client->context, value, NULL);
}
}
@@ -918,7 +810,7 @@ get_keycode_from_gdk_keymap (EekboardClient *client,
return FALSE;
for (i = 0; i < n_keys; i++)
- if (keys[i].group == client->group)
+ if (keys[i].group == eekboard_context_get_group (client->context))
best_match = &keys[i];
*keycode = best_match->keycode;
@@ -953,17 +845,15 @@ send_fake_modifier_key_event (EekboardClient *client,
static void
send_fake_key_event (EekboardClient *client,
- EekKey *key,
+ EekSymbol *symbol,
+ guint keyboard_modifiers,
gboolean is_pressed)
{
GdkDisplay *display = gdk_display_get_default ();
- EekSymbol *symbol;
- EekModifierType keyboard_modifiers, modifiers;
+ EekModifierType modifiers;
guint xkeysym;
guint keycode, replaced_keysym = 0;
- symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
-
/* Ignore special keys and modifiers */
if (!EEK_IS_KEYSYM(symbol) || eek_symbol_is_modifier (symbol))
return;
@@ -982,10 +872,9 @@ send_fake_key_event (EekboardClient *client,
}
/* Clear level shift modifiers */
- keyboard_modifiers = eek_keyboard_get_modifiers (client->keyboard);
keyboard_modifiers &= ~EEK_SHIFT_MASK;
keyboard_modifiers &= ~EEK_LOCK_MASK;
- keyboard_modifiers &= ~eek_keyboard_get_alt_gr_mask (client->keyboard);
+ //keyboard_modifiers &= ~eek_keyboard_get_alt_gr_mask (client->keyboard);
modifiers |= keyboard_modifiers;
@@ -1007,20 +896,15 @@ send_fake_key_event (EekboardClient *client,
}
static void
-on_key_pressed (EekKeyboard *keyboard,
- EekKey *key,
- gpointer user_data)
+on_key_pressed (EekboardContext *context,
+ guint keycode,
+ EekSymbol *symbol,
+ guint modifiers,
+ gpointer user_data)
{
EekboardClient *client = user_data;
- send_fake_key_event (client, key, TRUE);
- send_fake_key_event (client, key, FALSE);
-}
-
-static void
-on_key_released (EekKeyboard *keyboard,
- EekKey *key,
- gpointer user_data)
-{
+ send_fake_key_event (client, symbol, modifiers, TRUE);
+ send_fake_key_event (client, symbol, modifiers, FALSE);
}
static void
@@ -1074,11 +958,8 @@ eekboard_client_enable_xtest (EekboardClient *client)
update_modifier_keycodes (client);
client->key_pressed_handler =
- g_signal_connect (client->keyboard, "key-pressed",
+ g_signal_connect (client->context, "key-pressed",
G_CALLBACK(on_key_pressed), client);
- client->key_released_handler =
- g_signal_connect (client->keyboard, "key-released",
- G_CALLBACK(on_key_released), client);
return TRUE;
}
@@ -1090,43 +971,5 @@ eekboard_client_disable_xtest (EekboardClient *client)
XkbFreeKeyboard (client->xkb, 0, TRUE); /* free_all = TRUE */
client->xkb = NULL;
}
-
- if (g_signal_handler_is_connected (client->keyboard,
- client->key_pressed_handler))
- g_signal_handler_disconnect (client->keyboard,
- client->key_pressed_handler);
- if (g_signal_handler_is_connected (client->keyboard,
- client->key_released_handler))
- g_signal_handler_disconnect (client->keyboard,
- client->key_released_handler);
}
-
-gboolean
-eekboard_client_load_keyboard_from_file (EekboardClient *client,
- const gchar *keyboard_file)
-{
- GFile *file;
- GFileInputStream *input;
- GError *error;
- EekLayout *layout;
- gboolean retval;
-
- file = g_file_new_for_path (keyboard_file);
-
- error = NULL;
- input = g_file_read (file, NULL, &error);
- if (input == NULL)
- return FALSE;
-
- layout = eek_xml_layout_new (G_INPUT_STREAM(input));
- g_object_unref (input);
-#if ENABLE_FOCUS_LISTENER
- retval = set_keyboard (client, !client->follows_focus, layout);
-#else /* ENABLE_FOCUS_LISTENER */
- retval = set_keyboard (client, TRUE, layout);
-#endif /* !ENABLE_FOCUS_LISTENER */
- g_object_unref (layout);
- return retval;
-}
-
#endif /* HAVE_XTEST */
diff --git a/src/client.h b/src/client.h
index 7d1a6a6d..670730b2 100644
--- a/src/client.h
+++ b/src/client.h
@@ -33,15 +33,9 @@ typedef struct _EekboardClient EekboardClient;
EekboardClient * eekboard_client_new (GDBusConnection *connection);
-gboolean eekboard_client_load_keyboard_from_file
+gboolean eekboard_client_set_keyboard
(EekboardClient *client,
- const gchar *file);
-
-gboolean eekboard_client_load_keyboard_from_xkl
- (EekboardClient *client,
- const gchar *model,
- const gchar *layouts,
- const gchar *options);
+ const gchar *keyboard);
gboolean eekboard_client_enable_xkl (EekboardClient *client);
void eekboard_client_disable_xkl (EekboardClient *client);
diff --git a/src/server-context.c b/src/server-context.c
index 8fe0573e..3c7535f8 100644
--- a/src/server-context.c
+++ b/src/server-context.c
@@ -32,8 +32,10 @@
#include "eek/eek-clutter.h"
#endif
#include "eek/eek-gtk.h"
+#include "eek/eek-xkl.h"
#include "server-context.h"
+#include "xklutil.h"
#define CSW 640
#define CSH 480
@@ -51,7 +53,7 @@ static const gchar introspection_xml[] =
""
" "
" "
- " "
+ " "
" "
" "
" "
@@ -79,13 +81,18 @@ static const gchar introspection_xml[] =
" "
" "
" "
- " "
- " "
- " "
+ " "
+ " "
" "
" "
" "
" "
+ " "
+ " "
+ " "
+ " "
+ " "
+ " "
" "
"";
@@ -206,8 +213,7 @@ on_realize_set_dock (GtkWidget *widget,
{
#ifdef HAVE_XDOCK
GdkWindow *window = gtk_widget_get_window (widget);
- Atom atoms[2] = { None, None };
- gint x, y, width, height, depth;
+ gint x, y, width, height;
long vals[12];
/* set window type to dock */
@@ -599,30 +605,29 @@ server_context_init (ServerContext *context)
static gboolean on_repeat_timeout (ServerContext *context);
static void
-emit_press_release_dbus_signal (ServerContext *context)
+emit_key_pressed_dbus_signal (ServerContext *context, EekKey *key)
{
if (context->connection && context->enabled) {
- guint keycode = eek_key_get_keycode (context->repeat_key);
+ guint keycode = eek_key_get_keycode (key);
+ EekSymbol *symbol = eek_key_get_symbol_with_fallback (key, 0, 0);
+ guint modifiers = eek_keyboard_get_modifiers (context->keyboard);
+ GVariant *variant;
GError *error;
+ variant = eek_serializable_serialize (EEK_SERIALIZABLE(symbol));
+
error = NULL;
g_dbus_connection_emit_signal (context->connection,
NULL,
context->object_path,
SERVER_CONTEXT_INTERFACE,
"KeyPressed",
- g_variant_new ("(u)", keycode),
- &error);
- g_assert_no_error (error);
-
- error = NULL;
- g_dbus_connection_emit_signal (context->connection,
- NULL,
- context->object_path,
- SERVER_CONTEXT_INTERFACE,
- "KeyReleased",
- g_variant_new ("(u)", keycode),
+ g_variant_new ("(uvu)",
+ keycode,
+ variant,
+ modifiers),
&error);
+ g_variant_unref (variant);
g_assert_no_error (error);
}
}
@@ -632,7 +637,7 @@ on_repeat_timeout (ServerContext *context)
{
gint delay = g_settings_get_int (context->settings, "repeat-interval");
- emit_press_release_dbus_signal (context);
+ emit_key_pressed_dbus_signal (context, context->repeat_key);
context->repeat_timeout_id =
g_timeout_add (delay,
@@ -645,7 +650,7 @@ on_repeat_timeout (ServerContext *context)
static gboolean
on_repeat_timeout_init (ServerContext *context)
{
- emit_press_release_dbus_signal (context);
+ emit_key_pressed_dbus_signal (context, context->repeat_key);
/* FIXME: clear modifiers for further key repeat; better not
depend on modifier behavior is LATCH */
@@ -690,39 +695,13 @@ on_key_released (EekKeyboard *keyboard,
gpointer user_data)
{
ServerContext *context = user_data;
- gboolean need_key_press = FALSE;
if (context->repeat_timeout_id > 0) {
g_source_remove (context->repeat_timeout_id);
context->repeat_timeout_id = 0;
- need_key_press = TRUE;
- }
- if (context->connection && context->enabled) {
- guint keycode = eek_key_get_keycode (key);
- GError *error;
-
- if (need_key_press) {
- error = NULL;
- g_dbus_connection_emit_signal (context->connection,
- NULL,
- context->object_path,
- SERVER_CONTEXT_INTERFACE,
- "KeyPressed",
- g_variant_new ("(u)", keycode),
- &error);
- g_assert_no_error (error);
- }
-
- error = NULL;
- g_dbus_connection_emit_signal (context->connection,
- NULL,
- context->object_path,
- SERVER_CONTEXT_INTERFACE,
- "KeyReleased",
- g_variant_new ("(u)", keycode),
- &error);
- g_assert_no_error (error);
+ /* KeyPressed signal has not been emitted in repeat handler */
+ emit_key_pressed_dbus_signal (context, context->repeat_key);
}
}
@@ -739,6 +718,60 @@ disconnect_keyboard_signals (ServerContext *context)
context->key_released_handler);
}
+static EekKeyboard *
+create_keyboard_from_string (const gchar *string)
+{
+ EekKeyboard *keyboard;
+ EekLayout *layout;
+
+ if (g_str_has_prefix (string, "xkl:")) {
+ XklConfigRec *rec = eekboard_xkl_config_rec_from_string (&string[4]);
+
+ layout = eek_xkl_layout_new ();
+ if (!eek_xkl_layout_set_config (EEK_XKL_LAYOUT(layout), rec)) {
+ g_object_unref (layout);
+ return NULL;
+ }
+ } else {
+ gchar *path;
+ GFile *file;
+ GFileInputStream *input;
+ GError *error;
+
+ path = g_strdup_printf ("%s/%s.xml", KEYBOARDDIR, string);
+ file = g_file_new_for_path (path);
+ g_free (path);
+
+ error = NULL;
+ input = g_file_read (file, NULL, &error);
+ if (input == NULL) {
+ g_object_unref (file);
+ return NULL;
+ }
+ layout = eek_xml_layout_new (G_INPUT_STREAM(input));
+ }
+ keyboard = eek_keyboard_new (layout, CSW, CSH);
+ g_object_unref (layout);
+
+ return keyboard;
+}
+
+static void
+emit_group_changed_signal (ServerContext *context, int group)
+{
+ GError *error;
+
+ error = NULL;
+ g_dbus_connection_emit_signal (context->connection,
+ NULL,
+ context->object_path,
+ SERVER_CONTEXT_INTERFACE,
+ "GroupChanged",
+ g_variant_new ("(i)", group),
+ &error);
+ g_assert_no_error (error);
+}
+
static void
handle_method_call (GDBusConnection *connection,
const gchar *sender,
@@ -752,26 +785,27 @@ handle_method_call (GDBusConnection *connection,
ServerContext *context = user_data;
if (g_strcmp0 (method_name, "AddKeyboard") == 0) {
- GVariant *variant;
- EekSerializable *serializable;
+ const gchar *name;
static guint keyboard_id = 0;
+ EekKeyboard *keyboard;
- g_variant_get (parameters, "(v)", &variant);
+ g_variant_get (parameters, "(&s)", &name);
+ keyboard = create_keyboard_from_string (name);
- serializable = eek_serializable_deserialize (variant);
- if (!EEK_IS_KEYBOARD(serializable)) {
+ if (keyboard == NULL) {
g_dbus_method_invocation_return_error (invocation,
G_IO_ERROR,
G_IO_ERROR_FAILED_HANDLED,
- "not a keyboard");
+ "can't create a keyboard");
return;
}
- eek_keyboard_set_modifier_behavior (EEK_KEYBOARD(serializable),
+
+ eek_keyboard_set_modifier_behavior (keyboard,
EEK_MODIFIER_BEHAVIOR_LATCH);
g_hash_table_insert (context->keyboard_hash,
GUINT_TO_POINTER(++keyboard_id),
- serializable);
+ keyboard);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(u)",
keyboard_id));
@@ -802,6 +836,7 @@ handle_method_call (GDBusConnection *connection,
if (g_strcmp0 (method_name, "SetKeyboard") == 0) {
EekKeyboard *keyboard;
guint keyboard_id;
+ gint group;
g_variant_get (parameters, "(u)", &keyboard_id);
@@ -847,6 +882,10 @@ handle_method_call (GDBusConnection *connection,
}
g_dbus_method_invocation_return_value (invocation, NULL);
+
+ eek_element_get_group (EEK_ELEMENT(context->keyboard));
+ emit_group_changed_signal (context, group);
+
return;
}
@@ -895,6 +934,9 @@ handle_method_call (GDBusConnection *connection,
}
g_dbus_method_invocation_return_value (invocation, NULL);
+
+ emit_group_changed_signal (context, group);
+
return;
}
diff --git a/src/xklutil.c b/src/xklutil.c
index 9fbe9433..a9a1fd16 100644
--- a/src/xklutil.c
+++ b/src/xklutil.c
@@ -21,13 +21,13 @@
#include "xklutil.h"
XklConfigRec *
-eekboard_xkl_config_rec_new_from_string (const gchar *layouts)
+eekboard_xkl_config_rec_from_string (const gchar *layouts)
{
XklConfigRec *rec;
gchar **l, **v;
gint i;
- l = g_strsplit (layouts, ",", -1);
+ l = g_strsplit (layouts, ":", -1);
v = g_strdupv (l);
for (i = 0; l[i]; i++) {
gchar *layout = l[i], *variant = v[i],
@@ -50,6 +50,36 @@ eekboard_xkl_config_rec_new_from_string (const gchar *layouts)
return rec;
}
+gchar *
+eekboard_xkl_config_rec_to_string (XklConfigRec *rec)
+{
+ gchar **strv, **sp, **lp, **vp, *p;
+ gint n_layouts;
+ GString *str;
+
+ n_layouts = g_strv_length (rec->layouts);
+ strv = g_malloc0_n (n_layouts + 2, sizeof (gchar *));
+ for (sp = strv, lp = rec->layouts, vp = rec->variants; *lp; sp++, lp++) {
+ if (*vp != NULL)
+ *sp = g_strdup_printf ("%s(%s)", *lp, *vp++);
+ else
+ *sp = g_strdup_printf ("%s", *lp);
+ }
+
+ str = g_string_new ("");
+ p = g_strjoinv (":", strv);
+ g_strfreev (strv);
+ g_string_append (str, p);
+ g_free (p);
+
+ g_string_append_c (str, ':');
+ p = g_strjoinv ("+", rec->options);
+ g_string_append (str, p);
+ g_free (p);
+
+ return g_string_free (str,FALSE);
+}
+
static XklConfigItem *
xkl_config_item_copy (const XklConfigItem *item)
{
diff --git a/src/xklutil.h b/src/xklutil.h
index 001f2ead..75db4683 100644
--- a/src/xklutil.h
+++ b/src/xklutil.h
@@ -24,16 +24,16 @@
G_BEGIN_DECLS
-XklConfigRec *eekboard_xkl_config_rec_new_from_string
- (const gchar *layouts);
+XklConfigRec *eekboard_xkl_config_rec_from_string (const gchar *layouts);
+gchar *eekboard_xkl_config_rec_to_string (XklConfigRec *rec);
-GSList *eekboard_xkl_list_models (XklConfigRegistry *registry);
-GSList *eekboard_xkl_list_layouts (XklConfigRegistry *registry);
-GSList *eekboard_xkl_list_option_groups (XklConfigRegistry *registry);
-GSList *eekboard_xkl_list_layout_variants (XklConfigRegistry *registry,
- const gchar *layout);
-GSList *eekboard_xkl_list_options (XklConfigRegistry *registry,
- const gchar *group);
+GSList *eekboard_xkl_list_models (XklConfigRegistry *registry);
+GSList *eekboard_xkl_list_layouts (XklConfigRegistry *registry);
+GSList *eekboard_xkl_list_option_groups (XklConfigRegistry *registry);
+GSList *eekboard_xkl_list_layout_variants (XklConfigRegistry *registry,
+ const gchar *layout);
+GSList *eekboard_xkl_list_options (XklConfigRegistry *registry,
+ const gchar *group);
G_END_DECLS
#endif /* EEKBOARD_XKLUTIL_H */
diff --git a/src/xml-main.c b/src/xml-main.c
index 38548767..9cb43488 100644
--- a/src/xml-main.c
+++ b/src/xml-main.c
@@ -201,7 +201,7 @@ main (int argc, char **argv)
if (opt_layouts) {
XklConfigRec *rec;
- rec = eekboard_xkl_config_rec_new_from_string (opt_layouts);
+ rec = eekboard_xkl_config_rec_from_string (opt_layouts);
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(layout), rec->layouts);
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(layout), rec->variants);
g_object_unref (rec);