diff --git a/meson.build b/meson.build index 6fb26d0..b12b3bc 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,6 @@ project('somebar', ['c', 'cpp'], wayland_dep = dependency('wayland-client') wayland_cursor_dep = dependency('wayland-cursor') -qt5 = import('qt5') qt5_dep = dependency('qt5', modules: ['Core', 'Gui']) subdir('protocols') @@ -13,4 +12,4 @@ executable('somebar', 'src/shm_buffer.cpp', 'src/bar.cpp', wayland_sources, - dependencies: [qt5_dep, wayland_dep, wayland_cursor_dep]) + dependencies: [wayland_dep, wayland_cursor_dep, qt5_dep]) diff --git a/src/bar.cpp b/src/bar.cpp index bd0b272..cec099c 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -58,20 +58,20 @@ void Bar::create(wl_output *output) wl_surface_commit(_surface.get()); } -void Bar::click(int x, int, int btn, unsigned int modifiers) +void Bar::click(int x, int, int btn) { Arg arg = {0}; Arg *argp = nullptr; - Control control = Control::None; + int control = ClkNone; if (x > _statusX) { - control = Control::StatusText; + control = ClkStatusText; } else if (x > _titleX) { - control = Control::WinTitle; + control = ClkWinTitle; } else if (x > _layoutX) { - control = Control::LayoutSymbol; + control = ClkLayoutSymbol; } else for (auto tag = _tags.size()-1; tag >= 0; tag--) { if (x > _tags[tag].x) { - control = Control::TagBar; + control = ClkTagBar; arg.ui = 1< + void (*func)(Monitor &mon, const Arg &arg); + const Arg arg; +}; + extern wl_display *display; extern wl_compositor *compositor; extern wl_shm *shm; @@ -33,15 +41,6 @@ void toggleview(Monitor &m, const Arg &arg); void view(Monitor &m, const Arg &arg); void setlayout(Monitor &m, const Arg &arg); -enum class Control { None, TagBar, LayoutSymbol, WinTitle, StatusText }; -struct Button { - Control control; - unsigned int modifiers; // todo xkbcommon - int btn; // - void (*func)(Monitor &mon, const Arg &arg); - const Arg arg; -}; - // wayland smart pointers template struct wl_deleter; diff --git a/src/config.hpp b/src/config.hpp index 103a07e..27100e4 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -18,9 +18,9 @@ constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55 constexpr ColorScheme colorUrgent = {colorActive.bg, colorActive.fg}; constexpr Button buttons[] = { - { Control::TagBar, 0, BTN_LEFT, toggleview, {0} }, - { Control::TagBar, 0, BTN_MIDDLE, view, {0} }, - //{ Control::TagBar, 0, BTN_RIGHT, tag, {0} }, - { Control::LayoutSymbol, 0, BTN_LEFT, setlayout, {.ui = 0} }, - { Control::LayoutSymbol, 0, BTN_RIGHT, setlayout, {.ui = 2} }, + { ClkTagBar, BTN_LEFT, toggleview, {0} }, + { ClkTagBar, BTN_LEFT, view, {0} }, + //{ Clk::TagBar, 0, BTN_RIGHT, tag, {0} }, + { ClkLayoutSymbol, BTN_LEFT, setlayout, {.ui = 0} }, + { ClkLayoutSymbol, BTN_RIGHT, setlayout, {.ui = 2} }, }; diff --git a/src/main.cpp b/src/main.cpp index d364cd8..ab06267 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -135,7 +135,7 @@ static const struct wl_pointer_listener pointerListener = { auto& seat = *static_cast(sp); if (!seat.pointer->focusedBar) return; for (auto btn : seat.pointer->btns) { - seat.pointer->focusedBar->click(seat.pointer->x, seat.pointer->y, btn, 0); + seat.pointer->focusedBar->click(seat.pointer->x, seat.pointer->y, btn); } seat.pointer->btns.clear(); }, @@ -150,7 +150,8 @@ static const struct wl_seat_listener seatListener = { auto& seat = *static_cast(sp); auto hasPointer = cap & WL_SEAT_CAPABILITY_POINTER; if (!seat.pointer && hasPointer) { - seat.pointer.emplace(SeatPointer {wl_unique_ptr {wl_seat_get_pointer(seat.wlSeat.get())}}); + auto &pointer = seat.pointer.emplace(); + pointer.wlPointer = wl_unique_ptr {wl_seat_get_pointer(seat.wlSeat.get())}; wl_pointer_add_listener(seat.pointer->wlPointer.get(), &pointerListener, &seat); } else if (seat.pointer && !hasPointer) { seat.pointer.reset();