Resolve #2188800 Error handling with display == null

- Enhance #2237486 Implement preedit color in Plasma Wayland
This commit is contained in:
Takao Fujiwara 2023-11-25 14:11:26 +09:00
parent 5206f63c4d
commit 31e3c61bbd
2 changed files with 114 additions and 14 deletions

View File

@ -1,6 +1,6 @@
From db829f4aee399e5472bd55dc630a94425e72bacd Mon Sep 17 00:00:00 2001
From 59944ddbfe915f195e757c509246b597048116cf Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Sat, 30 Sep 2023 09:51:43 +0900
Date: Sat, 25 Nov 2023 13:42:31 +0900
Subject: [PATCH] client/wayland: Implement preedit color in Plasma Wayland
Wayland input-method protocol version 1 supports the preedit style
@ -18,10 +18,10 @@ Rf. https://github.com/ibus/ibus/wiki/Wayland-Colors
BUG=rhbz#2237486
---
client/wayland/Makefile.am | 1 +
client/wayland/ibuswaylandim.c | 176 +++-
client/wayland/ibuswaylandim.c | 204 ++++-
.../text-input-unstable-v1-client-protocol.h | 847 ++++++++++++++++++
src/ibusattribute.h | 52 +-
4 files changed, 1073 insertions(+), 3 deletions(-)
4 files changed, 1101 insertions(+), 3 deletions(-)
create mode 100644 client/wayland/text-input-unstable-v1-client-protocol.h
diff --git a/client/wayland/Makefile.am b/client/wayland/Makefile.am
@ -37,7 +37,7 @@ index 7e8d18af..94e357b4 100644
ibus_wayland_SOURCES = \
diff --git a/client/wayland/ibuswaylandim.c b/client/wayland/ibuswaylandim.c
index ffc20de1..37966dd6 100644
index 8f938288..9e8f651e 100644
--- a/client/wayland/ibuswaylandim.c
+++ b/client/wayland/ibuswaylandim.c
@@ -32,6 +32,7 @@
@ -56,7 +56,7 @@ index ffc20de1..37966dd6 100644
IBusModifierType modifiers;
struct xkb_context *xkb_context;
@@ -266,12 +268,176 @@ _context_forward_key_event_cb (IBusInputContext *context,
@@ -266,12 +268,204 @@ _context_forward_key_event_cb (IBusInputContext *context,
}
@ -77,6 +77,8 @@ index ffc20de1..37966dd6 100644
+ guint i;
+ const char *str;
+ uint32_t whole_wstyle = ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_DEFAULT;
+ uint32_t prev_start = 0;
+ uint32_t prev_end = 0;
+
+ g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
+ priv = ibus_wayland_im_get_instance_private (wlim);
@ -175,14 +177,40 @@ index ffc20de1..37966dd6 100644
+ whole_wstyle = wstyle;
+ continue;
+ }
+ if (start > end) {
+ g_warning ("Wrong start %d and end %d for %s", start, end, str);
+ if (end < prev_start) {
+ if (priv->log) {
+ fprintf (priv->log,
+ "Reverse order is not supported in end %d for %s "
+ "against start %d.\n", end, str, prev_start);
+ fflush (priv->log);
+ }
+ continue;
+ }
+ if (prev_end > end) {
+ if (priv->log) {
+ fprintf (priv->log,
+ "Nested styles are not supported in end %d for %s "
+ "against end %d.\n", end, str, prev_end);
+ fflush (priv->log);
+ }
+ continue;
+ }
+ if (prev_end > start && prev_start >= start)
+ start = prev_end;
+ if (start >= end) {
+ if (priv->log) {
+ fprintf (priv->log, "Wrong start %d and end %d for %s.\n",
+ start, end, str);
+ fflush (priv->log);
+ }
+ return;
+ }
+ zwp_input_method_context_v1_preedit_styling (priv->context,
+ start,
+ end - start,
+ wstyle);
+ prev_start = start;
+ prev_end = end;
+ }
+ if (whole_wstyle != ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_DEFAULT) {
+ uint32_t whole_start = 0;
@ -233,7 +261,7 @@ index ffc20de1..37966dd6 100644
g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
priv = ibus_wayland_im_get_instance_private (wlim);
/* CURSOR is byte offset. */
@@ -282,10 +448,13 @@ _context_show_preedit_text_cb (IBusInputContext *context,
@@ -282,10 +476,13 @@ _context_show_preedit_text_cb (IBusInputContext *context,
zwp_input_method_context_v1_preedit_cursor (priv->context,
cursor);
@ -248,7 +276,7 @@ index ffc20de1..37966dd6 100644
}
@@ -308,6 +477,7 @@ _context_update_preedit_text_cb (IBusInputContext *context,
@@ -308,6 +505,7 @@ _context_update_preedit_text_cb (IBusInputContext *context,
IBusText *text,
gint cursor_pos,
gboolean visible,
@ -256,7 +284,7 @@ index ffc20de1..37966dd6 100644
IBusWaylandIM *wlim)
{
IBusWaylandIMPrivate *priv;
@@ -317,6 +487,7 @@ _context_update_preedit_text_cb (IBusInputContext *context,
@@ -317,6 +515,7 @@ _context_update_preedit_text_cb (IBusInputContext *context,
g_object_unref (priv->preedit_text);
priv->preedit_text = g_object_ref_sink (text);
priv->preedit_cursor_pos = cursor_pos;
@ -264,7 +292,7 @@ index ffc20de1..37966dd6 100644
if (visible)
_context_show_preedit_text_cb (context, wlim);
@@ -977,7 +1148,7 @@ _create_input_context_done (GObject *object,
@@ -971,7 +1170,7 @@ _create_input_context_done (GObject *object,
G_CALLBACK (_context_forward_key_event_cb),
wlim);
@ -273,7 +301,7 @@ index ffc20de1..37966dd6 100644
G_CALLBACK (_context_update_preedit_text_cb),
wlim);
g_signal_connect (priv->ibuscontext, "show-preedit-text",
@@ -994,6 +1165,7 @@ _create_input_context_done (GObject *object,
@@ -988,6 +1187,7 @@ _create_input_context_done (GObject *object,
capabilities |= IBUS_CAP_SYNC_PROCESS_KEY_V2;
ibus_input_context_set_capabilities (priv->ibuscontext,
capabilities);
@ -1240,3 +1268,71 @@ index b5a44da0..cfc08c20 100644
--
2.41.0
From 0a7a4d1dfa580dfcc65d76a697f40094085e55a2 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Sat, 25 Nov 2023 13:42:07 +0900
Subject: [PATCH] ui/gtk3: Error handling with display == null
BUG=rhbz#2188800
---
ui/gtk3/bindingcommon.vala | 6 +++++-
ui/gtk3/panel.vala | 14 ++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/ui/gtk3/bindingcommon.vala b/ui/gtk3/bindingcommon.vala
index da324f70..588be17a 100644
--- a/ui/gtk3/bindingcommon.vala
+++ b/ui/gtk3/bindingcommon.vala
@@ -263,10 +263,14 @@ class BindingCommon {
return m_default_is_xdisplay;
}
- public static Gdk.X11.Display get_xdisplay() {
+ public static Gdk.X11.Display? get_xdisplay() {
if (m_xdisplay != null)
return m_xdisplay;
var display = Gdk.Display.get_default();
+ if (display == null) {
+ error("You should open a display for IBus panel.");
+ return null;
+ }
Type instance_type = display.get_type();
Type x11_type = typeof(Gdk.X11.Display);
if (instance_type.is_a(x11_type)) {
diff --git a/ui/gtk3/panel.vala b/ui/gtk3/panel.vala
index f1bbd720..783ec842 100644
--- a/ui/gtk3/panel.vala
+++ b/ui/gtk3/panel.vala
@@ -1422,9 +1422,12 @@ class Panel : IBus.PanelService {
Gdk.Display display_backup = null;
if (use_x11 && !BindingCommon.default_is_xdisplay()) {
+ var display = BindingCommon.get_xdisplay();
display_backup = Gdk.Display.get_default();
- Gdk.DisplayManager.get().set_default_display(
- (Gdk.Display)BindingCommon.get_xdisplay());
+ if (display != null) {
+ Gdk.DisplayManager.get().set_default_display(
+ (Gdk.Display)display);
+ }
}
// Show system menu
@@ -1476,9 +1479,12 @@ class Panel : IBus.PanelService {
private Gtk.Menu create_activate_menu(bool use_x11 = false) {
Gdk.Display display_backup = null;
if (use_x11 && !BindingCommon.default_is_xdisplay()) {
+ var display = BindingCommon.get_xdisplay();
display_backup = Gdk.Display.get_default();
- Gdk.DisplayManager.get().set_default_display(
- (Gdk.Display)BindingCommon.get_xdisplay());
+ if (display != null) {
+ Gdk.DisplayManager.get().set_default_display(
+ (Gdk.Display)display);
+ }
}
m_ime_menu = new Gtk.Menu();
--
2.41.0

View File

@ -58,7 +58,7 @@
Name: ibus
Version: 1.5.29~rc2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@ -580,6 +580,10 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Sat Nov 25 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc2-3
- Resolve #2188800 Error handling with display == null
- Enhance #2237486 Implement preedit color in Plasma Wayland
* Wed Nov 15 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc2-2
- Call strdup() after g_return_if_fail() in im-ibus.so