remove kb handling due to missing focus
This commit is contained in:
		
							parent
							
								
									bc35014269
								
							
						
					
					
						commit
						4556789b0e
					
				| @ -3,7 +3,6 @@ project('somebar', ['c', 'cpp'], | |||||||
| 
 | 
 | ||||||
| wayland_dep = dependency('wayland-client') | wayland_dep = dependency('wayland-client') | ||||||
| wayland_cursor_dep = dependency('wayland-cursor') | wayland_cursor_dep = dependency('wayland-cursor') | ||||||
| qt5 = import('qt5') |  | ||||||
| qt5_dep = dependency('qt5', modules: ['Core', 'Gui']) | qt5_dep = dependency('qt5', modules: ['Core', 'Gui']) | ||||||
| 
 | 
 | ||||||
| subdir('protocols') | subdir('protocols') | ||||||
| @ -13,4 +12,4 @@ executable('somebar', | |||||||
|   'src/shm_buffer.cpp', |   'src/shm_buffer.cpp', | ||||||
|   'src/bar.cpp', |   'src/bar.cpp', | ||||||
|   wayland_sources, |   wayland_sources, | ||||||
|   dependencies: [qt5_dep, wayland_dep, wayland_cursor_dep]) |   dependencies: [wayland_dep, wayland_cursor_dep, qt5_dep]) | ||||||
|  | |||||||
							
								
								
									
										14
									
								
								src/bar.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/bar.cpp
									
									
									
									
									
								
							| @ -58,20 +58,20 @@ void Bar::create(wl_output *output) | |||||||
|     wl_surface_commit(_surface.get()); |     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 arg = {0}; | ||||||
|     Arg *argp = nullptr; |     Arg *argp = nullptr; | ||||||
|     Control control = Control::None; |     int control = ClkNone; | ||||||
|     if (x > _statusX) { |     if (x > _statusX) { | ||||||
|         control = Control::StatusText; |         control = ClkStatusText; | ||||||
|     } else if (x > _titleX) { |     } else if (x > _titleX) { | ||||||
|         control = Control::WinTitle; |         control = ClkWinTitle; | ||||||
|     } else if (x > _layoutX) { |     } else if (x > _layoutX) { | ||||||
|         control = Control::LayoutSymbol; |         control = ClkLayoutSymbol; | ||||||
|     } else for (auto tag = _tags.size()-1; tag >= 0; tag--) { |     } else for (auto tag = _tags.size()-1; tag >= 0; tag--) { | ||||||
|         if (x > _tags[tag].x) { |         if (x > _tags[tag].x) { | ||||||
|             control = Control::TagBar; |             control = ClkTagBar; | ||||||
|             arg.ui = 1<<tag; |             arg.ui = 1<<tag; | ||||||
|             argp = &arg; |             argp = &arg; | ||||||
|             break; |             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++) { |     for (auto i = 0u; i < sizeof(buttons)/sizeof(buttons[0]); i++) { | ||||||
|         const auto& button = buttons[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)); |             button.func(*_mon, *(argp ? argp : &button.arg)); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -56,5 +56,5 @@ public: | |||||||
|     void setTitle(const char *title); |     void setTitle(const char *title); | ||||||
|     void setStatus(const QString &status); |     void setStatus(const QString &status); | ||||||
|     void invalidate(); |     void invalidate(); | ||||||
|     void click(int x, int y, int btn, unsigned int modifiers); |     void click(int x, int y, int btn); | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -22,6 +22,14 @@ union Arg { | |||||||
| }; | }; | ||||||
| struct Monitor; | 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_display *display; | ||||||
| extern wl_compositor *compositor; | extern wl_compositor *compositor; | ||||||
| extern wl_shm *shm; | extern wl_shm *shm; | ||||||
| @ -33,15 +41,6 @@ void toggleview(Monitor &m, const Arg &arg); | |||||||
| void view(Monitor &m, const Arg &arg); | void view(Monitor &m, const Arg &arg); | ||||||
| void setlayout(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
 | // wayland smart pointers
 | ||||||
| template<typename T> | template<typename T> | ||||||
| struct wl_deleter; | struct wl_deleter; | ||||||
|  | |||||||
| @ -18,9 +18,9 @@ constexpr ColorScheme colorActive = {QColor(0xee, 0xee, 0xee), QColor(0x00, 0x55 | |||||||
| constexpr ColorScheme colorUrgent = {colorActive.bg, colorActive.fg}; | constexpr ColorScheme colorUrgent = {colorActive.bg, colorActive.fg}; | ||||||
| 
 | 
 | ||||||
| constexpr Button buttons[] = { | constexpr Button buttons[] = { | ||||||
|     { Control::TagBar,       0, BTN_LEFT,   toggleview, {0} }, |     { ClkTagBar,       BTN_LEFT,   toggleview, {0} }, | ||||||
|     { Control::TagBar,       0, BTN_MIDDLE, view,       {0} }, |     { ClkTagBar,       BTN_LEFT,   view,       {0} }, | ||||||
|     //{ Control::TagBar, 0, BTN_RIGHT, tag, {0} },
 |     //{ Clk::TagBar, 0, BTN_RIGHT, tag, {0} },
 | ||||||
|     { Control::LayoutSymbol, 0, BTN_LEFT,   setlayout,  {.ui = 0} }, |     { ClkLayoutSymbol, BTN_LEFT,   setlayout,  {.ui = 0} }, | ||||||
|     { Control::LayoutSymbol, 0, BTN_RIGHT,  setlayout,  {.ui = 2} }, |     { ClkLayoutSymbol, BTN_RIGHT,  setlayout,  {.ui = 2} }, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -135,7 +135,7 @@ static const struct wl_pointer_listener pointerListener = { | |||||||
|         auto& seat = *static_cast<Seat*>(sp); |         auto& seat = *static_cast<Seat*>(sp); | ||||||
|         if (!seat.pointer->focusedBar) return; |         if (!seat.pointer->focusedBar) return; | ||||||
|         for (auto btn : seat.pointer->btns) { |         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(); |         seat.pointer->btns.clear(); | ||||||
|     }, |     }, | ||||||
| @ -150,7 +150,8 @@ static const struct wl_seat_listener seatListener = { | |||||||
|         auto& seat = *static_cast<Seat*>(sp); |         auto& seat = *static_cast<Seat*>(sp); | ||||||
|         auto hasPointer = cap & WL_SEAT_CAPABILITY_POINTER; |         auto hasPointer = cap & WL_SEAT_CAPABILITY_POINTER; | ||||||
|         if (!seat.pointer && hasPointer) { |         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); |             wl_pointer_add_listener(seat.pointer->wlPointer.get(), &pointerListener, &seat); | ||||||
|         } else if (seat.pointer && !hasPointer) { |         } else if (seat.pointer && !hasPointer) { | ||||||
|             seat.pointer.reset(); |             seat.pointer.reset(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user