mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-11-16 16:15:58 +01:00
parent
8a7799ae20
commit
b6130e3901
2 changed files with 13 additions and 3 deletions
|
@ -96,6 +96,9 @@ void Events::handlePointerEnter(void* data, struct wl_pointer* wl_pointer, uint3
|
||||||
if (ls->pSurface == surface) {
|
if (ls->pSurface == surface) {
|
||||||
g_pHyprpicker->m_pLastSurface = ls.get();
|
g_pHyprpicker->m_pLastSurface = ls.get();
|
||||||
|
|
||||||
|
if (!ls->pCursorImg)
|
||||||
|
break;
|
||||||
|
|
||||||
wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale);
|
wl_surface_set_buffer_scale(ls->pCursorSurface, ls->m_pMonitor->scale);
|
||||||
wl_surface_attach(ls->pCursorSurface, wl_cursor_image_get_buffer(ls->pCursorImg), 0, 0);
|
wl_surface_attach(ls->pCursorSurface, wl_cursor_image_get_buffer(ls->pCursorImg), 0, 0);
|
||||||
wl_pointer_set_cursor(wl_pointer, serial, ls->pCursorSurface, ls->pCursorImg->hotspot_x / ls->m_pMonitor->scale, ls->pCursorImg->hotspot_y / ls->m_pMonitor->scale);
|
wl_pointer_set_cursor(wl_pointer, serial, ls->pCursorSurface, ls->pCursorImg->hotspot_x / ls->m_pMonitor->scale, ls->pCursorImg->hotspot_y / ls->m_pMonitor->scale);
|
||||||
|
|
|
@ -80,7 +80,14 @@ void CHyprpicker::recheckACK() {
|
||||||
XCURSOR_SIZE = std::stoi(getenv("XCURSOR_SIZE"));
|
XCURSOR_SIZE = std::stoi(getenv("XCURSOR_SIZE"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ls->pCursorImg = wl_cursor_theme_get_cursor(wl_cursor_theme_load(getenv("XCURSOR_THEME"), XCURSOR_SIZE * ls->m_pMonitor->scale, m_pWLSHM), "crosshair")->images[0];
|
const auto THEME = wl_cursor_theme_load(getenv("XCURSOR_THEME"), XCURSOR_SIZE * ls->m_pMonitor->scale, m_pWLSHM);
|
||||||
|
auto cursor = wl_cursor_theme_get_cursor(THEME, "crosshair");
|
||||||
|
|
||||||
|
if (!cursor)
|
||||||
|
cursor = wl_cursor_theme_get_cursor(THEME, "left_ptr");
|
||||||
|
|
||||||
|
if (cursor)
|
||||||
|
ls->pCursorImg = cursor->images[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +249,7 @@ void CHyprpicker::convertBuffer(SPoolBuffer* pBuffer) {
|
||||||
|
|
||||||
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) {
|
||||||
uint32_t * px = (uint32_t*) (data + y * (int)pBuffer->pixelSize.x * 4 + x * 4);
|
uint32_t* px = (uint32_t*)(data + y * (int)pBuffer->pixelSize.x * 4 + x * 4);
|
||||||
|
|
||||||
// conv to 8 bit
|
// conv to 8 bit
|
||||||
uint8_t R = (uint8_t)std::round((255.0 * (((*px) & 0b00000000000000000000001111111111) >> 0) / 1023.0));
|
uint8_t R = (uint8_t)std::round((255.0 * (((*px) & 0b00000000000000000000001111111111) >> 0) / 1023.0));
|
||||||
|
@ -252,7 +259,7 @@ void CHyprpicker::convertBuffer(SPoolBuffer* pBuffer) {
|
||||||
|
|
||||||
// write 8-bit values
|
// write 8-bit values
|
||||||
*px = ((FLIP ? B : R) << 0) + (G << 8) + ((FLIP ? R : B) << 16) + (A << 24);
|
*px = ((FLIP ? B : R) << 0) + (G << 8) + ((FLIP ? R : B) << 16) + (A << 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
|
Loading…
Reference in a new issue