Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang-tidy clean up for classic ui #1216

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/ui/classic/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
*/
#include "buffer.h"
#include <fcntl.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <unistd.h>
#include <cerrno>
#include <cstdint>
#include <cstdlib>
#include <stdexcept>
#include <string>
#include <vector>
#include <cairo.h>
#include <sys/syscall.h>
#include <wayland-client.h>
#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"
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/ui/classic/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
#ifndef _FCITX_WAYLAND_CORE_BUFFER_H_
#define _FCITX_WAYLAND_CORE_BUFFER_H_

#include <cstddef>
#include <cstdint>
#include <memory>
#include <cairo/cairo.h>
#include <cairo.h>
#include <wayland-client.h>
#include "fcitx-utils/misc.h"
#include "fcitx-utils/signals.h"

namespace fcitx {
Expand Down
32 changes: 28 additions & 4 deletions src/ui/classic/classicui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,49 @@

#include "classicui.h"
#include <fcntl.h>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <cairo.h>
#include <xcb/xcb.h>
#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
Expand All @@ -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<AccentColorDBusType>();
settingMonitor_ = std::make_unique<PortalSettingMonitor>(
Expand Down Expand Up @@ -108,7 +132,7 @@ ClassicUI::ClassicUI(Instance *instance) : instance_(instance) {
auto &focusEvent =
static_cast<FocusGroupFocusChangedEvent &>(event);
if (!focusEvent.newFocus()) {
if (auto ui = uiForDisplay(focusEvent.group()->display())) {
if (auto *ui = uiForDisplay(focusEvent.group()->display())) {
ui->update(UserInterfaceComponent::InputPanel, nullptr);
}
}
Expand Down Expand Up @@ -400,7 +424,7 @@ void ClassicUI::resume() {
auto &focusEvent =
static_cast<FocusGroupFocusChangedEvent &>(event);
if (!focusEvent.newFocus()) {
if (auto ui = uiForDisplay(focusEvent.group()->display())) {
if (auto *ui = uiForDisplay(focusEvent.group()->display())) {
ui->update(UserInterfaceComponent::InputPanel, nullptr);
}
}
Expand Down
30 changes: 19 additions & 11 deletions src/ui/classic/classicui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,30 @@
#ifndef _FCITX_UI_CLASSIC_CLASSICUI_H_
#define _FCITX_UI_CLASSIC_CLASSICUI_H_

#include <cstddef>
#include <memory>
#include "config.h"

#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <vector>
#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"
Expand All @@ -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";

Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -274,7 +283,6 @@ class ClassicUI final : public UserInterface {
std::unique_ptr<EventSource> deferedEnableTray_;
std::unique_ptr<PlasmaThemeWatchdog> plasmaThemeWatchdog_;
};
} // namespace classicui
} // namespace fcitx
} // namespace fcitx::classicui

#endif // _FCITX_UI_CLASSIC_CLASSICUI_H_
8 changes: 3 additions & 5 deletions src/ui/classic/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
#ifndef _FCITX5_UI_CLASSIC_COMMON_H_
#define _FCITX5_UI_CLASSIC_COMMON_H_

#include <memory>
#include <glib-object.h>
#include "fcitx-utils/log.h"
#include "fcitx-utils/misc.h"

namespace fcitx {
namespace classicui {
namespace fcitx::classicui {

template <typename T>
using GObjectUniquePtr = UniqueCPtr<T, g_object_unref>;
Expand All @@ -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_
Loading
Loading