Skip to content

Commit

Permalink
Add shadow margin support to gtk client side input panel
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Apr 8, 2022
1 parent 67faf18 commit 8881d7a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions gtk3/fcitxtheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ void InputPanelThemeConfig::load(GKeyFile *file) {
prev.load(file, "InputPanel/PrevPage");
next.load(file, "InputPanel/NextPage");
blurMargin.load(file, "InputPanel/BlurMargin");
shadowMargin.load(file, "InputPanel/ShadowMargin");
}

void MarginConfig::load(GKeyFile *file, const char *group) {
Expand Down
1 change: 1 addition & 0 deletions gtk3/fcitxtheme.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct InputPanelThemeConfig {
ActionImageConfig prev;
ActionImageConfig next;
MarginConfig blurMargin;
MarginConfig shadowMargin;
};

class ThemeImage {
Expand Down
9 changes: 9 additions & 0 deletions gtk3/gtk3inputwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
*/
#include "gtk3inputwindow.h"
#include "fcitxtheme.h"
#include <gtk/gtk.h>

namespace fcitx::gtk {
Expand Down Expand Up @@ -88,6 +89,14 @@ void Gtk3InputWindow::update() {
pango_cairo_context_set_resolution(context_.get(), dpi_);
std::tie(width_, height_) = sizeHint();

if (auto gdkWindow = gtk_widget_get_window(window_.get())) {
gdk_window_set_shadow_width(
gdkWindow, config_->theme_.shadowMargin.marginLeft,
config_->theme_.shadowMargin.marginRight,
config_->theme_.shadowMargin.marginTop,
config_->theme_.shadowMargin.marginBottom);
}

gtk_widget_realize(window_.get());
gtk_window_resize(GTK_WINDOW(window_.get()), width_, height_);
gtk_widget_queue_draw(window_.get());
Expand Down
7 changes: 7 additions & 0 deletions gtk4/gtk4inputwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include "gtk4inputwindow.h"
#include <gtk/gtk.h>
#include <gtk3/fcitxtheme.h>

namespace fcitx::gtk {

Expand Down Expand Up @@ -143,6 +144,12 @@ void Gtk4InputWindow::reposition() {
gdk_popup_layout_set_anchor_hints(
popupLayout,
static_cast<GdkAnchorHints>(GDK_ANCHOR_SLIDE_X | GDK_ANCHOR_FLIP_Y));

gdk_popup_layout_set_shadow_width(
popupLayout, config_->theme_.shadowMargin.marginLeft,
config_->theme_.shadowMargin.marginRight,
config_->theme_.shadowMargin.marginTop,
config_->theme_.shadowMargin.marginBottom);
gdk_popup_present(GDK_POPUP(window_.get()), width_, height_, popupLayout);
gdk_popup_layout_unref(popupLayout);
}
Expand Down

0 comments on commit 8881d7a

Please sign in to comment.