Separate ibus-ui-gtk3 as ibus-panel sub package depended on libdbusmenu

- Update autogen.sh for Fedora 39
- Fix cursor position with GTK4 in Xorg
This commit is contained in:
Takao Fujiwara 2023-08-18 20:12:30 +09:00
parent 2fbf6a67b8
commit b38ab9abe3
2 changed files with 264 additions and 4 deletions

View File

@ -0,0 +1,240 @@
From f05c12dafef83cdd6b0f988d86e4411794c7e44f Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 9 Aug 2023 11:35:21 +0900
Subject: [PATCH] github/workflows: Fix Fedora 39 DNF
- Check latest gnome-shell-extension-no-overview
- Add various configure options
---
autogen.sh | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/autogen.sh b/autogen.sh
index 4ea8d757..05682f47 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -47,9 +47,10 @@ cd "$srcdir"
rpm -q $FEDORA_PKG1 || exit 1
rpm -q $FEDORA_PKG2 || exit 1
rpm -q $FEDORA_PKG3 || exit 1
- dnf update --assumeno $FEDORA_PKG1 || exit 1
- dnf update --assumeno $FEDORA_PKG2 || exit 1
- dnf update --assumeno $FEDORA_PKG3 || exit 1
+ (grep -qE '37|38' /etc/fedora-release) && DNF=dnf || DNF=dnf5
+ $DNF update --assumeno $FEDORA_PKG1 || exit 1
+ $DNF update --assumeno $FEDORA_PKG2 || exit 1
+ $DNF update --assumeno $FEDORA_PKG3 || exit 1
}
}
--
2.41.0
From 86d9bb9a1cbd4ffbd6bc2a4de85cb76a43bc2ced Mon Sep 17 00:00:00 2001
From: Peng Wu <pwu@redhat.com>
Date: Mon, 24 Jul 2023 14:04:12 +0800
Subject: [PATCH] client/gtk2: Update set_cursor_location function to use Gdk
functions
For ibus-gtk4, use the Gdk functions to get the inner cursor location.
The inner cursor location is translated by XTranslateCoordinates
for X Window.
For ibus-gtk3, use gdk_window_get_root_coords function to translate the
inner cursor location for X Window.
In Wayland, the set_cursor_location_relative function is called.
In X Window, the set_cursor_location function is called.
Fixes: https://github.com/ibus/ibus/commit/d0a47c3
Fixes: https://github.com/ibus/ibus/commit/a823161
BUG=https://github.com/ibus/ibus/pull/2549
BUG=https://gitlab.gnome.org/GNOME/gtk/-/issues/3024#note_987835
---
client/gtk2/ibusimcontext.c | 141 +++++++++++++++---------------------
1 file changed, 58 insertions(+), 83 deletions(-)
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 7ccc129d..b5a44da0 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <gtk/gtk.h>
+#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <ibus.h>
#include "ibusimcontext.h"
@@ -1612,8 +1613,13 @@ static gboolean
_set_cursor_location_internal (IBusIMContext *ibusimcontext)
{
GdkRectangle area;
+ GdkDisplay *display = NULL;
#if GTK_CHECK_VERSION (3, 98, 4)
GtkWidget *root;
+ GtkNative *native;
+ graphene_point_t p;
+ int tx = 0, ty = 0;
+ double nx = 0., ny = 0.;
#endif
if(ibusimcontext->client_window == NULL ||
@@ -1623,103 +1629,72 @@ _set_cursor_location_internal (IBusIMContext *ibusimcontext)
area = ibusimcontext->cursor_area;
-#ifdef GDK_WINDOWING_WAYLAND
#if GTK_CHECK_VERSION (3, 98, 4)
root = GTK_WIDGET (gtk_widget_get_root (ibusimcontext->client_window));
- /* FIXME: GTK_STYLE_CLASS_TITLEBAR is available in GTK3 but not GTK4.
- * gtk_css_boxes_get_content_rect() is available in GTK4 but it's an
- * internal API and calculate the window edge 32 in GTK3.
- */
- area.y += 32;
- area.width = 50; /* FIXME: Why 50 meets the cursor position? */
- area.height = gtk_widget_get_height (root);
- area.height += 32;
- if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) {
- ibus_input_context_set_cursor_location_relative (
- ibusimcontext->ibuscontext,
- area.x,
- area.y,
- area.width,
- area.height);
- return FALSE;
- }
-#else
- if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) {
- gdouble px, py;
- GdkWindow *parent;
- GdkWindow *window = ibusimcontext->client_window;
-
- while ((parent = gdk_window_get_effective_parent (window)) != NULL) {
- gdk_window_coords_to_parent (window, area.x, area.y, &px, &py);
- area.x = px;
- area.y = py;
- window = parent;
- }
-
- _set_rect_scale_factor_with_window (&area,
- ibusimcontext->client_window);
- ibus_input_context_set_cursor_location_relative (
- ibusimcontext->ibuscontext,
- area.x,
- area.y,
- area.width,
- area.height);
- return FALSE;
+ /* Translates the given point in client_window coordinates to coordinates
+ relative to root coordinate system. */
+ if (!gtk_widget_compute_point (ibusimcontext->client_window,
+ root,
+ &GRAPHENE_POINT_INIT (area.x, area.y),
+ &p)) {
+ graphene_point_init (&p, area.x, area.y);
}
-#endif
-#endif
-#if GTK_CHECK_VERSION (3, 98, 4)
-#elif GTK_CHECK_VERSION (2, 91, 0)
- if (area.x == -1 && area.y == -1 && area.width == 0 && area.height == 0) {
- area.x = 0;
- area.y += gdk_window_get_height (ibusimcontext->client_window);
- }
-#else
- if (area.x == -1 && area.y == -1 && area.width == 0 && area.height == 0) {
- gint w, h;
- gdk_drawable_get_size (ibusimcontext->client_window, &w, &h);
- area.y += h;
- area.x = 0;
- }
-#endif
+ native = gtk_widget_get_native (ibusimcontext->client_window);
+ /* Translates from the surface coordinates into the widget coordinates. */
+ gtk_native_get_surface_transform (native, &nx, &ny);
-#if GTK_CHECK_VERSION (3, 98, 4)
-#if defined(GDK_WINDOWING_X11)
- GdkDisplay *display = gtk_widget_get_display (ibusimcontext->client_window);
+ display = gtk_widget_get_display (ibusimcontext->client_window);
if (GDK_IS_X11_DISPLAY (display)) {
- Display *xdisplay = gdk_x11_display_get_xdisplay (display);
- Window root_window = gdk_x11_display_get_xrootwindow (display);
- GtkNative *native = gtk_widget_get_native (
- ibusimcontext->client_window);
- GdkSurface *surface = gtk_native_get_surface (native);
- /* The window is the toplevel window but not the inner text widget.
- * Unfortunatelly GTK4 cannot get the coordinate of the text widget.
- */
- Window window = gdk_x11_surface_get_xid (surface);
+ GdkSurface *surface = gtk_native_get_surface
+ (gtk_widget_get_native (ibusimcontext->client_window));
Window child;
- int x, y;
- XTranslateCoordinates (xdisplay, window, root_window,
- 0, 0, &x, &y, &child);
- XWindowAttributes xwa;
- XGetWindowAttributes (xdisplay, window, &xwa);
- area.x = x - xwa.x + area.x;
- area.y = y - xwa.y + area.y;
- area.width = 50; /* FIXME: Why 50 meets the cursor position? */
- area.height = xwa.height;
+ int scale_factor = gtk_widget_get_scale_factor
+ (ibusimcontext->client_window);
+
+ XTranslateCoordinates (GDK_DISPLAY_XDISPLAY (display),
+ GDK_SURFACE_XID (surface),
+ gdk_x11_display_get_xrootwindow (display),
+ 0, 0, &tx, &ty,
+ &child);
+
+ tx = tx / scale_factor;
+ ty = ty / scale_factor;
}
-#endif
+
+ area.x = p.x + nx + tx;
+ area.y = p.y + ny + ty;
#else
gdk_window_get_root_coords (ibusimcontext->client_window,
area.x, area.y,
&area.x, &area.y);
#endif
+
_set_rect_scale_factor_with_window (&area, ibusimcontext->client_window);
- ibus_input_context_set_cursor_location (ibusimcontext->ibuscontext,
- area.x,
- area.y,
- area.width,
- area.height);
+
+#ifdef GDK_WINDOWING_WAYLAND
+#if !GTK_CHECK_VERSION (3, 98, 4)
+ display = gdk_window_get_display (ibusimcontext->client_window);
+#endif
+
+ if (GDK_IS_WAYLAND_DISPLAY (display)) {
+ ibus_input_context_set_cursor_location_relative (ibusimcontext->ibuscontext,
+ area.x,
+ area.y,
+ area.width,
+ area.height);
+
+ } else {
+#endif
+ ibus_input_context_set_cursor_location (ibusimcontext->ibuscontext,
+ area.x,
+ area.y,
+ area.width,
+ area.height);
+#ifdef GDK_WINDOWING_WAYLAND
+ }
+#endif
+
return FALSE;
}
--
2.41.0

