remove kb handling due to missing focus

This commit is contained in:
Raphael Robatsch 2021-10-26 15:32:25 +02:00
parent bc35014269
commit 4556789b0e
6 changed files with 25 additions and 26 deletions

View file

@ -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])

View file

@ -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<<tag;
argp = &arg;
break;
@ -79,7 +79,7 @@ void Bar::click(int x, int, int btn, unsigned int modifiers)
}
for (auto i = 0u; i < sizeof(buttons)/sizeof(buttons[0]); i++) {
const auto& button = buttons[i];
if (button.control == control && button.btn == btn && button.modifiers == modifiers) {
if (button.control == control && button.btn == btn) {
button.func(*_mon, *(argp ? argp : &button.arg));
return;
}

View file

@ -56,5 +56,5 @@ public:
void setTitle(const char *title);
void setStatus(const QString &status);
void invalidate();
void click(int x, int y, int btn, unsigned int modifiers);
void click(int x, int y, int btn);
};

View file

@ -22,6 +22,14 @@ union Arg {
};
struct Monitor;
enum { ClkNone, ClkTagBar, ClkLayoutSymbol, ClkWinTitle, ClkStatusText };
struct Button {
int control;
int btn; // <linux/input-event-codes.h>
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; // <linux/input-event-codes.h>
void (*func)(Monitor &mon, const Arg &arg);
const Arg arg;
};
// wayland smart pointers
template<typename T>
struct wl_deleter;

View file

@ -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} },
};

View file

@ -135,7 +135,7 @@ static const struct wl_pointer_listener pointerListener = {
auto& seat = *static_cast<Seat*>(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<Seat*>(sp);
auto hasPointer = cap & WL_SEAT_CAPABILITY_POINTER;
if (!seat.pointer && hasPointer) {
seat.pointer.emplace(SeatPointer {wl_unique_ptr<wl_pointer> {wl_seat_get_pointer(seat.wlSeat.get())}});
auto &pointer = seat.pointer.emplace();
pointer.wlPointer = wl_unique_ptr<wl_pointer> {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();