mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-04 14:11:59 -07:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
b08b72358a | ||
|
aac75ddcbf | ||
|
5cd5631fb2 | ||
|
b8a7b09092 | ||
|
81f4a4f471 | ||
|
2623364dbd | ||
|
3b03597784 | ||
|
ce9c5fd722 | ||
|
f2999e84b9 |
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "0.27.1"
|
"version": "0.27.2"
|
||||||
}
|
}
|
@@ -234,16 +234,7 @@ void CWindow::createToplevelHandle() {
|
|||||||
|
|
||||||
// handle events
|
// handle events
|
||||||
hyprListener_toplevelActivate.initCallback(
|
hyprListener_toplevelActivate.initCallback(
|
||||||
&m_phForeignToplevel->events.request_activate,
|
&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) { g_pLayoutManager->getCurrentLayout()->requestFocusForWindow(this); }, this, "Toplevel");
|
||||||
[&](void* owner, void* data) {
|
|
||||||
if (isHidden() && m_sGroupData.pNextWindow) {
|
|
||||||
// grouped, change the current to us
|
|
||||||
setGroupCurrent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_pCompositor->focusWindow(this);
|
|
||||||
},
|
|
||||||
this, "Toplevel");
|
|
||||||
|
|
||||||
hyprListener_toplevelFullscreen.initCallback(
|
hyprListener_toplevelFullscreen.initCallback(
|
||||||
&m_phForeignToplevel->events.request_fullscreen,
|
&m_phForeignToplevel->events.request_fullscreen,
|
||||||
|
@@ -28,7 +28,8 @@ typedef struct {
|
|||||||
} xcb_size_hints_t;
|
} xcb_size_hints_t;
|
||||||
typedef unsigned int xcb_window_t;
|
typedef unsigned int xcb_window_t;
|
||||||
|
|
||||||
typedef enum xcb_stack_mode_t {
|
typedef enum xcb_stack_mode_t
|
||||||
|
{
|
||||||
XCB_STACK_MODE_ABOVE = 0,
|
XCB_STACK_MODE_ABOVE = 0,
|
||||||
XCB_STACK_MODE_BELOW = 1,
|
XCB_STACK_MODE_BELOW = 1,
|
||||||
XCB_STACK_MODE_TOP_IF = 2,
|
XCB_STACK_MODE_TOP_IF = 2,
|
||||||
|
@@ -519,4 +519,13 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
|||||||
return PWINDOWCANDIDATE;
|
return PWINDOWCANDIDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IHyprLayout::requestFocusForWindow(CWindow* pWindow) {
|
||||||
|
if (pWindow->isHidden() && pWindow->m_sGroupData.pNextWindow) {
|
||||||
|
// grouped, change the current to this window
|
||||||
|
pWindow->setGroupCurrent(pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pCompositor->focusWindow(pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
IHyprLayout::~IHyprLayout() {}
|
IHyprLayout::~IHyprLayout() {}
|
||||||
|
@@ -148,6 +148,13 @@ interface IHyprLayout {
|
|||||||
*/
|
*/
|
||||||
virtual void replaceWindowDataWith(CWindow* from, CWindow* to) = 0;
|
virtual void replaceWindowDataWith(CWindow* from, CWindow* to) = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Called via the foreign toplevel activation protocol.
|
||||||
|
Focuses a window, bringing it to the top of its group if applicable.
|
||||||
|
May be ignored.
|
||||||
|
*/
|
||||||
|
virtual void requestFocusForWindow(CWindow*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector2D m_vBeginDragXY;
|
Vector2D m_vBeginDragXY;
|
||||||
Vector2D m_vLastDragXY;
|
Vector2D m_vLastDragXY;
|
||||||
|
@@ -1013,11 +1013,9 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto PWINDOWTOCHANGETO = PLASTWINDOW->m_bIsFullscreen
|
const auto PWINDOWTOCHANGETO = PLASTWINDOW->m_bIsFullscreen ?
|
||||||
? (arg == 'd' || arg == 'b' || arg == 'r'
|
(arg == 'd' || arg == 'b' || arg == 'r' ? g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true) : g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW, true)) :
|
||||||
? g_pCompositor->getNextWindowOnWorkspace(PLASTWINDOW, true)
|
g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
||||||
: g_pCompositor->getPrevWindowOnWorkspace(PLASTWINDOW, true))
|
|
||||||
: g_pCompositor->getWindowInDirection(PLASTWINDOW, arg);
|
|
||||||
|
|
||||||
// Found window in direction, switch to it
|
// Found window in direction, switch to it
|
||||||
if (PWINDOWTOCHANGETO) {
|
if (PWINDOWTOCHANGETO) {
|
||||||
@@ -2088,6 +2086,9 @@ void CKeybindManager::moveGroupWindow(std::string args) {
|
|||||||
if (!g_pCompositor->m_pLastWindow || !g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow)
|
if (!g_pCompositor->m_pLastWindow || !g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_pCompositor->m_pLastWindow->switchWithWindowInGroup(BACK ? g_pCompositor->m_pLastWindow->getGroupPrevious() : g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow);
|
if ((!BACK && g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow->m_sGroupData.head) || (BACK && g_pCompositor->m_pLastWindow->m_sGroupData.head))
|
||||||
|
std::swap(g_pCompositor->m_pLastWindow->m_sGroupData.head, g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow->m_sGroupData.head);
|
||||||
|
else
|
||||||
|
g_pCompositor->m_pLastWindow->switchWithWindowInGroup(BACK ? g_pCompositor->m_pLastWindow->getGroupPrevious() : g_pCompositor->m_pLastWindow->m_sGroupData.pNextWindow);
|
||||||
g_pCompositor->m_pLastWindow->updateWindowDecos();
|
g_pCompositor->m_pLastWindow->updateWindowDecos();
|
||||||
}
|
}
|
||||||
|
@@ -326,15 +326,11 @@ void CScreencopyProtocolManager::copyFrame(wl_client* client, wl_resource* resou
|
|||||||
|
|
||||||
void CScreencopyProtocolManager::onOutputCommit(CMonitor* pMonitor, wlr_output_event_commit* e) {
|
void CScreencopyProtocolManager::onOutputCommit(CMonitor* pMonitor, wlr_output_event_commit* e) {
|
||||||
m_pLastMonitorBackBuffer = e->buffer;
|
m_pLastMonitorBackBuffer = e->buffer;
|
||||||
shareAllFrames(pMonitor, true);
|
shareAllFrames(pMonitor);
|
||||||
m_pLastMonitorBackBuffer = nullptr;
|
m_pLastMonitorBackBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScreencopyProtocolManager::onRenderEnd(CMonitor* pMonitor) {
|
void CScreencopyProtocolManager::shareAllFrames(CMonitor* pMonitor) {
|
||||||
shareAllFrames(pMonitor, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CScreencopyProtocolManager::shareAllFrames(CMonitor* pMonitor, bool dmabuf) {
|
|
||||||
if (m_vFramesAwaitingWrite.empty())
|
if (m_vFramesAwaitingWrite.empty())
|
||||||
return; // nothing to share
|
return; // nothing to share
|
||||||
|
|
||||||
@@ -347,7 +343,7 @@ void CScreencopyProtocolManager::shareAllFrames(CMonitor* pMonitor, bool dmabuf)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->pMonitor != pMonitor || dmabuf != (f->bufferCap == WLR_BUFFER_CAP_DMABUF))
|
if (f->pMonitor != pMonitor)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
shareFrame(f);
|
shareFrame(f);
|
||||||
@@ -409,6 +405,12 @@ void CScreencopyProtocolManager::sendFrameDamage(SScreencopyFrame* frame) {
|
|||||||
|
|
||||||
PIXMAN_DAMAGE_FOREACH(&frame->pMonitor->lastFrameDamage) {
|
PIXMAN_DAMAGE_FOREACH(&frame->pMonitor->lastFrameDamage) {
|
||||||
const auto RECT = &RECTSARR[i];
|
const auto RECT = &RECTSARR[i];
|
||||||
|
|
||||||
|
if (frame->buffer->width < 1 || frame->buffer->height < 1 || frame->buffer->width - RECT->x1 < 1 || frame->buffer->height - RECT->y1 < 1) {
|
||||||
|
Debug::log(ERR, "[sc] Failed to send damage");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
zwlr_screencopy_frame_v1_send_damage(frame->resource, std::clamp(RECT->x1, 0, frame->buffer->width), std::clamp(RECT->y1, 0, frame->buffer->height),
|
zwlr_screencopy_frame_v1_send_damage(frame->resource, std::clamp(RECT->x1, 0, frame->buffer->width), std::clamp(RECT->y1, 0, frame->buffer->height),
|
||||||
std::clamp(RECT->x2 - RECT->x1, 0, frame->buffer->width - RECT->x1),
|
std::clamp(RECT->x2 - RECT->x1, 0, frame->buffer->width - RECT->x1),
|
||||||
std::clamp(RECT->y2 - RECT->y1, 0, frame->buffer->height - RECT->y1));
|
std::clamp(RECT->y2 - RECT->y1, 0, frame->buffer->height - RECT->y1));
|
||||||
@@ -423,46 +425,18 @@ bool CScreencopyProtocolManager::copyFrameShm(SScreencopyFrame* frame, timespec*
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// render the client
|
// render the client
|
||||||
const auto PMONITOR = frame->pMonitor;
|
const auto PMONITOR = frame->pMonitor;
|
||||||
pixman_region32_t fakeDamage;
|
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
|
|
||||||
|
|
||||||
if (!wlr_output_attach_render(PMONITOR->output, nullptr)) {
|
if (!wlr_renderer_begin_with_buffer(g_pCompositor->m_sWLRRenderer, m_pLastMonitorBackBuffer)) {
|
||||||
Debug::log(ERR, "[screencopy] Couldn't attach render");
|
|
||||||
pixman_region32_fini(&fakeDamage);
|
|
||||||
wlr_buffer_end_data_ptr_access(frame->buffer);
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PFORMAT = get_gles2_format_from_drm(format);
|
bool success = wlr_renderer_read_pixels(g_pCompositor->m_sWLRRenderer, format, stride, frame->box.width, frame->box.height, frame->box.x, frame->box.y, 0, 0, data);
|
||||||
if (!PFORMAT) {
|
wlr_renderer_end(g_pCompositor->m_sWLRRenderer);
|
||||||
Debug::log(ERR, "[screencopy] Cannot read pixels, unsupported format %lx", PFORMAT);
|
|
||||||
wlr_output_rollback(PMONITOR->output);
|
|
||||||
pixman_region32_fini(&fakeDamage);
|
|
||||||
wlr_buffer_end_data_ptr_access(frame->buffer);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_pHyprOpenGL->begin(PMONITOR, &fakeDamage, true);
|
|
||||||
|
|
||||||
// we should still have the last frame by this point in the original fb
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, g_pHyprOpenGL->m_RenderData.pCurrentMonData->primaryFB.m_iFb);
|
|
||||||
|
|
||||||
glFinish(); // flush
|
|
||||||
|
|
||||||
glReadPixels(frame->box.x, frame->box.y, frame->box.width, frame->box.height, PFORMAT->gl_format, PFORMAT->gl_type, data);
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, g_pHyprOpenGL->m_iWLROutputFb);
|
|
||||||
|
|
||||||
g_pHyprOpenGL->end();
|
|
||||||
|
|
||||||
wlr_output_rollback(PMONITOR->output);
|
|
||||||
|
|
||||||
pixman_region32_fini(&fakeDamage);
|
|
||||||
|
|
||||||
wlr_buffer_end_data_ptr_access(frame->buffer);
|
wlr_buffer_end_data_ptr_access(frame->buffer);
|
||||||
|
|
||||||
return true;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
||||||
@@ -482,6 +456,7 @@ bool CScreencopyProtocolManager::copyFrameDmabuf(SScreencopyFrame* frame) {
|
|||||||
|
|
||||||
float color[] = {0, 0, 0, 0};
|
float color[] = {0, 0, 0, 0};
|
||||||
wlr_renderer_clear(g_pCompositor->m_sWLRRenderer, color);
|
wlr_renderer_clear(g_pCompositor->m_sWLRRenderer, color);
|
||||||
|
// TODO: use hl render methods to use damage
|
||||||
wlr_render_texture_with_matrix(g_pCompositor->m_sWLRRenderer, sourceTex, glMatrix, 1.0f);
|
wlr_render_texture_with_matrix(g_pCompositor->m_sWLRRenderer, sourceTex, glMatrix, 1.0f);
|
||||||
|
|
||||||
wlr_texture_destroy(sourceTex);
|
wlr_texture_destroy(sourceTex);
|
||||||
|
@@ -77,7 +77,6 @@ class CScreencopyProtocolManager {
|
|||||||
|
|
||||||
void copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer);
|
void copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer);
|
||||||
|
|
||||||
void onRenderEnd(CMonitor* pMonitor);
|
|
||||||
void onOutputCommit(CMonitor* pMonitor, wlr_output_event_commit* e);
|
void onOutputCommit(CMonitor* pMonitor, wlr_output_event_commit* e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -91,7 +90,7 @@ class CScreencopyProtocolManager {
|
|||||||
|
|
||||||
wlr_buffer* m_pLastMonitorBackBuffer = nullptr;
|
wlr_buffer* m_pLastMonitorBackBuffer = nullptr;
|
||||||
|
|
||||||
void shareAllFrames(CMonitor* pMonitor, bool dmabuf);
|
void shareAllFrames(CMonitor* pMonitor);
|
||||||
void shareFrame(SScreencopyFrame* frame);
|
void shareFrame(SScreencopyFrame* frame);
|
||||||
void sendFrameDamage(SScreencopyFrame* frame);
|
void sendFrameDamage(SScreencopyFrame* frame);
|
||||||
bool copyFrameDmabuf(SScreencopyFrame* frame);
|
bool copyFrameDmabuf(SScreencopyFrame* frame);
|
||||||
|
@@ -1073,7 +1073,6 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pProtocolManager->m_pScreencopyProtocolManager->onRenderEnd(pMonitor);
|
|
||||||
pixman_region32_fini(&damage);
|
pixman_region32_fini(&damage);
|
||||||
|
|
||||||
if (UNLOCK_SC)
|
if (UNLOCK_SC)
|
||||||
@@ -1588,6 +1587,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||||||
wlr_output_set_transform(pMonitor->output, pMonitorRule->transform);
|
wlr_output_set_transform(pMonitor->output, pMonitorRule->transform);
|
||||||
pMonitor->transform = pMonitorRule->transform;
|
pMonitor->transform = pMonitorRule->transform;
|
||||||
|
|
||||||
|
const auto WLRREFRESHRATE = (wlr_backend_is_wl(pMonitor->output->backend) || wlr_backend_is_x11(pMonitor->output->backend)) ? 0 : pMonitorRule->refreshRate * 1000;
|
||||||
|
|
||||||
// loop over modes and choose an appropriate one.
|
// loop over modes and choose an appropriate one.
|
||||||
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1, -1) && pMonitorRule->resolution != Vector2D(-1, -2)) {
|
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1, -1) && pMonitorRule->resolution != Vector2D(-1, -2)) {
|
||||||
if (!wl_list_empty(&pMonitor->output->modes) && pMonitorRule->drmMode.type != DRM_MODE_TYPE_USERDEF) {
|
if (!wl_list_empty(&pMonitor->output->modes) && pMonitorRule->drmMode.type != DRM_MODE_TYPE_USERDEF) {
|
||||||
@@ -1619,7 +1620,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE);
|
||||||
pMonitor->vecSize = pMonitorRule->resolution;
|
pMonitor->vecSize = pMonitorRule->resolution;
|
||||||
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
||||||
|
|
||||||
@@ -1667,7 +1668,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, WLRREFRESHRATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pMonitor->vecSize = pMonitorRule->resolution;
|
pMonitor->vecSize = pMonitorRule->resolution;
|
||||||
|
Reference in New Issue
Block a user