mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-12-22 06:09:48 +01:00
core: migrate to hyprutils for utils
This commit is contained in:
parent
8791f717ef
commit
cffd2ca3f8
12 changed files with 74 additions and 140 deletions
|
@ -1,4 +1,4 @@
|
|||
cmake_minimum_required(VERSION 3.4)
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
project(hyprpicker
|
||||
DESCRIPTION "A blazing fast wayland wallpaper utility"
|
||||
)
|
||||
|
@ -72,7 +72,7 @@ add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-m
|
|||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols xkbcommon cairo pango pangocairo libjpeg)
|
||||
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols xkbcommon cairo pango pangocairo libjpeg hyprutils>=0.2.0)
|
||||
|
||||
file(GLOB_RECURSE SRCFILES "src/*.cpp")
|
||||
|
||||
|
|
14
README.md
14
README.md
|
@ -30,11 +30,15 @@ Launch it. Click. That's it.
|
|||
|
||||
## Manual
|
||||
|
||||
Install build dependencies (Debian):
|
||||
|
||||
```sh
|
||||
apt install --no-install-recommends -y cmake g++ make pkg-config libpango1.0-dev libjpeg-dev libwayland-dev wayland-protocols libxkbcommon-dev
|
||||
```
|
||||
Install dependencies:
|
||||
- cmake
|
||||
- pkg-config
|
||||
- pango
|
||||
- cairo
|
||||
- wayland
|
||||
- wayland-protocols
|
||||
- hyprutils
|
||||
- xkbcommon
|
||||
|
||||
Building is done via CMake:
|
||||
|
||||
|
|
|
@ -9,23 +9,12 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
|
|||
std::string levelstr = "";
|
||||
|
||||
switch (level) {
|
||||
case LOG:
|
||||
levelstr = "[LOG] ";
|
||||
break;
|
||||
case WARN:
|
||||
levelstr = "[WARN] ";
|
||||
break;
|
||||
case ERR:
|
||||
levelstr = "[ERR] ";
|
||||
break;
|
||||
case CRIT:
|
||||
levelstr = "[CRITICAL] ";
|
||||
break;
|
||||
case INFO:
|
||||
levelstr = "[INFO] ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LOG: levelstr = "[LOG] "; break;
|
||||
case WARN: levelstr = "[WARN] "; break;
|
||||
case ERR: levelstr = "[ERR] "; break;
|
||||
case CRIT: levelstr = "[CRITICAL] "; break;
|
||||
case INFO: levelstr = "[INFO] "; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
char buf[LOGMESSAGESIZE] = "";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "debug/Log.hpp"
|
||||
#include "helpers/Vector2D.hpp"
|
||||
#include "includes.hpp"
|
||||
#include "helpers/Monitor.hpp"
|
||||
#include "helpers/Color.hpp"
|
||||
|
@ -22,3 +21,6 @@
|
|||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
using namespace Hyprutils::Math;
|
||||
|
|
|
@ -39,7 +39,7 @@ void Events::description(void* data, wl_output* wl_output, const char* descripti
|
|||
void Events::ls_configure(void* data, zwlr_layer_surface_v1* surface, uint32_t serial, uint32_t width, uint32_t height) {
|
||||
const auto PLAYERSURFACE = (CLayerSurface*)data;
|
||||
|
||||
PLAYERSURFACE->m_pMonitor->size = Vector2D(width, height);
|
||||
PLAYERSURFACE->m_pMonitor->size = Vector2D((int)width, (int)height);
|
||||
|
||||
PLAYERSURFACE->ACKSerial = serial;
|
||||
PLAYERSURFACE->wantsACK = true;
|
||||
|
@ -82,9 +82,7 @@ void Events::handleCapabilities(void* data, wl_seat* wl_seat, uint32_t capabilit
|
|||
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
|
||||
const auto POINTER = wl_seat_get_pointer(wl_seat);
|
||||
wl_pointer_add_listener(POINTER, &pointerListener, wl_seat);
|
||||
g_pHyprpicker->m_pCursorShapeDevice = (g_pHyprpicker->m_pCursorShape) ?
|
||||
wp_cursor_shape_manager_v1_get_pointer(g_pHyprpicker->m_pCursorShape, POINTER) :
|
||||
nullptr;
|
||||
g_pHyprpicker->m_pCursorShapeDevice = (g_pHyprpicker->m_pCursorShape) ? wp_cursor_shape_manager_v1_get_pointer(g_pHyprpicker->m_pCursorShape, POINTER) : nullptr;
|
||||
} else {
|
||||
Debug::log(CRIT, "Hyprpicker cannot work without a pointer!");
|
||||
g_pHyprpicker->finish(1);
|
||||
|
@ -397,8 +395,6 @@ void Events::handleSCReady(void* lsdata, struct zwlr_screencopy_frame_v1* frame,
|
|||
if (TR == 0)
|
||||
return;
|
||||
|
||||
const auto TRFLIP = PLS->m_pMonitor->transform >= 4;
|
||||
|
||||
cairo_matrix_rotate(mtx, -M_PI_2 * (double)TR);
|
||||
|
||||
if (TR == 1)
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include "../defines.hpp"
|
||||
|
||||
namespace Events {
|
||||
void geometry(void *data, wl_output *output, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char *make, const char *model, int32_t transform);
|
||||
void geometry(void* data, wl_output* output, int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, const char* make, const char* model,
|
||||
int32_t transform);
|
||||
|
||||
void mode(void* data, wl_output* output, uint32_t flags, int32_t width, int32_t height, int32_t refresh);
|
||||
|
||||
|
@ -63,9 +64,11 @@ namespace Events {
|
|||
|
||||
inline const wl_seat_listener seatListener = {.capabilities = handleCapabilities};
|
||||
|
||||
inline const wl_pointer_listener pointerListener = { .enter = handlePointerEnter, .leave = handlePointerLeave, .motion = handlePointerMotion, .button = handlePointerButton, .axis = handlePointerAxis };
|
||||
inline const wl_pointer_listener pointerListener = {
|
||||
.enter = handlePointerEnter, .leave = handlePointerLeave, .motion = handlePointerMotion, .button = handlePointerButton, .axis = handlePointerAxis};
|
||||
|
||||
inline const wl_keyboard_listener keyboardListener = { .keymap = handleKeyboardKeymap, .enter = handleKeyboardEnter,.leave = handleKeyboardLeave, .key = handleKeyboardKey, .modifiers = handleKeyboardModifiers };
|
||||
inline const wl_keyboard_listener keyboardListener = {
|
||||
.keymap = handleKeyboardKeymap, .enter = handleKeyboardEnter, .leave = handleKeyboardLeave, .key = handleKeyboardKey, .modifiers = handleKeyboardModifiers};
|
||||
|
||||
inline const wl_callback_listener frameListener = {.done = handleFrameDone};
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "../defines.hpp"
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
using namespace Hyprutils::Math;
|
||||
|
||||
struct SMonitor {
|
||||
std::string name = "";
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#include "Vector2D.hpp"
|
||||
|
||||
Vector2D::Vector2D(double xx, double yy) {
|
||||
x = xx;
|
||||
y = yy;
|
||||
}
|
||||
|
||||
Vector2D::Vector2D() { x = 0; y = 0; }
|
||||
Vector2D::~Vector2D() {}
|
||||
|
||||
double Vector2D::normalize() {
|
||||
// get max abs
|
||||
const auto max = abs(x) > abs(y) ? abs(x) : abs(y);
|
||||
|
||||
x /= max;
|
||||
y /= max;
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
Vector2D Vector2D::floor() {
|
||||
return Vector2D((int)x, (int)y);
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
class Vector2D {
|
||||
public:
|
||||
Vector2D(double, double);
|
||||
Vector2D();
|
||||
~Vector2D();
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
|
||||
// returns the scale
|
||||
double normalize();
|
||||
|
||||
Vector2D operator+(const Vector2D a) const {
|
||||
return Vector2D(this->x + a.x, this->y + a.y);
|
||||
}
|
||||
Vector2D operator-(const Vector2D a) const {
|
||||
return Vector2D(this->x - a.x, this->y - a.y);
|
||||
}
|
||||
Vector2D operator*(const float a) const {
|
||||
return Vector2D(this->x * a, this->y * a);
|
||||
}
|
||||
Vector2D operator/(const float a) const {
|
||||
return Vector2D(this->x / a, this->y / a);
|
||||
}
|
||||
|
||||
bool operator==(const Vector2D& a) const {
|
||||
return a.x == x && a.y == y;
|
||||
}
|
||||
|
||||
bool operator!=(const Vector2D& a) const {
|
||||
return a.x != x || a.y != y;
|
||||
}
|
||||
|
||||
Vector2D floor();
|
||||
};
|
Loading…
Reference in a new issue