added drag and drop functionality

barebones but functioning
This commit is contained in:
vaxerski 2022-03-21 17:50:28 +01:00
parent 546fff6aa6
commit 30ae4be181
5 changed files with 24 additions and 2 deletions

View file

@ -29,7 +29,6 @@ Nevertheless, REPORT any you find! Make an issue!
- Blur
- Fadein/out
- Window rules
- Drag and drop
- Fix electron rendering issues
- Fix sloppy dragging of windows
- Optimization

View file

@ -5,6 +5,8 @@ CCompositor::CCompositor() {
unlink("/tmp/hypr/hyprlandd.log");
unlink("/tmp/hypr/.hyprlandrq");
system("mkdir -p /tmp/hypr");
m_sWLDisplay = wl_display_create();
m_sWLRBackend = wlr_backend_autocreate(m_sWLDisplay);
@ -88,6 +90,7 @@ void CCompositor::initAllSignals() {
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);
wl_signal_add(&m_sWLRSeat->events.request_start_drag, &Events::listen_requestDrag);
wl_signal_add(&m_sWLRLayerShell->events.new_surface, &Events::listen_newLayerSurface);
wl_signal_add(&m_sWLROutputLayout->events.change, &Events::listen_change);
wl_signal_add(&m_sWLROutputMgr->events.apply, &Events::listen_outputMgrApply);

View file

@ -81,4 +81,8 @@ namespace Events {
// XWayland
LISTENER(readyXWayland);
LISTENER(surfaceXWayland);
// Drag & Drop
LISTENER(requestDrag);
LISTENER(startDrag);
};

View file

@ -64,3 +64,19 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
xcb_disconnect(XCBCONNECTION);
}
void Events::listener_requestDrag(wl_listener* listener, void* data) {
const auto E = (wlr_seat_request_start_drag_event*)data;
if (!wlr_seat_validate_pointer_grab_serial(g_pCompositor->m_sWLRSeat, E->origin, E->serial)) {
Debug::log(LOG, "Ignoring drag and drop request: serial mismatch.");
wlr_data_source_destroy(E->drag->source);
return;
}
wlr_seat_start_pointer_drag(g_pCompositor->m_sWLRSeat, E->drag, E->serial);
}
void Events::listener_startDrag(wl_listener* listener, void* data) {
// TODO: draw the drag icon
}

View file

@ -315,7 +315,7 @@ void CHyprRenderer::arrangeLayerArray(SMonitor* pMonitor, const std::list<SLayer
wlr_layer_surface_v1_configure(ls->layerSurface, box.width, box.height);
Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i", &ls, box.x, box.y, box.width, box.height);
Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i with margins: t: %i l: %i r: %i b: %i", &ls, box.x, box.y, box.width, box.height, PSTATE->margin.top, PSTATE->margin.left, PSTATE->margin.right, PSTATE->margin.bottom);
}
}