View File

@ -52,7 +52,7 @@
Name: ibus
Version: 1.5.29~beta2
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@ -60,6 +60,7 @@ Source0: https://github.com/ibus/%name/releases/download/%{source_version
Source1: %{name}-xinput
Source2: %{name}.conf.5
# Patch0: %%{name}-HEAD.patch
Patch0: %{name}-HEAD.patch
# Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577
Patch1: %{name}-1385349-segv-bus-proxy.patch
%if 0%{?fedora:0}%{?rhel:1}
@ -97,7 +98,6 @@ BuildRequires: intltool
BuildRequires: git
BuildRequires: vala
BuildRequires: iso-codes-devel
BuildRequires: libdbusmenu-gtk3-devel
BuildRequires: libnotify-devel
BuildRequires: wayland-devel
BuildRequires: cldr-emoji-annotation
@ -247,6 +247,17 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
%description wayland
This package contains IBus IM module for Wayland
%package panel
Summary: IBus Panel icon
Requires: %{name}%{?_isa} = %{version}-%{release}
BuildRequires: libdbusmenu-gtk3-devel
%description panel
This package contains IBus Panel icon using GtkStatusIcon or AppIndicator
in non-GNOME desktop sessions likes XFCE or Plasma because gnome-shell
shows the IBus Icon. This package depends on libdbusmenu-gtk3 for Wayland
desktop sessions.
%package devel
Summary: Development tools for ibus
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
@ -297,6 +308,8 @@ the functionality of the installed %{name} package.
# cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c || :
# cp client/gtk2/ibusim.c client/gtk3/ibusim.c || :
# cp client/gtk2/ibusimcontext.c client/gtk4/ibusimcontext.c || :
cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c || :
cp client/gtk2/ibusimcontext.c client/gtk4/ibusimcontext.c || :
# prep test
@ -441,7 +454,6 @@ dconf update || :
%{_bindir}/ibus-daemon
%{_datadir}/applications/org.freedesktop.IBus.Panel.Emojier.desktop
%{_datadir}/applications/org.freedesktop.IBus.Panel.Extension.Gtk3.desktop
%{_datadir}/applications/org.freedesktop.IBus.Panel.Wayland.Gtk3.desktop
%{_datadir}/bash-completion/completions/ibus.bash
%{_datadir}/dbus-1/services/*.service
%{_datadir}/GConf/gsettings/*
@ -462,7 +474,6 @@ dconf update || :
%{_libexecdir}/ibus-portal
%{_libexecdir}/ibus-extension-gtk3
%{_libexecdir}/ibus-ui-emojier
%{_libexecdir}/ibus-ui-gtk3
%{_libexecdir}/ibus-x11
%{_sysconfdir}/dconf/db/ibus.d
%{_sysconfdir}/dconf/profile/ibus
@ -526,6 +537,10 @@ dconf update || :
%files wayland
%{_libexecdir}/ibus-wayland
%files panel
%{_datadir}/applications/org.freedesktop.IBus.Panel.Wayland.Gtk3.desktop
%{_libexecdir}/ibus-ui-gtk3
%files devel
%{_libdir}/ibus
%{_libdir}/lib*.so
@ -557,6 +572,11 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Fri Aug 18 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~beta2-2
- Separate ibus-ui-gtk3 as ibus-panel sub package depended on libdbusmenu
- Update autogen.sh for Fedora 39
- Fix cursor position with GTK4 in Xorg
* Tue Aug 08 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~beta2-1
- Distinguish Arabic XKB and Keypad XKB options