mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-12-22 06:09:48 +01:00
clang-format, no-zoom and render-inactive
This commit is contained in:
parent
234c2da51a
commit
cc6b3234b2
5 changed files with 259 additions and 203 deletions
65
.clang-format
Normal file
65
.clang-format
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: true
|
||||||
|
AlignConsecutiveAssignments: true
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: false
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
ColumnLimit: 180
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
|
||||||
|
BraceWrapping:
|
||||||
|
AfterEnum: false
|
||||||
|
|
||||||
|
AlignConsecutiveDeclarations: AcrossEmptyLines
|
||||||
|
|
||||||
|
NamespaceIndentation: All
|
|
@ -1,7 +1,9 @@
|
||||||
#include "Events.hpp"
|
#include "Events.hpp"
|
||||||
|
|
||||||
#include "../hyprpicker.hpp"
|
#include "../hyprpicker.hpp"
|
||||||
|
|
||||||
void Events::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 Events::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) {
|
||||||
// ignored
|
// ignored
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +114,6 @@ void Events::handlePointerAxis(void *data, wl_pointer *wl_pointer, uint32_t time
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::handlePointerMotion(void* data, struct wl_pointer* wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
void Events::handlePointerMotion(void* data, struct wl_pointer* wl_pointer, uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||||
|
|
||||||
auto x = wl_fixed_to_double(surface_x);
|
auto x = wl_fixed_to_double(surface_x);
|
||||||
auto y = wl_fixed_to_double(surface_y);
|
auto y = wl_fixed_to_double(surface_y);
|
||||||
|
|
||||||
|
@ -122,36 +123,25 @@ void Events::handlePointerMotion(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::handlePointerButton(void* data, struct wl_pointer* wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t button_state) {
|
void Events::handlePointerButton(void* data, struct wl_pointer* wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t button_state) {
|
||||||
auto fmax3 = [](float a, float b, float c) -> float {
|
auto fmax3 = [](float a, float b, float c) -> float { return (a > b && a > c) ? a : (b > c) ? b : c; };
|
||||||
return (a > b && a > c) ? a : (b > c) ? b : c;
|
auto fmin3 = [](float a, float b, float c) -> float { return (a < b && a < c) ? a : (b < c) ? b : c; };
|
||||||
};
|
|
||||||
auto fmin3 = [](float a, float b, float c) -> float {
|
|
||||||
return (a < b && a < c) ? a : (b < c) ? b : c;
|
|
||||||
};
|
|
||||||
|
|
||||||
// get the px and print it
|
// get the px and print it
|
||||||
const auto SCALE = Vector2D{
|
const auto SCALE = Vector2D{
|
||||||
g_pHyprpicker->m_pLastSurface->screenBuffer.pixelSize.x / (g_pHyprpicker->m_pLastSurface->buffers[0].pixelSize.x / g_pHyprpicker->m_pLastSurface->m_pMonitor->scale),
|
g_pHyprpicker->m_pLastSurface->screenBuffer.pixelSize.x / (g_pHyprpicker->m_pLastSurface->buffers[0].pixelSize.x / g_pHyprpicker->m_pLastSurface->m_pMonitor->scale),
|
||||||
g_pHyprpicker->m_pLastSurface->screenBuffer.pixelSize.y / (g_pHyprpicker->m_pLastSurface->buffers[0].pixelSize.y / g_pHyprpicker->m_pLastSurface->m_pMonitor->scale)
|
g_pHyprpicker->m_pLastSurface->screenBuffer.pixelSize.y / (g_pHyprpicker->m_pLastSurface->buffers[0].pixelSize.y / g_pHyprpicker->m_pLastSurface->m_pMonitor->scale)};
|
||||||
};
|
|
||||||
|
|
||||||
const auto CLICKPOS = Vector2D{g_pHyprpicker->m_vLastCoords.floor().x * SCALE.x, g_pHyprpicker->m_vLastCoords.floor().y * SCALE.y};
|
const auto CLICKPOS = Vector2D{g_pHyprpicker->m_vLastCoords.floor().x * SCALE.x, g_pHyprpicker->m_vLastCoords.floor().y * SCALE.y};
|
||||||
|
|
||||||
const auto COL = g_pHyprpicker->getColorFromPixel(g_pHyprpicker->m_pLastSurface, CLICKPOS);
|
const auto COL = g_pHyprpicker->getColorFromPixel(g_pHyprpicker->m_pLastSurface, CLICKPOS);
|
||||||
|
|
||||||
switch (g_pHyprpicker->m_bSelectedOutputMode) {
|
switch (g_pHyprpicker->m_bSelectedOutputMode) {
|
||||||
case OUTPUT_CMYK:
|
case OUTPUT_CMYK: {
|
||||||
{
|
|
||||||
// http://www.codeproject.com/KB/applications/xcmyk.aspx
|
// http://www.codeproject.com/KB/applications/xcmyk.aspx
|
||||||
|
|
||||||
float r = 1 - COL.r / 255.0f,
|
float r = 1 - COL.r / 255.0f, g = 1 - COL.g / 255.0f, b = 1 - COL.b / 255.0f;
|
||||||
g = 1 - COL.g / 255.0f,
|
float k = fmin3(r, g, b), K = 1 - k;
|
||||||
b = 1 - COL.b / 255.0f;
|
float c = (r - k) / K, m = (g - k) / K, y = (b - k) / K;
|
||||||
float k = fmin3(r, g, b),
|
|
||||||
K = 1 - k;
|
|
||||||
float c = (r - k) / K,
|
|
||||||
m = (g - k) / K,
|
|
||||||
y = (b - k) / K;
|
|
||||||
|
|
||||||
c = std::round(c * 100);
|
c = std::round(c * 100);
|
||||||
m = std::round(m * 100);
|
m = std::round(m * 100);
|
||||||
|
@ -168,8 +158,7 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
g_pHyprpicker->finish();
|
g_pHyprpicker->finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OUTPUT_HEX:
|
case OUTPUT_HEX: {
|
||||||
{
|
|
||||||
auto toHex = [](int i) -> std::string {
|
auto toHex = [](int i) -> std::string {
|
||||||
const char* DS = "0123456789ABCDEF";
|
const char* DS = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
@ -191,8 +180,7 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
g_pHyprpicker->finish();
|
g_pHyprpicker->finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OUTPUT_RGB:
|
case OUTPUT_RGB: {
|
||||||
{
|
|
||||||
if (g_pHyprpicker->m_bFancyOutput)
|
if (g_pHyprpicker->m_bFancyOutput)
|
||||||
Debug::log(NONE, "\033[38;2;%i;%i;%im%i %i %i\033[0m", COL.r, COL.g, COL.b, COL.r, COL.g, COL.b);
|
Debug::log(NONE, "\033[38;2;%i;%i;%im%i %i %i\033[0m", COL.r, COL.g, COL.b, COL.r, COL.g, COL.b);
|
||||||
else
|
else
|
||||||
|
@ -204,8 +192,7 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OUTPUT_HSL:
|
case OUTPUT_HSL:
|
||||||
case OUTPUT_HSV:
|
case OUTPUT_HSV: {
|
||||||
{
|
|
||||||
// https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB
|
// https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB
|
||||||
|
|
||||||
auto floatEq = [](float a, float b) -> bool {
|
auto floatEq = [](float a, float b) -> bool {
|
||||||
|
@ -213,11 +200,8 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
};
|
};
|
||||||
|
|
||||||
float h, s, l, v;
|
float h, s, l, v;
|
||||||
float r = COL.r / 255.0f,
|
float r = COL.r / 255.0f, g = COL.g / 255.0f, b = COL.b / 255.0f;
|
||||||
g = COL.g / 255.0f,
|
float max = fmax3(r, g, b), min = fmin3(r, g, b);
|
||||||
b = COL.b / 255.0f;
|
|
||||||
float max = fmax3(r, g, b),
|
|
||||||
min = fmin3(r, g, b);
|
|
||||||
float c = max - min;
|
float c = max - min;
|
||||||
|
|
||||||
v = max;
|
v = max;
|
||||||
|
@ -259,27 +243,18 @@ void Events::handlePointerButton(void *data, struct wl_pointer *wl_pointer, uint
|
||||||
g_pHyprpicker->finish();
|
g_pHyprpicker->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::handleKeyboardKeymap(void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size) {
|
void Events::handleKeyboardKeymap(void* data, wl_keyboard* wl_keyboard, uint format, int fd, uint size) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::handleKeyboardKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
|
void Events::handleKeyboardKey(void* data, struct wl_keyboard* keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) {
|
||||||
if (key == 1) // escape
|
if (key == 1) // escape
|
||||||
g_pHyprpicker->finish();
|
g_pHyprpicker->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {
|
void Events::handleKeyboardEnter(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface, wl_array* keys) {}
|
||||||
|
|
||||||
}
|
void Events::handleKeyboardLeave(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface) {}
|
||||||
|
|
||||||
void Events::handleKeyboardLeave(void* data, wl_keyboard* wl_keyboard, uint serial, wl_surface* surface) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::handleKeyboardModifiers(void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
void Events::handleKeyboardModifiers(void* data, wl_keyboard* wl_keyboard, uint serial, uint mods_depressed, uint mods_latched, uint mods_locked, uint group) {}
|
||||||
|
|
||||||
void Events::handleFrameDone(void* data, struct wl_callback* callback, uint32_t time) {
|
void Events::handleFrameDone(void* data, struct wl_callback* callback, uint32_t time) {
|
||||||
CLayerSurface* pLS = (CLayerSurface*)data;
|
CLayerSurface* pLS = (CLayerSurface*)data;
|
||||||
|
|
|
@ -65,8 +65,10 @@ void CHyprpicker::recheckACK() {
|
||||||
zwlr_layer_surface_v1_ack_configure(ls->pLayerSurface, ls->ACKSerial);
|
zwlr_layer_surface_v1_ack_configure(ls->pLayerSurface, ls->ACKSerial);
|
||||||
|
|
||||||
if (!ls->buffers[0].buffer) {
|
if (!ls->buffers[0].buffer) {
|
||||||
createBuffer(&ls->buffers[0], ls->m_pMonitor->size.x * ls->m_pMonitor->scale, ls->m_pMonitor->size.y * ls->m_pMonitor->scale, WL_SHM_FORMAT_ARGB8888, ls->m_pMonitor->size.x * ls->m_pMonitor->scale * 4);
|
createBuffer(&ls->buffers[0], ls->m_pMonitor->size.x * ls->m_pMonitor->scale, ls->m_pMonitor->size.y * ls->m_pMonitor->scale, WL_SHM_FORMAT_ARGB8888,
|
||||||
createBuffer(&ls->buffers[1], ls->m_pMonitor->size.x * ls->m_pMonitor->scale, ls->m_pMonitor->size.y * ls->m_pMonitor->scale, WL_SHM_FORMAT_ARGB8888, ls->m_pMonitor->size.x * ls->m_pMonitor->scale * 4);
|
ls->m_pMonitor->size.x * ls->m_pMonitor->scale * 4);
|
||||||
|
createBuffer(&ls->buffers[1], ls->m_pMonitor->size.x * ls->m_pMonitor->scale, ls->m_pMonitor->size.y * ls->m_pMonitor->scale, WL_SHM_FORMAT_ARGB8888,
|
||||||
|
ls->m_pMonitor->size.x * ls->m_pMonitor->scale * 4);
|
||||||
|
|
||||||
int XCURSOR_SIZE = 24;
|
int XCURSOR_SIZE = 24;
|
||||||
if (getenv("XCURSOR_SIZE")) {
|
if (getenv("XCURSOR_SIZE")) {
|
||||||
|
@ -208,8 +210,7 @@ void CHyprpicker::createSeat(wl_seat* pSeat) {
|
||||||
void CHyprpicker::convertBuffer(SPoolBuffer* pBuffer) {
|
void CHyprpicker::convertBuffer(SPoolBuffer* pBuffer) {
|
||||||
switch (pBuffer->format) {
|
switch (pBuffer->format) {
|
||||||
case WL_SHM_FORMAT_ARGB8888:
|
case WL_SHM_FORMAT_ARGB8888:
|
||||||
case WL_SHM_FORMAT_XRGB8888:
|
case WL_SHM_FORMAT_XRGB8888: break;
|
||||||
break;
|
|
||||||
case WL_SHM_FORMAT_ABGR8888:
|
case WL_SHM_FORMAT_ABGR8888:
|
||||||
case WL_SHM_FORMAT_XBGR8888: {
|
case WL_SHM_FORMAT_XBGR8888: {
|
||||||
uint8_t* data = (uint8_t*)pBuffer->data;
|
uint8_t* data = (uint8_t*)pBuffer->data;
|
||||||
|
@ -261,8 +262,7 @@ void* convert24To32Buffer(SPoolBuffer* pBuffer) {
|
||||||
*dstPx = {srcPx->red, srcPx->green, srcPx->blue, 0xFF};
|
*dstPx = {srcPx->red, srcPx->green, srcPx->blue, 0xFF};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
case WL_SHM_FORMAT_RGB888: {
|
case WL_SHM_FORMAT_RGB888: {
|
||||||
for (int y = 0; y < pBuffer->pixelSize.y; ++y) {
|
for (int y = 0; y < pBuffer->pixelSize.y; ++y) {
|
||||||
for (int x = 0; x < pBuffer->pixelSize.x; ++x) {
|
for (int x = 0; x < pBuffer->pixelSize.x; ++x) {
|
||||||
|
@ -282,8 +282,7 @@ void* convert24To32Buffer(SPoolBuffer* pBuffer) {
|
||||||
*dstPx = {0xFF, srcPx->red, srcPx->green, srcPx->blue};
|
*dstPx = {0xFF, srcPx->red, srcPx->green, srcPx->blue};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} break;
|
||||||
break;
|
|
||||||
default: {
|
default: {
|
||||||
Debug::log(CRIT, "Unsupported format for 24bit buffer %i", pBuffer->format);
|
Debug::log(CRIT, "Unsupported format for 24bit buffer %i", pBuffer->format);
|
||||||
}
|
}
|
||||||
|
@ -303,20 +302,20 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
|
||||||
void* data = pSurface->screenBuffer.data;
|
void* data = pSurface->screenBuffer.data;
|
||||||
if (bytesPerPixel == 4) {
|
if (bytesPerPixel == 4) {
|
||||||
convertBuffer(&pSurface->screenBuffer);
|
convertBuffer(&pSurface->screenBuffer);
|
||||||
}
|
} else if (bytesPerPixel == 3) {
|
||||||
else if (bytesPerPixel == 3) {
|
|
||||||
Debug::log(WARN, "24 bit formats are unsupported, hyprpicker may or may not work as intended!");
|
Debug::log(WARN, "24 bit formats are unsupported, hyprpicker may or may not work as intended!");
|
||||||
data = convert24To32Buffer(&pSurface->screenBuffer);
|
data = convert24To32Buffer(&pSurface->screenBuffer);
|
||||||
pSurface->screenBuffer.paddedData = data;
|
pSurface->screenBuffer.paddedData = data;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Debug::log(CRIT, "Unsupported stride/bytes per pixel %i", bytesPerPixel);
|
Debug::log(CRIT, "Unsupported stride/bytes per pixel %i", bytesPerPixel);
|
||||||
g_pHyprpicker->finish(1);
|
g_pHyprpicker->finish(1);
|
||||||
}
|
}
|
||||||
pSurface->screenBuffer.surface = cairo_image_surface_create_for_data((unsigned char*)data, CAIRO_FORMAT_ARGB32, pSurface->screenBuffer.pixelSize.x, pSurface->screenBuffer.pixelSize.y, pSurface->screenBuffer.pixelSize.x * 4);
|
pSurface->screenBuffer.surface = cairo_image_surface_create_for_data((unsigned char*)data, CAIRO_FORMAT_ARGB32, pSurface->screenBuffer.pixelSize.x,
|
||||||
|
pSurface->screenBuffer.pixelSize.y, pSurface->screenBuffer.pixelSize.x * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
PBUFFER->surface = cairo_image_surface_create_for_data((unsigned char*)PBUFFER->data, CAIRO_FORMAT_ARGB32, pSurface->m_pMonitor->size.x * pSurface->m_pMonitor->scale, pSurface->m_pMonitor->size.y * pSurface->m_pMonitor->scale, PBUFFER->pixelSize.x * 4);
|
PBUFFER->surface = cairo_image_surface_create_for_data((unsigned char*)PBUFFER->data, CAIRO_FORMAT_ARGB32, pSurface->m_pMonitor->size.x * pSurface->m_pMonitor->scale,
|
||||||
|
pSurface->m_pMonitor->size.y * pSurface->m_pMonitor->scale, PBUFFER->pixelSize.x * 4);
|
||||||
PBUFFER->cairo = cairo_create(PBUFFER->surface);
|
PBUFFER->cairo = cairo_create(PBUFFER->surface);
|
||||||
|
|
||||||
const auto PCAIRO = PBUFFER->cairo;
|
const auto PCAIRO = PBUFFER->cairo;
|
||||||
|
@ -358,6 +357,7 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
|
||||||
//
|
//
|
||||||
|
|
||||||
cairo_restore(PCAIRO);
|
cairo_restore(PCAIRO);
|
||||||
|
if (!g_pHyprpicker->m_bNoZoom) {
|
||||||
cairo_save(PCAIRO);
|
cairo_save(PCAIRO);
|
||||||
|
|
||||||
const auto PIXCOLOR = getColorFromPixel(pSurface, CLICKPOS);
|
const auto PIXCOLOR = getColorFromPixel(pSurface, CLICKPOS);
|
||||||
|
@ -394,11 +394,26 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
|
||||||
cairo_restore(PCAIRO);
|
cairo_restore(PCAIRO);
|
||||||
|
|
||||||
cairo_pattern_destroy(PATTERN);
|
cairo_pattern_destroy(PATTERN);
|
||||||
} else {
|
}
|
||||||
|
} else if (!g_pHyprpicker->m_bRenderInactive) {
|
||||||
cairo_set_operator(PCAIRO, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator(PCAIRO, CAIRO_OPERATOR_SOURCE);
|
||||||
cairo_set_source_rgba(PCAIRO, 0, 0, 0, 0);
|
cairo_set_source_rgba(PCAIRO, 0, 0, 0, 0);
|
||||||
cairo_rectangle(PCAIRO, 0, 0, pSurface->m_pMonitor->size.x * pSurface->m_pMonitor->scale, pSurface->m_pMonitor->size.y * pSurface->m_pMonitor->scale);
|
cairo_rectangle(PCAIRO, 0, 0, pSurface->m_pMonitor->size.x * pSurface->m_pMonitor->scale, pSurface->m_pMonitor->size.y * pSurface->m_pMonitor->scale);
|
||||||
cairo_fill(PCAIRO);
|
cairo_fill(PCAIRO);
|
||||||
|
} else {
|
||||||
|
const auto SCALEBUFS = Vector2D{pSurface->screenBuffer.pixelSize.x / PBUFFER->pixelSize.x, pSurface->screenBuffer.pixelSize.y / PBUFFER->pixelSize.y};
|
||||||
|
const auto PATTERNPRE = cairo_pattern_create_for_surface(pSurface->screenBuffer.surface);
|
||||||
|
cairo_pattern_set_filter(PATTERNPRE, CAIRO_FILTER_BILINEAR);
|
||||||
|
cairo_matrix_t matrixPre;
|
||||||
|
cairo_matrix_init_identity(&matrixPre);
|
||||||
|
cairo_matrix_scale(&matrixPre, SCALEBUFS.x, SCALEBUFS.y);
|
||||||
|
cairo_pattern_set_matrix(PATTERNPRE, &matrixPre);
|
||||||
|
cairo_set_source(PCAIRO, PATTERNPRE);
|
||||||
|
cairo_paint(PCAIRO);
|
||||||
|
|
||||||
|
cairo_surface_flush(PBUFFER->surface);
|
||||||
|
|
||||||
|
cairo_pattern_destroy(PATTERNPRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFrame(pSurface);
|
sendFrame(pSurface);
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
#include "helpers/LayerSurface.hpp"
|
#include "helpers/LayerSurface.hpp"
|
||||||
#include "helpers/PoolBuffer.hpp"
|
#include "helpers/PoolBuffer.hpp"
|
||||||
|
|
||||||
enum eOutputMode {
|
enum eOutputMode
|
||||||
|
{
|
||||||
OUTPUT_CMYK = 0,
|
OUTPUT_CMYK = 0,
|
||||||
OUTPUT_HEX,
|
OUTPUT_HEX,
|
||||||
OUTPUT_RGB,
|
OUTPUT_RGB,
|
||||||
|
@ -30,6 +31,8 @@ public:
|
||||||
bool m_bFancyOutput = true;
|
bool m_bFancyOutput = true;
|
||||||
|
|
||||||
bool m_bAutoCopy = false;
|
bool m_bAutoCopy = false;
|
||||||
|
bool m_bRenderInactive = false;
|
||||||
|
bool m_bNoZoom = false;
|
||||||
|
|
||||||
bool m_bRunning = true;
|
bool m_bRunning = true;
|
||||||
|
|
||||||
|
@ -48,7 +51,6 @@ public:
|
||||||
void destroyBuffer(SPoolBuffer*);
|
void destroyBuffer(SPoolBuffer*);
|
||||||
int createPoolFile(size_t, std::string&);
|
int createPoolFile(size_t, std::string&);
|
||||||
bool setCloexec(const int&);
|
bool setCloexec(const int&);
|
||||||
|
|
||||||
void recheckACK();
|
void recheckACK();
|
||||||
|
|
||||||
void sendFrame(CLayerSurface*);
|
void sendFrame(CLayerSurface*);
|
||||||
|
@ -62,8 +64,8 @@ public:
|
||||||
void finish(int code = 0);
|
void finish(int code = 0);
|
||||||
|
|
||||||
CColor getColorFromPixel(CLayerSurface*, Vector2D);
|
CColor getColorFromPixel(CLayerSurface*, Vector2D);
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprpicker> g_pHyprpicker;
|
inline std::unique_ptr<CHyprpicker> g_pHyprpicker;
|
43
src/main.cpp
43
src/main.cpp
|
@ -1,13 +1,17 @@
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "hyprpicker.hpp"
|
#include "hyprpicker.hpp"
|
||||||
|
|
||||||
static void help(void) {
|
static void help(void) {
|
||||||
std::cout << "Hyprpicker usage: hyprpicker [arg [...]].\n\nArguments:\n" <<
|
std::cout << "Hyprpicker usage: hyprpicker [arg [...]].\n\nArguments:\n"
|
||||||
" -a | --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n" <<
|
<< " -a | --autocopy | Automatically copies the output to the clipboard (requires wl-clipboard)\n"
|
||||||
" -f | --format=fmt | Specifies the output format (cmyk, hex, rgb, hsl, hsv)\n" <<
|
<< " -f | --format=fmt | Specifies the output format (cmyk, hex, rgb, hsl, hsv)\n"
|
||||||
" -n | --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n" <<
|
<< " -n | --no-fancy | Disables the \"fancy\" (aka. colored) outputting\n"
|
||||||
" -h | --help | Show this help message\n";
|
<< " -h | --help | Show this help message\n"
|
||||||
|
<< " -r | --render-inactive | Render (freeze) inactive displays\n"
|
||||||
|
<< " -z | --no-zoom | Disable the zoom lens\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv, char** envp) {
|
int main(int argc, char** argv, char** envp) {
|
||||||
|
@ -15,15 +19,15 @@ int main(int argc, char** argv, char** envp) {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {{"autocopy", no_argument, NULL, 'a'},
|
||||||
{"autocopy", no_argument, NULL, 'a'},
|
|
||||||
{"format", required_argument, NULL, 'f'},
|
{"format", required_argument, NULL, 'f'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"no-fancy", no_argument, NULL, 'n'},
|
{"no-fancy", no_argument, NULL, 'n'},
|
||||||
{NULL, 0, NULL, 0 }
|
{"render-inactive", no_argument, NULL, 'r'},
|
||||||
};
|
{"no-zoom", no_argument, NULL, 'z'},
|
||||||
|
{NULL, 0, NULL, 0}};
|
||||||
|
|
||||||
int c = getopt_long(argc, argv, ":f:hna", long_options, &option_index);
|
int c = getopt_long(argc, argv, ":f:hnarz", long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -44,18 +48,13 @@ int main(int argc, char** argv, char** envp) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h': help(); exit(0);
|
||||||
help();
|
case 'n': g_pHyprpicker->m_bFancyOutput = false; break;
|
||||||
exit(0);
|
case 'a': g_pHyprpicker->m_bAutoCopy = true; break;
|
||||||
case 'n':
|
case 'r': g_pHyprpicker->m_bRenderInactive = true; break;
|
||||||
g_pHyprpicker->m_bFancyOutput = false;
|
case 'z': g_pHyprpicker->m_bNoZoom = true; break;
|
||||||
break;
|
|
||||||
case 'a':
|
default: help(); exit(1);
|
||||||
g_pHyprpicker->m_bAutoCopy = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
help();
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue