mirror of https://github.com/hyprwm/Hyprland
fixed rendering
This commit is contained in:
parent
5971576a50
commit
625e4ce264
|
@ -1,6 +1,7 @@
|
||||||
#include "Compositor.hpp"
|
#include "Compositor.hpp"
|
||||||
|
|
||||||
CCompositor::CCompositor() {
|
CCompositor::CCompositor() {
|
||||||
|
|
||||||
m_sWLDisplay = wl_display_create();
|
m_sWLDisplay = wl_display_create();
|
||||||
|
|
||||||
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay);
|
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay);
|
||||||
|
@ -36,13 +37,10 @@ CCompositor::CCompositor() {
|
||||||
|
|
||||||
m_sWLROutputLayout = wlr_output_layout_create();
|
m_sWLROutputLayout = wlr_output_layout_create();
|
||||||
|
|
||||||
wl_signal_add(&m_sWLRBackend->events.new_output, &Events::listen_newOutput);
|
|
||||||
|
|
||||||
m_sWLRScene = wlr_scene_create();
|
m_sWLRScene = wlr_scene_create();
|
||||||
wlr_scene_attach_output_layout(m_sWLRScene, m_sWLROutputLayout);
|
wlr_scene_attach_output_layout(m_sWLRScene, m_sWLROutputLayout);
|
||||||
|
|
||||||
m_sWLRXDGShell = wlr_xdg_shell_create(m_sWLDisplay);
|
m_sWLRXDGShell = wlr_xdg_shell_create(m_sWLDisplay);
|
||||||
wl_signal_add(&m_sWLRXDGShell->events.new_surface, &Events::listen_newXDGSurface);
|
|
||||||
|
|
||||||
m_sWLRCursor = wlr_cursor_create();
|
m_sWLRCursor = wlr_cursor_create();
|
||||||
wlr_cursor_attach_output_layout(m_sWLRCursor, m_sWLROutputLayout);
|
wlr_cursor_attach_output_layout(m_sWLRCursor, m_sWLROutputLayout);
|
||||||
|
@ -50,31 +48,31 @@ CCompositor::CCompositor() {
|
||||||
m_sWLRXCursorMgr = wlr_xcursor_manager_create(nullptr, 24);
|
m_sWLRXCursorMgr = wlr_xcursor_manager_create(nullptr, 24);
|
||||||
wlr_xcursor_manager_load(m_sWLRXCursorMgr, 1);
|
wlr_xcursor_manager_load(m_sWLRXCursorMgr, 1);
|
||||||
|
|
||||||
wl_signal_add(&m_sWLRCursor->events.motion, &Events::listen_mouseMove);
|
|
||||||
wl_signal_add(&m_sWLRCursor->events.motion_absolute, &Events::listen_mouseMoveAbsolute);
|
|
||||||
wl_signal_add(&m_sWLRCursor->events.button, &Events::listen_mouseButton);
|
|
||||||
wl_signal_add(&m_sWLRCursor->events.axis, &Events::listen_mouseAxis);
|
|
||||||
wl_signal_add(&m_sWLRCursor->events.frame, &Events::listen_mouseFrame);
|
|
||||||
|
|
||||||
m_sWLRSeat = wlr_seat_create(m_sWLDisplay, "seat0");
|
m_sWLRSeat = wlr_seat_create(m_sWLDisplay, "seat0");
|
||||||
|
|
||||||
wl_signal_add(&m_sWLRBackend->events.new_input, &Events::listen_newInput);
|
|
||||||
wl_signal_add(&m_sWLRSeat->events.request_set_cursor, &Events::listen_requestMouse);
|
|
||||||
wl_signal_add(&m_sWLRSeat->events.request_set_selection, &Events::listen_requestSetSel);
|
|
||||||
|
|
||||||
m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend);
|
m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend);
|
||||||
|
|
||||||
m_sWLRIdle = wlr_idle_create(m_sWLDisplay);
|
m_sWLRIdle = wlr_idle_create(m_sWLDisplay);
|
||||||
|
|
||||||
// TODO: XWayland
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CCompositor::~CCompositor() {
|
CCompositor::~CCompositor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::startCompositor() {
|
void CCompositor::initAllSignals() {
|
||||||
|
wl_signal_add(&m_sWLRBackend->events.new_output, &Events::listen_newOutput);
|
||||||
|
wl_signal_add(&m_sWLRXDGShell->events.new_surface, &Events::listen_newXDGSurface);
|
||||||
|
wl_signal_add(&m_sWLRCursor->events.motion, &Events::listen_mouseMove);
|
||||||
|
wl_signal_add(&m_sWLRCursor->events.motion_absolute, &Events::listen_mouseMoveAbsolute);
|
||||||
|
wl_signal_add(&m_sWLRCursor->events.button, &Events::listen_mouseButton);
|
||||||
|
wl_signal_add(&m_sWLRCursor->events.axis, &Events::listen_mouseAxis);
|
||||||
|
wl_signal_add(&m_sWLRCursor->events.frame, &Events::listen_mouseFrame);
|
||||||
|
wl_signal_add(&m_sWLRBackend->events.new_input, &Events::listen_newInput);
|
||||||
|
wl_signal_add(&m_sWLRSeat->events.request_set_cursor, &Events::listen_requestMouse);
|
||||||
|
wl_signal_add(&m_sWLRSeat->events.request_set_selection, &Events::listen_requestSetSel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCompositor::startCompositor() {
|
||||||
// Init all the managers BEFORE we start with the wayland server so that ALL of the stuff is initialized
|
// Init all the managers BEFORE we start with the wayland server so that ALL of the stuff is initialized
|
||||||
// properly and we dont get any bad mem reads.
|
// properly and we dont get any bad mem reads.
|
||||||
//
|
//
|
||||||
|
@ -95,6 +93,8 @@ void CCompositor::startCompositor() {
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
|
initAllSignals();
|
||||||
|
|
||||||
m_szWLDisplaySocket = wl_display_add_socket_auto(m_sWLDisplay);
|
m_szWLDisplaySocket = wl_display_add_socket_auto(m_sWLDisplay);
|
||||||
|
|
||||||
if (!m_szWLDisplaySocket) {
|
if (!m_szWLDisplaySocket) {
|
||||||
|
|
|
@ -62,6 +62,9 @@ public:
|
||||||
bool windowExists(CWindow*);
|
bool windowExists(CWindow*);
|
||||||
bool windowValidMapped(CWindow*);
|
bool windowValidMapped(CWindow*);
|
||||||
CWindow* vectorToWindow(const Vector2D&);
|
CWindow* vectorToWindow(const Vector2D&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initAllSignals();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,8 @@ void Events::listener_mapWindow(wl_listener* listener, void* data) {
|
||||||
PWINDOW->m_bMappedX11 = true;
|
PWINDOW->m_bMappedX11 = true;
|
||||||
|
|
||||||
// test
|
// test
|
||||||
|
PWINDOW->m_vSize = PMONITOR->vecSize;
|
||||||
|
PWINDOW->m_vPosition = PMONITOR->vecPosition;
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, PMONITOR->vecSize);
|
g_pXWaylandManager->setWindowSize(PWINDOW, PMONITOR->vecSize);
|
||||||
g_pCompositor->focusWindow(PWINDOW);
|
g_pCompositor->focusWindow(PWINDOW);
|
||||||
|
|
||||||
|
@ -236,7 +238,7 @@ void Events::listener_setTitleWindow(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||||
|
|
||||||
Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle);
|
Debug::log(LOG, "Window %x set title to %s", PWINDOW, PWINDOW->m_szTitle.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_fullscreenWindow(wl_listener* listener, void* data) {
|
void Events::listener_fullscreenWindow(wl_listener* listener, void* data) {
|
||||||
|
@ -253,10 +255,6 @@ void Events::listener_mouseAxis(wl_listener* listener, void* data) {
|
||||||
// TODO:
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_mouseButton(wl_listener* listener, void* data) {
|
|
||||||
g_pInputManager->onMouseButton((wlr_event_pointer_button*)data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Events::listener_activateX11(wl_listener* listener, void* data) {
|
void Events::listener_activateX11(wl_listener* listener, void* data) {
|
||||||
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_activateX11);
|
CWindow* PWINDOW = wl_container_of(listener, PWINDOW, listen_activateX11);
|
||||||
|
|
||||||
|
@ -344,6 +342,10 @@ void Events::listener_mouseMoveAbsolute(wl_listener* listener, void* data) {
|
||||||
g_pInputManager->onMouseWarp((wlr_event_pointer_motion_absolute*)data);
|
g_pInputManager->onMouseWarp((wlr_event_pointer_motion_absolute*)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Events::listener_mouseButton(wl_listener* listener, void* data) {
|
||||||
|
g_pInputManager->onMouseButton((wlr_event_pointer_button*)data);
|
||||||
|
}
|
||||||
|
|
||||||
void Events::listener_newInput(wl_listener* listener, void* data) {
|
void Events::listener_newInput(wl_listener* listener, void* data) {
|
||||||
const auto DEVICE = (wlr_input_device*)data;
|
const auto DEVICE = (wlr_input_device*)data;
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,40 @@ void CInputManager::onMouseMoved(wlr_event_pointer_motion* e) {
|
||||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, e->device, delta.floor().x, delta.floor().y);
|
wlr_cursor_move(g_pCompositor->m_sWLRCursor, e->device, delta.floor().x, delta.floor().y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mouseMoveUnified(e->time_msec);
|
||||||
if (e->time_msec)
|
|
||||||
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat);
|
|
||||||
|
|
||||||
|
|
||||||
g_pCompositor->focusWindow(g_pCompositor->vectorToWindow(getMouseCoordsInternal()));
|
|
||||||
// todo: pointer
|
// todo: pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) {
|
void CInputManager::onMouseWarp(wlr_event_pointer_motion_absolute* e) {
|
||||||
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y);
|
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, e->device, e->x, e->y);
|
||||||
|
|
||||||
if (e->time_msec)
|
m_vMouseCoords = Vector2D(e->x, e->y);
|
||||||
|
m_vWLRMouseCoords = m_vMouseCoords;
|
||||||
|
|
||||||
|
mouseMoveUnified(e->time_msec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CInputManager::mouseMoveUnified(uint32_t time) {
|
||||||
|
|
||||||
|
const auto PWINDOW = g_pCompositor->vectorToWindow(m_vMouseCoords);
|
||||||
|
|
||||||
|
if (!PWINDOW) {
|
||||||
|
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
|
||||||
|
|
||||||
|
wlr_seat_pointer_clear_focus(g_pCompositor->m_sWLRSeat);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time)
|
||||||
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat);
|
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sWLRSeat);
|
||||||
|
|
||||||
|
g_pCompositor->focusWindow(PWINDOW);
|
||||||
|
|
||||||
|
Vector2D surfaceLocal = m_vMouseCoords - PWINDOW->m_vPosition;
|
||||||
|
|
||||||
|
wlr_seat_pointer_notify_enter(g_pCompositor->m_sWLRSeat, g_pXWaylandManager->getWindowSurface(PWINDOW), surfaceLocal.x, surfaceLocal.y);
|
||||||
|
wlr_seat_pointer_notify_motion(g_pCompositor->m_sWLRSeat, time, surfaceLocal.x, surfaceLocal.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseButton(wlr_event_pointer_button* e) {
|
void CInputManager::onMouseButton(wlr_event_pointer_button* e) {
|
||||||
|
|
|
@ -26,6 +26,8 @@ private:
|
||||||
|
|
||||||
std::list<SKeyboard> m_lKeyboards;
|
std::list<SKeyboard> m_lKeyboards;
|
||||||
|
|
||||||
|
void mouseMoveUnified(uint32_t);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CInputManager> g_pInputManager;
|
inline std::unique_ptr<CInputManager> g_pInputManager;
|
|
@ -51,7 +51,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
// render the bad boy
|
// render the bad boy
|
||||||
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y);
|
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y);
|
||||||
|
|
||||||
SRenderData renderdata = {PMONITOR->output, time, w.m_vSize.x, w.m_vSize.y};
|
SRenderData renderdata = {PMONITOR->output, time, w.m_vPosition.x, w.m_vPosition.y};
|
||||||
|
|
||||||
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata);
|
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata);
|
||||||
wlr_xdg_surface_for_each_popup_surface(w.m_uSurface.xdg, renderSurface, &renderdata);
|
wlr_xdg_surface_for_each_popup_surface(w.m_uSurface.xdg, renderSurface, &renderdata);
|
||||||
|
@ -62,7 +62,10 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
if (!w.m_bIsX11)
|
if (!w.m_bIsX11)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
wlr_box geometry = { w.m_uSurface.xwayland->x, w.m_uSurface.xwayland->y, w.m_uSurface.xwayland->width, w.m_uSurface.xwayland->height };
|
if (!g_pCompositor->windowValidMapped(&w))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wlr_box geometry = {w.m_vPosition.x, w.m_vPosition.y, w.m_vSize.x, w.m_vSize.y};
|
||||||
|
|
||||||
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &geometry))
|
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &geometry))
|
||||||
continue;
|
continue;
|
||||||
|
@ -70,7 +73,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
// render the bad boy
|
// render the bad boy
|
||||||
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y);
|
wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, PMONITOR->output, &w.m_vPosition.x, &w.m_vPosition.y);
|
||||||
|
|
||||||
SRenderData renderdata = {PMONITOR->output, time, w.m_vSize.x, w.m_vSize.y};
|
SRenderData renderdata = {PMONITOR->output, time, w.m_vPosition.x, w.m_vPosition.y};
|
||||||
|
|
||||||
if (w.m_uSurface.xwayland->surface)
|
if (w.m_uSurface.xwayland->surface)
|
||||||
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata);
|
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(&w), renderSurface, &renderdata);
|
||||||
|
|
Loading…
Reference in New Issue