summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-11-19 18:10:05 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2014-11-19 18:10:05 +0900
commita7abce698f40e60275c46f05967e8cc369769e4b (patch)
tree1ebf35c264737157bfc750e9de6e6677114fea48
parentde3541d2a26c673f27c068559f6d363064e03760 (diff)
downloadibus-a7abce698f40e60275c46f05967e8cc369769e4b.tar.gz
Fixes ibus_engine_update_lookup_table_fast method
gnome shell needs the previous page and next page to correctly show the page up/down arrows, send three pages instead of one page. URL: https://bugzilla.gnome.org/show_bug.cgi?id=703020 BUG= Review URL: https://codereview.appspot.com/164540045 Patch from Peng Wu <alexepico@gmail.com>.
-rw-r--r--src/ibusengine.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/ibusengine.c b/src/ibusengine.c
index 53d57df1..4758f82f 100644
--- a/src/ibusengine.c
+++ b/src/ibusengine.c
@@ -1422,12 +1422,17 @@ ibus_engine_update_lookup_table_fast (IBusEngine *engine,
IBusLookupTable *table,
gboolean visible)
{
+ /* Note: gnome shell needs the previous page and next page
+ to correctly show the page up/down arrows,
+ send three pages instead of one page. */
+
g_return_if_fail (IBUS_IS_ENGINE (engine));
g_return_if_fail (IBUS_IS_LOOKUP_TABLE (table));
IBusLookupTable *new_table;
IBusText *text;
gint page_begin;
+ gint cursor_pos;
gint i;
if (table->candidates->len < table->page_size << 2) {
@@ -1436,19 +1441,31 @@ ibus_engine_update_lookup_table_fast (IBusEngine *engine,
}
page_begin = (table->cursor_pos / table->page_size) * table->page_size;
+ cursor_pos = ibus_lookup_table_get_cursor_in_page (table);
+
+ if (table->cursor_pos >= table->page_size) {
+ /* has previous page, adjust the value. */
+ page_begin -= table->page_size;
+ cursor_pos += table->page_size;
+ }
- new_table = ibus_lookup_table_new (table->page_size, 0, table->cursor_visible, table->round);
+ new_table = ibus_lookup_table_new
+ (table->page_size, 0, table->cursor_visible, table->round);
- for (i = page_begin; i < page_begin + table->page_size && i < table->candidates->len; i++) {
- ibus_lookup_table_append_candidate (new_table, ibus_lookup_table_get_candidate (table, i));
+ /* '3' means the previous page, current page and next page. */
+ for (i = page_begin; i < page_begin + 3 * table->page_size &&
+ i < table->candidates->len; i++) {
+ ibus_lookup_table_append_candidate
+ (new_table, ibus_lookup_table_get_candidate (table, i));
}
for (i = 0; (text = ibus_lookup_table_get_label (table, i)) != NULL; i++) {
ibus_lookup_table_append_label (new_table, text);
}
- ibus_lookup_table_set_cursor_pos (new_table, ibus_lookup_table_get_cursor_in_page (table));
- ibus_lookup_table_set_orientation (new_table, ibus_lookup_table_get_orientation (table));
+ ibus_lookup_table_set_cursor_pos (new_table, cursor_pos);
+ ibus_lookup_table_set_orientation
+ (new_table, ibus_lookup_table_get_orientation (table));
ibus_engine_update_lookup_table (engine, new_table, visible);