1 /*
2  * SPDX-FileCopyrightText: 2021~2021 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _GTK3_GTK3INPUTWINDOW_H_
8 #define _GTK3_GTK3INPUTWINDOW_H_
9 
10 #include "inputwindow.h"
11 #include <gtk/gtk.h>
12 
13 namespace fcitx::gtk {
14 
15 class Gtk4InputWindow : public InputWindow {
16 public:
17     Gtk4InputWindow(ClassicUIConfig *config, FcitxGClient *client);
18 
19     ~Gtk4InputWindow();
20 
21     void setParent(GtkWidget *parent);
22     void update() override;
23     void setCursorRect(GdkRectangle rect);
24 
25 private:
26     void draw(cairo_t *cr);
27     gboolean event(GdkEvent *event);
28     void reposition();
29     void surfaceNotifyMapped(GdkSurface *surface);
30     void resetWindow();
31     void syncFontOptions();
32 
33     bool supportAlpha = false;
34     // Dummy widget to track font options.
35     UniqueCPtr<GtkWindow, gtk_window_destroy> dummyWidget_;
36     UniqueCPtr<GdkSurface, gdk_surface_destroy> window_;
37     UniqueCPtr<GdkCairoContext, g_object_unref> cairoCcontext_;
38     GtkWidget *parent_ = nullptr;
39     size_t width_ = 1;
40     size_t height_ = 1;
41     GdkRectangle rect_;
42     double scrollDelta_ = 0;
43 };
44 
45 } // namespace fcitx::gtk
46 
47 #endif // _GTK3_GTK3INPUTWINDOW_H_
48