style: pointer/reference goes to type, not name
This commit is contained in:
		
							parent
							
								
									ebf06f932f
								
							
						
					
					
						commit
						30329b71f4
					
				
							
								
								
									
										11
									
								
								src/bar.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/bar.cpp
									
									
									
									
									
								
							| @ -62,10 +62,8 @@ int BarComponent::width() const | |||||||
| } | } | ||||||
| void BarComponent::setText(const std::string& text) | void BarComponent::setText(const std::string& text) | ||||||
| { | { | ||||||
|     auto chars = new char[text.size()]; |     _text = std::make_unique<std::string>(text); | ||||||
|     text.copy(chars, text.size()); |     pango_layout_set_text(pangoLayout.get(), _text->c_str(), _text->size()); | ||||||
|     _text.reset(chars); |  | ||||||
|     pango_layout_set_text(pangoLayout.get(), chars, text.size()); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Bar::Bar(Monitor* mon) | Bar::Bar(Monitor* mon) | ||||||
| @ -231,7 +229,10 @@ void Bar::setColorScheme(const ColorScheme &scheme, bool invert) | |||||||
|         ? ColorScheme {scheme.bg, scheme.fg} |         ? ColorScheme {scheme.bg, scheme.fg} | ||||||
|         : ColorScheme {scheme.fg, scheme.bg}; |         : ColorScheme {scheme.fg, scheme.bg}; | ||||||
| } | } | ||||||
| static void setColor(cairo_t *painter, const Color &color) { cairo_set_source_rgba(painter, color.r/255.0, color.g/255.0, color.b/255.0, color.a/255.0); } | static void setColor(cairo_t* painter, const Color& color) | ||||||
|  | { | ||||||
|  |     cairo_set_source_rgba(painter, color.r/255.0, color.g/255.0, color.b/255.0, color.a/255.0); | ||||||
|  | } | ||||||
| void Bar::beginFg() { setColor(_painter, _colorScheme.fg); } | void Bar::beginFg() { setColor(_painter, _colorScheme.fg); } | ||||||
| void Bar::beginBg() { setColor(_painter, _colorScheme.bg); } | void Bar::beginBg() { setColor(_painter, _colorScheme.bg); } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ | |||||||
| #include "shm_buffer.hpp" | #include "shm_buffer.hpp" | ||||||
| 
 | 
 | ||||||
| class BarComponent { | class BarComponent { | ||||||
|     std::unique_ptr<char[]> _text; |     std::unique_ptr<std::string> _text; | ||||||
| public: | public: | ||||||
|     BarComponent(); |     BarComponent(); | ||||||
|     explicit BarComponent(wl_unique_ptr<PangoLayout> layout); |     explicit BarComponent(wl_unique_ptr<PangoLayout> layout); | ||||||
|  | |||||||
| @ -52,7 +52,9 @@ void spawn(Monitor&, const Arg &arg); | |||||||
| // wayland smart pointers
 | // wayland smart pointers
 | ||||||
| template<typename T> | template<typename T> | ||||||
| struct wl_deleter; | struct wl_deleter; | ||||||
| #define WL_DELETER(type, fn) template<> struct wl_deleter<type> { void operator()(type *v) { if(v) fn(v); } } | #define WL_DELETER(type, fn) template<> struct wl_deleter<type> { \ | ||||||
|  |     void operator()(type* v) { if(v) fn(v); } \ | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| template<typename T> | template<typename T> | ||||||
| using wl_unique_ptr = std::unique_ptr<T, wl_deleter<T>>; | using wl_unique_ptr = std::unique_ptr<T, wl_deleter<T>>; | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.cpp
									
									
									
									
									
								
							| @ -1,14 +1,13 @@ | |||||||
| // somebar - dwl bar
 | // somebar - dwl bar
 | ||||||
| // See LICENSE file for copyright and license details.
 | // See LICENSE file for copyright and license details.
 | ||||||
| 
 | 
 | ||||||
| #include <stdio.h> |  | ||||||
| #include <fcntl.h> |  | ||||||
| #include <math.h> |  | ||||||
| #include <signal.h> |  | ||||||
| #include <algorithm> | #include <algorithm> | ||||||
|  | #include <cstdio> | ||||||
| #include <list> | #include <list> | ||||||
| #include <optional> | #include <optional> | ||||||
| #include <vector> | #include <vector> | ||||||
|  | #include <fcntl.h> | ||||||
|  | #include <signal.h> | ||||||
| #include <sys/epoll.h> | #include <sys/epoll.h> | ||||||
| #include <sys/mman.h> | #include <sys/mman.h> | ||||||
| #include <sys/signalfd.h> | #include <sys/signalfd.h> | ||||||
| @ -143,7 +142,7 @@ static const struct wl_pointer_listener pointerListener = { | |||||||
|         auto& seat = *static_cast<Seat*>(sp); |         auto& seat = *static_cast<Seat*>(sp); | ||||||
|         seat.pointer->focusedBar = barFromSurface(surface); |         seat.pointer->focusedBar = barFromSurface(surface); | ||||||
|         if (!cursorImage) { |         if (!cursorImage) { | ||||||
|             auto cursorTheme = wl_cursor_theme_load(NULL, 24, shm); |             auto cursorTheme = wl_cursor_theme_load(nullptr, 24, shm); | ||||||
|             cursorImage = wl_cursor_theme_get_cursor(cursorTheme, "left_ptr")->images[0]; |             cursorImage = wl_cursor_theme_get_cursor(cursorTheme, "left_ptr")->images[0]; | ||||||
|             cursorSurface = wl_compositor_create_surface(compositor); |             cursorSurface = wl_compositor_create_surface(compositor); | ||||||
|             wl_surface_attach(cursorSurface, wl_cursor_image_get_buffer(cursorImage), 0, 0); |             wl_surface_attach(cursorSurface, wl_cursor_image_get_buffer(cursorImage), 0, 0); | ||||||
| @ -411,7 +410,7 @@ static const struct wl_registry_listener registry_listener = { | |||||||
|     .global_remove = registryHandleRemove, |     .global_remove = registryHandleRemove, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| int main(int argc, char **argv) | int main(int argc, char* argv[]) | ||||||
| { | { | ||||||
|     int opt; |     int opt; | ||||||
|     while ((opt = getopt(argc, argv, "chv")) != -1) { |     while ((opt = getopt(argc, argv, "chv")) != -1) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user