From c354d3e355f716624e2c9612e25c4600f8d6e877 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Wed, 25 Dec 2024 20:22:52 -0800 Subject: [PATCH] Clang-tidy clean up for classic ui --- src/ui/classic/buffer.cpp | 11 +++-- src/ui/classic/buffer.h | 4 +- src/ui/classic/classicui.cpp | 32 +++++++++++-- src/ui/classic/classicui.h | 30 +++++++----- src/ui/classic/common.h | 8 ++-- src/ui/classic/inputwindow.cpp | 64 ++++++++++++++++++------- src/ui/classic/inputwindow.h | 24 +++++++--- src/ui/classic/plasmathemewatchdog.cpp | 1 + src/ui/classic/plasmathemewatchdog.h | 1 + src/ui/classic/portalsettingmonitor.cpp | 10 +++- src/ui/classic/portalsettingmonitor.h | 7 ++- src/ui/classic/theme.h | 2 +- src/ui/classic/waylandcursortheme.cpp | 8 +++- src/ui/classic/waylandcursortheme.h | 4 +- src/ui/classic/waylandinputwindow.cpp | 39 +++++++++------ src/ui/classic/waylandinputwindow.h | 9 ++-- src/ui/classic/waylandpointer.cpp | 3 ++ src/ui/classic/waylandpointer.h | 10 ++-- src/ui/classic/waylandshmwindow.cpp | 12 ++++- src/ui/classic/waylandshmwindow.h | 14 ++++-- src/ui/classic/waylandui.cpp | 7 ++- src/ui/classic/waylandui.h | 15 ++++-- src/ui/classic/waylandwindow.cpp | 3 ++ src/ui/classic/waylandwindow.h | 12 +++-- src/ui/classic/window.cpp | 2 +- src/ui/classic/window.h | 9 ++-- src/ui/classic/xcbinputwindow.cpp | 15 ++++++ src/ui/classic/xcbinputwindow.h | 12 +++-- src/ui/classic/xcbmenu.cpp | 24 +++++++++- src/ui/classic/xcbmenu.h | 21 ++++++-- src/ui/classic/xcbtraywindow.cpp | 28 +++++++++-- src/ui/classic/xcbtraywindow.h | 16 +++++-- src/ui/classic/xcbui.h | 20 ++++++-- src/ui/classic/xcbwindow.cpp | 7 +++ src/ui/classic/xcbwindow.h | 14 ++++-- 35 files changed, 373 insertions(+), 125 deletions(-) diff --git a/src/ui/classic/buffer.cpp b/src/ui/classic/buffer.cpp index 015d85702..025245d91 100644 --- a/src/ui/classic/buffer.cpp +++ b/src/ui/classic/buffer.cpp @@ -6,15 +6,20 @@ */ #include "buffer.h" #include -#include #include #include +#include +#include +#include #include +#include #include #include #include +#include +#include "fcitx-utils/fs.h" #include "fcitx-utils/stringutils.h" -#include "theme.h" +#include "fcitx-utils/unixfd.h" #include "wl_buffer.h" #include "wl_callback.h" #include "wl_shm.h" @@ -28,7 +33,7 @@ namespace fcitx::wayland { __VA_ARGS__; \ } while (ret < 0 && errno == EINTR) -UnixFD openShm(void) { +UnixFD openShm() { int ret; // We support multiple different methods, memfd / shm_open on BSD / // O_TMPFILE. While linux has shm_open, it doesn't have SHM_ANON extension diff --git a/src/ui/classic/buffer.h b/src/ui/classic/buffer.h index 749ea1291..28ee1a316 100644 --- a/src/ui/classic/buffer.h +++ b/src/ui/classic/buffer.h @@ -7,10 +7,12 @@ #ifndef _FCITX_WAYLAND_CORE_BUFFER_H_ #define _FCITX_WAYLAND_CORE_BUFFER_H_ +#include #include #include -#include +#include #include +#include "fcitx-utils/misc.h" #include "fcitx-utils/signals.h" namespace fcitx { diff --git a/src/ui/classic/classicui.cpp b/src/ui/classic/classicui.cpp index 1a90d0ebd..0dfa8e2e5 100644 --- a/src/ui/classic/classicui.cpp +++ b/src/ui/classic/classicui.cpp @@ -7,24 +7,49 @@ #include "classicui.h" #include +#include +#include +#include +#include +#include #include +#include +#include #include #include +#include +#include +#include +#include #include "fcitx-config/iniparser.h" +#include "fcitx-config/rawconfig.h" +#include "fcitx-utils/color.h" #include "fcitx-utils/dbus/message_details.h" +#include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/fs.h" +#include "fcitx-utils/i18n.h" +#include "fcitx-utils/log.h" +#include "fcitx-utils/misc.h" #include "fcitx-utils/misc_p.h" #include "fcitx-utils/standardpath.h" +#include "fcitx-utils/stringutils.h" +#include "fcitx/addonfactory.h" +#include "fcitx/addoninstance.h" #include "fcitx/event.h" #include "fcitx/inputcontext.h" #include "fcitx/inputcontextmanager.h" #include "fcitx/instance.h" +#include "fcitx/userinterface.h" #include "common.h" #include "notificationitem_public.h" #include "plasmathemewatchdog.h" +#include "theme.h" #ifdef ENABLE_X11 +#include "xcb_public.h" #include "xcbui.h" #endif #ifdef WAYLAND_FOUND +#include "wayland_public.h" #include "waylandui.h" #endif #ifdef ENABLE_DBUS @@ -40,9 +65,8 @@ FCITX_DEFINE_LOG_CATEGORY(classicui_logcategory, "classicui"); using AccentColorDBusType = FCITX_STRING_TO_DBUS_TYPE("(ddd)"); ClassicUI::ClassicUI(Instance *instance) : instance_(instance) { - #ifdef ENABLE_DBUS - if (auto dbusAddon = dbus()) { + if (auto *dbusAddon = dbus()) { dbus::VariantTypeRegistry::defaultRegistry() .registerType(); settingMonitor_ = std::make_unique( @@ -108,7 +132,7 @@ ClassicUI::ClassicUI(Instance *instance) : instance_(instance) { auto &focusEvent = static_cast(event); if (!focusEvent.newFocus()) { - if (auto ui = uiForDisplay(focusEvent.group()->display())) { + if (auto *ui = uiForDisplay(focusEvent.group()->display())) { ui->update(UserInterfaceComponent::InputPanel, nullptr); } } @@ -400,7 +424,7 @@ void ClassicUI::resume() { auto &focusEvent = static_cast(event); if (!focusEvent.newFocus()) { - if (auto ui = uiForDisplay(focusEvent.group()->display())) { + if (auto *ui = uiForDisplay(focusEvent.group()->display())) { ui->update(UserInterfaceComponent::InputPanel, nullptr); } } diff --git a/src/ui/classic/classicui.h b/src/ui/classic/classicui.h index 1aa4cccfb..b79510b8e 100644 --- a/src/ui/classic/classicui.h +++ b/src/ui/classic/classicui.h @@ -7,19 +7,30 @@ #ifndef _FCITX_UI_CLASSIC_CLASSICUI_H_ #define _FCITX_UI_CLASSIC_CLASSICUI_H_ +#include #include -#include "config.h" - +#include +#include +#include +#include +#include +#include #include "fcitx-config/configuration.h" #include "fcitx-config/iniparser.h" #include "fcitx-config/option.h" +#include "fcitx-config/rawconfig.h" +#include "fcitx-utils/color.h" +#include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/handlertable.h" #include "fcitx-utils/i18n.h" -#include "fcitx/addonfactory.h" +#include "fcitx-utils/stringutils.h" #include "fcitx/addoninstance.h" #include "fcitx/addonmanager.h" +#include "fcitx/event.h" #include "fcitx/instance.h" #include "fcitx/userinterface.h" #include "classicui_public.h" +#include "config.h" #include "plasmathemewatchdog.h" #include "portalsettingmonitor.h" #include "theme.h" @@ -30,11 +41,9 @@ #include "wayland_public.h" #endif #ifdef ENABLE_DBUS -#include "fcitx-utils/dbus/bus.h" #endif -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { inline constexpr std::string_view PlasmaThemeName = "plasma"; @@ -47,8 +56,8 @@ class UIInterface { virtual ~UIInterface() {} virtual void update(UserInterfaceComponent component, InputContext *inputContext) = 0; - virtual void updateCursor(InputContext *) {} - virtual void updateCurrentInputMethod(InputContext *) {} + virtual void updateCursor(InputContext * /*unused*/) {} + virtual void updateCurrentInputMethod(InputContext * /*unused*/) {} virtual void suspend() = 0; virtual void resume() {} virtual void setEnableTray(bool) = 0; @@ -59,7 +68,7 @@ class UIInterface { struct NotEmpty { bool check(const std::string &value) { return !value.empty(); } - void dumpDescription(RawConfig &) const {} + void dumpDescription(RawConfig & /*unused*/) const {} }; struct ThemeAnnotation : public EnumAnnotation { @@ -274,7 +283,6 @@ class ClassicUI final : public UserInterface { std::unique_ptr deferedEnableTray_; std::unique_ptr plasmaThemeWatchdog_; }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_CLASSICUI_H_ diff --git a/src/ui/classic/common.h b/src/ui/classic/common.h index 395a9183d..61c93f1ed 100644 --- a/src/ui/classic/common.h +++ b/src/ui/classic/common.h @@ -7,12 +7,11 @@ #ifndef _FCITX5_UI_CLASSIC_COMMON_H_ #define _FCITX5_UI_CLASSIC_COMMON_H_ -#include #include #include "fcitx-utils/log.h" +#include "fcitx-utils/misc.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { template using GObjectUniquePtr = UniqueCPtr; @@ -25,7 +24,6 @@ FCITX_DECLARE_LOG_CATEGORY(classicui_logcategory); #define CLASSICUI_INFO() \ FCITX_LOGC(::fcitx::classicui::classicui_logcategory, Info) -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX5_UI_CLASSIC_COMMON_H_ diff --git a/src/ui/classic/inputwindow.cpp b/src/ui/classic/inputwindow.cpp index f65c48412..2e19b10df 100644 --- a/src/ui/classic/inputwindow.cpp +++ b/src/ui/classic/inputwindow.cpp @@ -5,21 +5,38 @@ * */ #include "inputwindow.h" +#include #include +#include +#include #include #include #include +#include +#include +#include #include +#include #include #include +#include +#include #include +#include +#include #include #include "fcitx-utils/color.h" +#include "fcitx-utils/rect.h" +#include "fcitx-utils/textformatflags.h" +#include "fcitx/candidatelist.h" #include "fcitx/inputmethodentry.h" #include "fcitx/inputpanel.h" #include "fcitx/instance.h" #include "fcitx/misc_p.h" +#include "fcitx/text.h" +#include "fcitx/userinterface.h" #include "classicui.h" +#include "common.h" #include "theme.h" namespace fcitx::classicui { @@ -46,7 +63,7 @@ static void prepareLayout(cairo_t *cr, PangoLayout *layout) { } static void renderLayout(cairo_t *cr, PangoLayout *layout, int x, int y) { - auto context = pango_layout_get_context(layout); + auto *context = pango_layout_get_context(layout); auto *metrics = pango_context_get_metrics( context, pango_context_get_font_description(context), pango_context_get_language(context)); @@ -58,7 +75,10 @@ static void renderLayout(cairo_t *cr, PangoLayout *layout, int x, int y) { // Ensure the text are not painting on half pixel. cairo_move_to(cr, x, y + yOffset); - double dx, dy, odx, ody; + double dx; + double dy; + double odx; + double ody; cairo_get_current_point(cr, &dx, &dy); // Save old user value odx = dx; @@ -80,7 +100,8 @@ static void renderLayout(cairo_t *cr, PangoLayout *layout, int x, int y) { int MultilineLayout::width() const { int width = 0; for (const auto &layout : lines_) { - int w, h; + int w; + int h; pango_layout_get_pixel_size(layout.get(), &w, &h); width = std::max(width, w); } @@ -245,19 +266,19 @@ void InputWindow::setTextToLayout( appendText(line, newAttrList, newHighlightAttrList, text); } - auto entry = parent_->instance()->inputMethodEntry(inputContext); + const auto *entry = parent_->instance()->inputMethodEntry(inputContext); if (*parent_->config().useInputMethodLanguageToDisplayText && entry && !entry->languageCode().empty()) { - if (auto language = + if (auto *language = pango_language_from_string(entry->languageCode().c_str())) { if (newAttrList) { - auto attr = pango_attr_language_new(language); + auto *attr = pango_attr_language_new(language); attr->start_index = 0; attr->end_index = line.size(); pango_attr_list_insert(newAttrList, attr); } if (newHighlightAttrList) { - auto attr = pango_attr_language_new(language); + auto *attr = pango_attr_language_new(language); attr->start_index = 0; attr->end_index = line.size(); pango_attr_list_insert(newHighlightAttrList, attr); @@ -364,7 +385,8 @@ std::pair InputWindow::update(InputContext *inputContext) { visible_ = nCandidates_ || pango_layout_get_character_count(upperLayout_.get()) || pango_layout_get_character_count(lowerLayout_.get()); - int width = 0, height = 0; + int width = 0; + int height = 0; if (visible_) { std::tie(width, height) = sizeHint(); if (width <= 0 || height <= 0) { @@ -402,7 +424,8 @@ std::pair InputWindow::sizeHint() { m = n; } }; - int w, h; + int w; + int h; const auto &textMargin = *theme.inputPanel->textMargin; auto extraW = *textMargin.marginLeft + *textMargin.marginRight; @@ -425,9 +448,11 @@ std::pair InputWindow::sizeHint() { vertical = false; } - size_t wholeH = 0, wholeW = 0; + size_t wholeH = 0; + size_t wholeW = 0; for (size_t i = 0; i < nCandidates_; i++) { - size_t candidateW = 0, candidateH = 0; + size_t candidateW = 0; + size_t candidateH = 0; if (labelLayouts_[i].characterCount()) { candidateW += labelLayouts_[i].width(); updateIfLarger(candidateH, @@ -493,7 +518,8 @@ void InputWindow::paint(cairo_t *cr, unsigned int width, unsigned int height, fontHeight = PANGO_PIXELS(fontHeight); size_t currentHeight = 0; - int w, h; + int w; + int h; auto extraW = *textMargin.marginLeft + *textMargin.marginRight; auto extraH = *textMargin.marginTop + *textMargin.marginBottom; if (pango_layout_get_character_count(upperLayout_.get())) { @@ -533,14 +559,16 @@ void InputWindow::paint(cairo_t *cr, unsigned int width, unsigned int height, candidateRegions_.clear(); candidateRegions_.reserve(nCandidates_); - size_t wholeW = 0, wholeH = 0; + size_t wholeW = 0; + size_t wholeH = 0; // size of text = textMargin + actual text size. // HighLight = HighLight margin + TEXT. // Click region = HighLight - click for (size_t i = 0; i < nCandidates_; i++) { - int x, y; + int x; + int y; if (vertical) { x = 0; y = currentHeight + wholeH; @@ -550,7 +578,10 @@ void InputWindow::paint(cairo_t *cr, unsigned int width, unsigned int height, } x += *textMargin.marginLeft; y += *textMargin.marginTop; - int labelW = 0, labelH = 0, candidateW = 0, candidateH = 0; + int labelW = 0; + int labelH = 0; + int candidateW = 0; + int candidateH = 0; if (labelLayouts_[i].characterCount()) { labelW = labelLayouts_[i].width(); labelH = fontHeight * labelLayouts_[i].size(); @@ -620,7 +651,8 @@ void InputWindow::paint(cairo_t *cr, unsigned int width, unsigned int height, const auto &next = theme.loadAction(*theme.inputPanel->next); if (prev.valid() && next.valid()) { cairo_save(cr); - int prevY = 0, nextY = 0; + int prevY = 0; + int nextY = 0; switch (*theme.inputPanel->buttonAlignment) { case PageButtonAlignment::Top: prevY = *margin.marginTop; diff --git a/src/ui/classic/inputwindow.h b/src/ui/classic/inputwindow.h index d1c102e88..0ded731d5 100644 --- a/src/ui/classic/inputwindow.h +++ b/src/ui/classic/inputwindow.h @@ -7,15 +7,28 @@ #ifndef _FCITX_UI_CLASSIC_INPUTWINDOW_H_ #define _FCITX_UI_CLASSIC_INPUTWINDOW_H_ +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include #include +#include "fcitx-utils/macros.h" +#include "fcitx-utils/misc.h" +#include "fcitx-utils/rect.h" +#include "fcitx-utils/textformatflags.h" +#include "fcitx-utils/trackableobject.h" #include "fcitx/candidatelist.h" #include "fcitx/inputcontext.h" +#include "fcitx/text.h" #include "common.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class ClassicUI; @@ -41,7 +54,7 @@ class MultilineLayout { int width() const; - int size() { return lines_.size(); } + int size() const { return lines_.size(); } void render(cairo_t *cr, int x, int y, int lineHeight, bool highlight); std::vector> lines_; @@ -107,7 +120,6 @@ class InputWindow { std::pair sizeHint(); }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_INPUTWINDOW_H_ diff --git a/src/ui/classic/plasmathemewatchdog.cpp b/src/ui/classic/plasmathemewatchdog.cpp index 098c7cd15..589090540 100644 --- a/src/ui/classic/plasmathemewatchdog.cpp +++ b/src/ui/classic/plasmathemewatchdog.cpp @@ -18,6 +18,7 @@ #include #include #include "fcitx-utils/event.h" +#include "fcitx-utils/eventloopinterface.h" #include "fcitx-utils/fs.h" #include "fcitx-utils/standardpath.h" #include "fcitx-utils/unixfd.h" diff --git a/src/ui/classic/plasmathemewatchdog.h b/src/ui/classic/plasmathemewatchdog.h index 64e4e0bee..5b5b365c7 100644 --- a/src/ui/classic/plasmathemewatchdog.h +++ b/src/ui/classic/plasmathemewatchdog.h @@ -12,6 +12,7 @@ #include #include #include "fcitx-utils/event.h" +#include "fcitx-utils/eventloopinterface.h" #include "fcitx-utils/unixfd.h" namespace fcitx::classicui { diff --git a/src/ui/classic/portalsettingmonitor.cpp b/src/ui/classic/portalsettingmonitor.cpp index 4999662c3..623840f36 100644 --- a/src/ui/classic/portalsettingmonitor.cpp +++ b/src/ui/classic/portalsettingmonitor.cpp @@ -6,9 +6,14 @@ */ #include "portalsettingmonitor.h" +#include #include #include +#include +#include #include "fcitx-utils/dbus/bus.h" +#include "fcitx-utils/dbus/matchrule.h" +#include "fcitx-utils/dbus/message.h" #include "fcitx-utils/misc_p.h" #include "common.h" @@ -34,7 +39,8 @@ PortalSettingMonitor::PortalSettingMonitor(dbus::Bus &bus) XDG_PORTAL_DESKTOP_SETTINGS_INTERFACE, "SettingChanged", {key.interface, key.name}), [this, key](dbus::Message &msg) { - std::string interface, name; + std::string interface; + std::string name; msg >> interface >> name; if (interface != key.interface || name != key.name) { return true; @@ -104,7 +110,7 @@ PortalSettingMonitor::queryValue(const PortalSettingKey &key) { call << key.interface << key.name; return call.callAsync(5000000, [this, key](dbus::Message &msg) { // Key does not exist. - auto data = findValue(watcherData_, key); + auto *data = findValue(watcherData_, key); if (!data) { return true; } diff --git a/src/ui/classic/portalsettingmonitor.h b/src/ui/classic/portalsettingmonitor.h index 69e1a3918..adf2be356 100644 --- a/src/ui/classic/portalsettingmonitor.h +++ b/src/ui/classic/portalsettingmonitor.h @@ -7,6 +7,8 @@ #ifndef _FCITX_UI_CLASSIC_PORTALSETTINGMONITOR_H_ #define _FCITX_UI_CLASSIC_PORTALSETTINGMONITOR_H_ +#include +#include #include #include #include @@ -14,6 +16,7 @@ #include "fcitx-utils/dbus/servicewatcher.h" #include "fcitx-utils/dbus/variant.h" #include "fcitx-utils/handlertable_details.h" +#include "fcitx-utils/macros.h" #include "fcitx/misc_p.h" namespace fcitx { @@ -41,8 +44,8 @@ struct std::hash { namespace fcitx { -typedef std::function PortalSettingCallback; -typedef HandlerTableEntry PortalSettingEntry; +using PortalSettingCallback = std::function; +using PortalSettingEntry = HandlerTableEntry; class PortalSettingMonitor { struct PortalSettingData { diff --git a/src/ui/classic/theme.h b/src/ui/classic/theme.h index fa9e3b4f9..fc6524d80 100644 --- a/src/ui/classic/theme.h +++ b/src/ui/classic/theme.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include "fcitx-config/configuration.h" #include "fcitx-config/enum.h" #include "fcitx-config/option.h" diff --git a/src/ui/classic/waylandcursortheme.cpp b/src/ui/classic/waylandcursortheme.cpp index a1299b4db..4788b871e 100644 --- a/src/ui/classic/waylandcursortheme.cpp +++ b/src/ui/classic/waylandcursortheme.cpp @@ -1,6 +1,10 @@ #include "waylandcursortheme.h" +#include #include +#include +#include #include +#include "fcitx-utils/dbus/variant.h" #include "fcitx-utils/misc_p.h" #include "dbus_public.h" #include "portalsettingmonitor.h" @@ -28,7 +32,7 @@ WaylandCursorTheme::WaylandCursorTheme(WaylandUI *ui) } #ifdef ENABLE_DBUS - if (auto dbusAddon = ui->parent()->dbus()) { + if (auto *dbusAddon = ui->parent()->dbus()) { settingMonitor_ = std::make_unique( *dbusAddon->call()); cursorSizeWatcher_ = @@ -72,7 +76,7 @@ void WaylandCursorTheme::setTheme(const std::string &theme) { WaylandCursorInfo WaylandCursorTheme::loadCursorTheme(int scale) { auto size = cursorSize_ * scale; - if (auto theme = findValue(themes_, size)) { + if (auto *theme = findValue(themes_, size)) { return *theme; } WaylandCursorInfo info; diff --git a/src/ui/classic/waylandcursortheme.h b/src/ui/classic/waylandcursortheme.h index 7937d7f0e..0e03429a9 100644 --- a/src/ui/classic/waylandcursortheme.h +++ b/src/ui/classic/waylandcursortheme.h @@ -8,8 +8,10 @@ #define _FCITX_UI_CLASSIC_WAYLANDCURSORTHEME_H_ #include +#include #include #include +#include "fcitx-utils/signals.h" #include "config.h" #include "portalsettingmonitor.h" #include "wl_shm.h" @@ -29,7 +31,7 @@ class WaylandCursorTheme { auto &themeChanged() const { return themeChangedSignal_; } - WaylandCursorInfo loadCursorTheme(int size); + WaylandCursorInfo loadCursorTheme(int scale); auto cursorSize() const { return cursorSize_; } private: diff --git a/src/ui/classic/waylandinputwindow.cpp b/src/ui/classic/waylandinputwindow.cpp index 5b8bc950e..bf0c63a33 100644 --- a/src/ui/classic/waylandinputwindow.cpp +++ b/src/ui/classic/waylandinputwindow.cpp @@ -5,7 +5,19 @@ * */ #include "waylandinputwindow.h" +#include +#include +#include +#include +#include +#include +#include +#include "fcitx-utils/rect.h" +#include "fcitx/inputcontext.h" #include "common.h" +#include "inputwindow.h" +#include "org_kde_kwin_blur_manager.h" +#include "theme.h" #include "waylandim_public.h" #include "waylandui.h" #include "waylandwindow.h" @@ -105,28 +117,27 @@ void WaylandInputWindow::updateBlur() { if (!compositor) { return; } - auto width = window_->width(), height = window_->height(); + auto width = window_->width(); + auto height = window_->height(); Rect rect(0, 0, width, height); shrink(rect, *ui_->parent()->theme().inputPanel->blurMargin); if (!*ui_->parent()->theme().inputPanel->enableBlur || rect.isEmpty()) { return; + } + std::vector data; + std::unique_ptr region(compositor->createRegion()); + if (ui_->parent()->theme().inputPanel->blurMask->empty()) { + region->add(rect.left(), rect.top(), rect.width(), rect.height()); } else { - std::vector data; - std::unique_ptr region(compositor->createRegion()); - if (ui_->parent()->theme().inputPanel->blurMask->empty()) { + auto regions = + parent_->theme().mask(parent_->theme().maskConfig(), width, height); + for (const auto &rect : regions) { region->add(rect.left(), rect.top(), rect.width(), rect.height()); - } else { - auto regions = parent_->theme().mask(parent_->theme().maskConfig(), - width, height); - for (const auto &rect : regions) { - region->add(rect.left(), rect.top(), rect.width(), - rect.height()); - } } - blur_.reset(blurManager_->create(window_->surface())); - blur_->setRegion(region.get()); - blur_->commit(); } + blur_.reset(blurManager_->create(window_->surface())); + blur_->setRegion(region.get()); + blur_->commit(); } void WaylandInputWindow::updateScale() { window_->updateScale(); } diff --git a/src/ui/classic/waylandinputwindow.h b/src/ui/classic/waylandinputwindow.h index 2d23a0277..ddad6b528 100644 --- a/src/ui/classic/waylandinputwindow.h +++ b/src/ui/classic/waylandinputwindow.h @@ -8,14 +8,16 @@ #define _FCITX_UI_CLASSIC_WAYLANDINPUTWINDOW_H_ #include +#include +#include "fcitx-utils/trackableobject.h" +#include "fcitx/inputcontext.h" #include "inputwindow.h" #include "org_kde_kwin_blur.h" #include "org_kde_kwin_blur_manager.h" #include "zwp_input_panel_surface_v1.h" #include "zwp_input_popup_surface_v2.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class WaylandUI; class WaylandWindow; @@ -45,7 +47,6 @@ class WaylandInputWindow : public InputWindow { std::unique_ptr blur_; }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WAYLANDINPUTWINDOW_H_ diff --git a/src/ui/classic/waylandpointer.cpp b/src/ui/classic/waylandpointer.cpp index 94fd880c6..68fc4e2a4 100644 --- a/src/ui/classic/waylandpointer.cpp +++ b/src/ui/classic/waylandpointer.cpp @@ -6,7 +6,10 @@ */ #include "waylandpointer.h" +#include +#include #include "waylandwindow.h" +#include "wl_seat.h" #include "wl_surface.h" namespace fcitx::classicui { diff --git a/src/ui/classic/waylandpointer.h b/src/ui/classic/waylandpointer.h index c69258498..134f99343 100644 --- a/src/ui/classic/waylandpointer.h +++ b/src/ui/classic/waylandpointer.h @@ -7,14 +7,17 @@ #ifndef _FCITX_UI_CLASSIC_WAYLANDPOINTER_H_ #define _FCITX_UI_CLASSIC_WAYLANDPOINTER_H_ +#include #include +#include "fcitx-utils/signals.h" +#include "fcitx-utils/trackableobject.h" +#include "display.h" #include "waylandcursor.h" #include "wl_pointer.h" #include "wl_seat.h" #include "wl_touch.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class WaylandUI; class WaylandWindow; @@ -50,7 +53,6 @@ class WaylandPointer { std::unique_ptr cursor_; }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WAYLANDPOINTER_H_ diff --git a/src/ui/classic/waylandshmwindow.cpp b/src/ui/classic/waylandshmwindow.cpp index 6c8d415f4..194f2e25b 100644 --- a/src/ui/classic/waylandshmwindow.cpp +++ b/src/ui/classic/waylandshmwindow.cpp @@ -6,7 +6,16 @@ */ #include "waylandshmwindow.h" +#include +#include +#include +#include +#include "fcitx-utils/eventloopinterface.h" +#include "buffer.h" #include "common.h" +#include "waylandui.h" +#include "waylandwindow.h" +#include "wl_shm.h" namespace fcitx::classicui { @@ -68,7 +77,8 @@ cairo_surface_t *WaylandShmWindow::prerender() { } } - uint32_t bufferWidth = width_, bufferHeight = height_; + uint32_t bufferWidth = width_; + uint32_t bufferHeight = height_; surfaceToBufferSize(bufferScale(), &bufferWidth, &bufferHeight); if (iter != buffers_.end() && ((*iter)->width() != bufferWidth || diff --git a/src/ui/classic/waylandshmwindow.h b/src/ui/classic/waylandshmwindow.h index 1c7f6c686..933707ab2 100644 --- a/src/ui/classic/waylandshmwindow.h +++ b/src/ui/classic/waylandshmwindow.h @@ -7,12 +7,16 @@ #ifndef _FCITX_UI_CLASSIC_WAYLANDSHMWINDOW_H_ #define _FCITX_UI_CLASSIC_WAYLANDSHMWINDOW_H_ -#include +#include +#include +#include +#include +#include "fcitx-utils/eventloopinterface.h" #include "buffer.h" +#include "waylandui.h" #include "waylandwindow.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class WaylandShmWindow : public WaylandWindow { public: @@ -34,7 +38,7 @@ class WaylandShmWindow : public WaylandWindow { bool pending_ = false; std::unique_ptr deferEvent_; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WAYLANDSHMWINDOW_H_ diff --git a/src/ui/classic/waylandui.cpp b/src/ui/classic/waylandui.cpp index ea15c2264..ac1e81735 100644 --- a/src/ui/classic/waylandui.cpp +++ b/src/ui/classic/waylandui.cpp @@ -6,11 +6,16 @@ */ #include "waylandui.h" -#include +#include +#include +#include "fcitx/userinterface.h" +#include "classicui.h" +#include "common.h" #include "display.h" #include "org_kde_kwin_blur_manager.h" #include "waylandcursortheme.h" #include "waylandinputwindow.h" +#include "waylandpointer.h" #include "waylandshmwindow.h" #include "wl_compositor.h" #include "wl_seat.h" diff --git a/src/ui/classic/waylandui.h b/src/ui/classic/waylandui.h index e979f0bd3..48758b9cd 100644 --- a/src/ui/classic/waylandui.h +++ b/src/ui/classic/waylandui.h @@ -7,12 +7,17 @@ #ifndef _FCITX_UI_CLASSIC_WAYLANDUI_H_ #define _FCITX_UI_CLASSIC_WAYLANDUI_H_ +#include +#include +#include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/signals.h" +#include "fcitx/userinterface.h" #include "classicui.h" +#include "display.h" #include "waylandcursortheme.h" #include "waylandpointer.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class WaylandWindow; class WaylandInputWindow; @@ -28,7 +33,7 @@ class WaylandUI : public UIInterface { InputContext *inputContext) override; void suspend() override; void resume() override; - void setEnableTray(bool) override {} + void setEnableTray(bool /*unused*/) override {} std::unique_ptr newWindow(); @@ -45,7 +50,7 @@ class WaylandUI : public UIInterface { std::unique_ptr inputWindow_; std::unique_ptr defer_; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WAYLANDUI_H_ diff --git a/src/ui/classic/waylandwindow.cpp b/src/ui/classic/waylandwindow.cpp index 378b4f5bd..fe8ea752a 100644 --- a/src/ui/classic/waylandwindow.cpp +++ b/src/ui/classic/waylandwindow.cpp @@ -6,6 +6,9 @@ */ #include "waylandwindow.h" +#include +#include "fcitx-utils/eventloopinterface.h" +#include "waylandui.h" #include "wl_compositor.h" #include "wl_output.h" #include "wl_surface.h" diff --git a/src/ui/classic/waylandwindow.h b/src/ui/classic/waylandwindow.h index 3f7a7160e..cba0500a0 100644 --- a/src/ui/classic/waylandwindow.h +++ b/src/ui/classic/waylandwindow.h @@ -8,7 +8,13 @@ #define _FCITX_UI_CLASSIC_WAYLANDWINDOW_H_ #include +#include +#include +#include +#include "fcitx-utils/eventloopinterface.h" #include "fcitx-utils/rect.h" +#include "fcitx-utils/signals.h" +#include "fcitx-utils/trackableobject.h" #include "waylandui.h" #include "window.h" #include "wp_fractional_scale_manager_v1.h" @@ -16,8 +22,7 @@ #include "wp_viewport.h" #include "wp_viewporter.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class WaylandWindow : public Window, public TrackableObject { public: @@ -95,7 +100,6 @@ class WaylandWindow : public Window, public TrackableObject { void scheduleRepaint(); }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WAYLANDWINDOW_H_ diff --git a/src/ui/classic/window.cpp b/src/ui/classic/window.cpp index 6cb9f1d4e..2dc494ab6 100644 --- a/src/ui/classic/window.cpp +++ b/src/ui/classic/window.cpp @@ -9,7 +9,7 @@ namespace fcitx::classicui { -Window::Window() {} +Window::Window() = default; void Window::resize(unsigned int width, unsigned int height) { width_ = width; diff --git a/src/ui/classic/window.h b/src/ui/classic/window.h index ef951a5c0..842f11bc2 100644 --- a/src/ui/classic/window.h +++ b/src/ui/classic/window.h @@ -7,10 +7,9 @@ #ifndef _FCITX_UI_CLASSIC_WINDOW_H_ #define _FCITX_UI_CLASSIC_WINDOW_H_ -#include +#include -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class Window { public: @@ -28,7 +27,7 @@ class Window { unsigned int width_ = 100; unsigned int height_ = 100; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_WINDOW_H_ diff --git a/src/ui/classic/xcbinputwindow.cpp b/src/ui/classic/xcbinputwindow.cpp index 03b8e28be..6923916b5 100644 --- a/src/ui/classic/xcbinputwindow.cpp +++ b/src/ui/classic/xcbinputwindow.cpp @@ -6,9 +6,24 @@ */ #include "xcbinputwindow.h" +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include #include "fcitx-utils/rect.h" +#include "fcitx/inputcontext.h" +#include "inputwindow.h" +#include "theme.h" +#include "xcb_public.h" +#include "xcbui.h" +#include "xcbwindow.h" namespace fcitx::classicui { diff --git a/src/ui/classic/xcbinputwindow.h b/src/ui/classic/xcbinputwindow.h index 37fb9852e..4f89d3f85 100644 --- a/src/ui/classic/xcbinputwindow.h +++ b/src/ui/classic/xcbinputwindow.h @@ -7,11 +7,15 @@ #ifndef _FCITX_UI_CLASSIC_XCBINPUTWINDOW_H_ #define _FCITX_UI_CLASSIC_XCBINPUTWINDOW_H_ +#include +#include +#include "fcitx-utils/rect.h" +#include "fcitx/inputcontext.h" #include "inputwindow.h" +#include "xcbui.h" #include "xcbwindow.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class XCBInputWindow : public XCBWindow, protected InputWindow { public: @@ -36,7 +40,7 @@ class XCBInputWindow : public XCBWindow, protected InputWindow { xcb_atom_t atomBlur_; int dpi_ = -1; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_XCBINPUTWINDOW_H_ diff --git a/src/ui/classic/xcbmenu.cpp b/src/ui/classic/xcbmenu.cpp index 7d45dfcd3..83cea2ad9 100644 --- a/src/ui/classic/xcbmenu.cpp +++ b/src/ui/classic/xcbmenu.cpp @@ -5,17 +5,39 @@ * */ #include "xcbmenu.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include #include +#include +#include "fcitx-utils/connectableobject.h" +#include "fcitx-utils/eventloopinterface.h" #include "fcitx-utils/log.h" +#include "fcitx-utils/rect.h" +#include "fcitx-utils/signals.h" +#include "fcitx-utils/trackableobject.h" +#include "fcitx/action.h" #include "fcitx/inputcontext.h" +#include "fcitx/menu.h" #include "fcitx/userinterfacemanager.h" #include "common.h" #include "theme.h" +#include "xcbui.h" +#include "xcbwindow.h" namespace fcitx::classicui { diff --git a/src/ui/classic/xcbmenu.h b/src/ui/classic/xcbmenu.h index f71b8ec6d..297fd17de 100644 --- a/src/ui/classic/xcbmenu.h +++ b/src/ui/classic/xcbmenu.h @@ -7,12 +7,26 @@ #ifndef _FCITX_UI_CLASSIC_XCBMENU_H_ #define _FCITX_UI_CLASSIC_XCBMENU_H_ +#include +#include +#include +#include +#include +#include +#include +#include +#include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/rect.h" +#include "fcitx-utils/signals.h" +#include "fcitx-utils/trackableobject.h" +#include "fcitx/action.h" +#include "fcitx/inputcontext.h" #include "fcitx/menu.h" #include "common.h" +#include "xcbui.h" #include "xcbwindow.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class MenuPool; @@ -117,7 +131,6 @@ class MenuPool { std::unique_ptr popupMenuTimer_; }; -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_XCBMENU_H_ diff --git a/src/ui/classic/xcbtraywindow.cpp b/src/ui/classic/xcbtraywindow.cpp index 3ad3d5017..ea74ac6e8 100644 --- a/src/ui/classic/xcbtraywindow.cpp +++ b/src/ui/classic/xcbtraywindow.cpp @@ -6,16 +6,33 @@ */ #include "xcbtraywindow.h" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include #include "fcitx-utils/i18n.h" +#include "fcitx-utils/misc.h" +#include "fcitx-utils/rect.h" +#include "fcitx/action.h" #include "fcitx/inputcontext.h" #include "fcitx/inputmethodentry.h" #include "fcitx/inputmethodmanager.h" #include "fcitx/statusarea.h" #include "fcitx/userinterfacemanager.h" #include "common.h" +#include "xcb_public.h" #include "xcbmenu.h" +#include "xcbui.h" +#include "xcbwindow.h" namespace fcitx::classicui { @@ -146,8 +163,9 @@ bool XCBTrayWindow::filterEvent(xcb_generic_event_t *event) { createTrayWindow(); findDock(); return true; - } else if (property->atom == atoms_[ATOM_ORIENTATION] && - property->window == dockWindow_) { + } + if (property->atom == atoms_[ATOM_ORIENTATION] && + property->window == dockWindow_) { isHorizontal_ = trayOrientation(); resizeTrayWindow(); return true; @@ -353,7 +371,8 @@ void XCBTrayWindow::paint(cairo_t *c) { cairo_save(c); cairo_set_operator(c, CAIRO_OPERATOR_SOURCE); - double scaleW = 1.0, scaleH = 1.0; + double scaleW = 1.0; + double scaleH = 1.0; if (image.width() != width() || image.height() != height()) { scaleW = static_cast(width()) / image.width(); scaleH = static_cast(height()) / image.height(); @@ -367,7 +386,8 @@ void XCBTrayWindow::paint(cairo_t *c) { int ah = scaleH * image.height(); cairo_scale(c, scaleW, scaleH); - cairo_set_source_surface(c, image, (width() - aw) / 2, (height() - ah) / 2); + cairo_set_source_surface(c, image, (width() - aw) / 2.0, + (height() - ah) / 2.0); cairo_paint(c); cairo_restore(c); } diff --git a/src/ui/classic/xcbtraywindow.h b/src/ui/classic/xcbtraywindow.h index d394a4eaf..db4e45fc8 100644 --- a/src/ui/classic/xcbtraywindow.h +++ b/src/ui/classic/xcbtraywindow.h @@ -7,12 +7,20 @@ #ifndef _FCITX_UI_CLASSIC_XCBTRAYWINDOW_H_ #define _FCITX_UI_CLASSIC_XCBTRAYWINDOW_H_ +#include +#include +#include +#include +#include +#include "fcitx-utils/handlertable.h" +#include "fcitx/action.h" #include "fcitx/menu.h" +#include "xcb_public.h" #include "xcbmenu.h" +#include "xcbui.h" #include "xcbwindow.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class XCBTrayWindow : public XCBWindow { public: @@ -76,7 +84,7 @@ class XCBTrayWindow : public XCBWindow { std::list groupActions_; std::list inputMethodActions_; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_XCBTRAYWINDOW_H_ diff --git a/src/ui/classic/xcbui.h b/src/ui/classic/xcbui.h index b2e90eda1..b78c414d5 100644 --- a/src/ui/classic/xcbui.h +++ b/src/ui/classic/xcbui.h @@ -7,14 +7,25 @@ #ifndef _FCITX_UI_CLASSIC_XCBUI_H_ #define _FCITX_UI_CLASSIC_XCBUI_H_ +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include "fcitx-utils/eventloopinterface.h" +#include "fcitx-utils/handlertable_details.h" #include "fcitx-utils/misc.h" #include "fcitx-utils/rect.h" +#include "fcitx/userinterface.h" #include "classicui.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class XCBInputWindow; class XCBTrayWindow; @@ -56,7 +67,7 @@ class XCBUI : public UIInterface { void updateCurrentInputMethod(InputContext *inputContext) override; void suspend() override; void resume() override; - void setEnableTray(bool) override; + void setEnableTray(bool enable) override; void setCairoDevice(cairo_device_t *device); const auto &screenRects() { return rects_; } @@ -116,7 +127,6 @@ class XCBUI : public UIInterface { void addEventMaskToWindow(xcb_connection_t *conn, xcb_window_t wid, uint32_t mask); -} // namespace classicui -} // namespace fcitx +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_XCBUI_H_ diff --git a/src/ui/classic/xcbwindow.cpp b/src/ui/classic/xcbwindow.cpp index 0bf8dda02..1f5a386bf 100644 --- a/src/ui/classic/xcbwindow.cpp +++ b/src/ui/classic/xcbwindow.cpp @@ -6,11 +6,18 @@ */ #include "xcbwindow.h" +#include +#include #include #include #include #include +#include +#include "fcitx-utils/misc.h" #include "common.h" +#include "window.h" +#include "xcb_public.h" +#include "xcbui.h" namespace fcitx::classicui { diff --git a/src/ui/classic/xcbwindow.h b/src/ui/classic/xcbwindow.h index 1fc89f630..2ff145ccd 100644 --- a/src/ui/classic/xcbwindow.h +++ b/src/ui/classic/xcbwindow.h @@ -7,13 +7,17 @@ #ifndef _FCITX_UI_CLASSIC_XCBWINDOW_H_ #define _FCITX_UI_CLASSIC_XCBWINDOW_H_ -#include +#include +#include #include +#include +#include "fcitx-utils/handlertable.h" +#include "fcitx-utils/misc.h" #include "window.h" +#include "xcb_public.h" #include "xcbui.h" -namespace fcitx { -namespace classicui { +namespace fcitx::classicui { class XCBWindow : public Window { public: @@ -41,7 +45,7 @@ class XCBWindow : public Window { UniqueCPtr surface_; UniqueCPtr contentSurface_; }; -} // namespace classicui -} // namespace fcitx + +} // namespace fcitx::classicui #endif // _FCITX_UI_CLASSIC_XCBWINDOW_H_