style: pointer/reference goes to type, not name

This commit is contained in:
Raphael Robatsch 2021-10-29 20:19:09 +02:00
parent ebf06f932f
commit 30329b71f4
6 changed files with 105 additions and 103 deletions

View File

@ -62,10 +62,8 @@ int BarComponent::width() const
}
void BarComponent::setText(const std::string& text)
{
auto chars = new char[text.size()];
text.copy(chars, text.size());
_text.reset(chars);
pango_layout_set_text(pangoLayout.get(), chars, text.size());
_text = std::make_unique<std::string>(text);
pango_layout_set_text(pangoLayout.get(), _text->c_str(), _text->size());
}
Bar::Bar(Monitor* mon)
@ -231,7 +229,10 @@ void Bar::setColorScheme(const ColorScheme &scheme, bool invert)
? ColorScheme {scheme.bg, scheme.fg}
: 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::beginBg() { setColor(_painter, _colorScheme.bg); }

View File

@ -11,7 +11,7 @@
#include "shm_buffer.hpp"
class BarComponent {
std::unique_ptr<char[]> _text;
std::unique_ptr<std::string> _text;
public:
BarComponent();
explicit BarComponent(wl_unique_ptr<PangoLayout> layout);

View File

@ -52,7 +52,9 @@ void spawn(Monitor&, const Arg &arg);
// wayland smart pointers
template<typename T>
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>
using wl_unique_ptr = std::unique_ptr<T, wl_deleter<T>>;

View File

@ -1,14 +1,13 @@
// somebar - dwl bar
// See LICENSE file for copyright and license details.
#include <stdio.h>
#include <fcntl.h>
#include <math.h>
#include <signal.h>
#include <algorithm>
#include <cstdio>
#include <list>
#include <optional>
#include <vector>
#include <fcntl.h>
#include <signal.h>
#include <sys/epoll.h>
#include <sys/mman.h>
#include <sys/signalfd.h>
@ -143,7 +142,7 @@ static const struct wl_pointer_listener pointerListener = {
auto& seat = *static_cast<Seat*>(sp);
seat.pointer->focusedBar = barFromSurface(surface);
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];
cursorSurface = wl_compositor_create_surface(compositor);
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,
};
int main(int argc, char **argv)
int main(int argc, char* argv[])
{
int opt;
while ((opt = getopt(argc, argv, "chv")) != -1) {