Restore events/Devices.cpp formatting

This commit is contained in:
Darksome 2022-07-16 12:44:12 +03:00
parent e56ff0fcb0
commit fdbc54d97b

View file

@ -15,53 +15,55 @@
// // // //
// ---------------------------------------------------- // // ---------------------------------------------------- //
void Events::listener_keyboardDestroy(void *owner, void *data) { void Events::listener_keyboardDestroy(void* owner, void* data) {
SKeyboard *PKEYBOARD = (SKeyboard *)owner; SKeyboard* PKEYBOARD = (SKeyboard*)owner;
g_pInputManager->destroyKeyboard(PKEYBOARD); g_pInputManager->destroyKeyboard(PKEYBOARD);
Debug::log(LOG, "Destroyed keyboard %x", PKEYBOARD); Debug::log(LOG, "Destroyed keyboard %x", PKEYBOARD);
} }
void Events::listener_keyboardKey(void *owner, void *data) { void Events::listener_keyboardKey(void* owner, void* data) {
SKeyboard *PKEYBOARD = (SKeyboard *)owner; SKeyboard* PKEYBOARD = (SKeyboard*)owner;
g_pInputManager->onKeyboardKey((wlr_keyboard_key_event *)data, PKEYBOARD); g_pInputManager->onKeyboardKey((wlr_keyboard_key_event*)data, PKEYBOARD);
} }
void Events::listener_keyboardMod(void *owner, void *data) { void Events::listener_keyboardMod(void* owner, void* data) {
SKeyboard *PKEYBOARD = (SKeyboard *)owner; SKeyboard* PKEYBOARD = (SKeyboard*)owner;
g_pInputManager->onKeyboardMod(data, PKEYBOARD); g_pInputManager->onKeyboardMod(data, PKEYBOARD);
} }
void Events::listener_mouseFrame(wl_listener *listener, void *data) { void Events::listener_mouseFrame(wl_listener* listener, void* data) {
wlr_seat_pointer_notify_frame(g_pCompositor->m_sSeat.seat); wlr_seat_pointer_notify_frame(g_pCompositor->m_sSeat.seat);
} }
void Events::listener_mouseMove(wl_listener *listener, void *data) { void Events::listener_mouseMove(wl_listener* listener, void* data) {
g_pInputManager->onMouseMoved((wlr_pointer_motion_event *)data); g_pInputManager->onMouseMoved((wlr_pointer_motion_event*)data);
} }
void Events::listener_mouseMoveAbsolute(wl_listener *listener, void *data) { void Events::listener_mouseMoveAbsolute(wl_listener* listener, void* data) {
g_pInputManager->onMouseWarp((wlr_pointer_motion_absolute_event *)data); g_pInputManager->onMouseWarp((wlr_pointer_motion_absolute_event*)data);
} }
void Events::listener_mouseButton(wl_listener *listener, void *data) { void Events::listener_mouseButton(wl_listener* listener, void* data) {
g_pInputManager->onMouseButton((wlr_pointer_button_event *)data); g_pInputManager->onMouseButton((wlr_pointer_button_event*)data);
} }
void Events::listener_mouseAxis(wl_listener *listener, void *data) { void Events::listener_mouseAxis(wl_listener* listener, void* data) {
g_pInputManager->onMouseWheel((wlr_pointer_axis_event *)data); const auto E = (wlr_pointer_axis_event*)data;
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, E->time_msec, E->orientation, E->delta, E->delta_discrete, E->source);
} }
void Events::listener_requestMouse(wl_listener *listener, void *data) { void Events::listener_requestMouse(wl_listener* listener, void* data) {
const auto EVENT = (wlr_seat_pointer_request_set_cursor_event *)data; const auto EVENT = (wlr_seat_pointer_request_set_cursor_event*)data;
g_pInputManager->processMouseRequest(EVENT); g_pInputManager->processMouseRequest(EVENT);
} }
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;
switch (DEVICE->type) { switch(DEVICE->type) {
case WLR_INPUT_DEVICE_KEYBOARD: case WLR_INPUT_DEVICE_KEYBOARD:
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name); Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
g_pInputManager->newKeyboard(DEVICE); g_pInputManager->newKeyboard(DEVICE);
@ -72,8 +74,7 @@ void Events::listener_newInput(wl_listener *listener, void *data) {
break; break;
case WLR_INPUT_DEVICE_TOUCH: case WLR_INPUT_DEVICE_TOUCH:
Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name); Debug::log(LOG, "Attached a touch device with name %s", DEVICE->name);
Debug::log(WARN, "!!!! Hyprland does not directly support touchscreens, " Debug::log(WARN, "!!!! Hyprland does not directly support touchscreens, bugs may occur !!!!");
"bugs may occur !!!!");
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, DEVICE); wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, DEVICE);
break; break;
case WLR_INPUT_DEVICE_TABLET_TOOL: case WLR_INPUT_DEVICE_TABLET_TOOL:
@ -92,8 +93,8 @@ void Events::listener_newInput(wl_listener *listener, void *data) {
g_pInputManager->updateCapabilities(DEVICE); g_pInputManager->updateCapabilities(DEVICE);
} }
void Events::listener_newConstraint(wl_listener *listener, void *data) { void Events::listener_newConstraint(wl_listener* listener, void* data) {
const auto PCONSTRAINT = (wlr_pointer_constraint_v1 *)data; const auto PCONSTRAINT = (wlr_pointer_constraint_v1*)data;
Debug::log(LOG, "New mouse constraint at %x", PCONSTRAINT); Debug::log(LOG, "New mouse constraint at %x", PCONSTRAINT);
@ -103,48 +104,33 @@ void Events::listener_newConstraint(wl_listener *listener, void *data) {
CONSTRAINT->pMouse = g_pCompositor->m_sSeat.mouse; CONSTRAINT->pMouse = g_pCompositor->m_sSeat.mouse;
CONSTRAINT->constraint = PCONSTRAINT; CONSTRAINT->constraint = PCONSTRAINT;
CONSTRAINT->hyprListener_destroyConstraint.initCallback( CONSTRAINT->hyprListener_destroyConstraint.initCallback(&PCONSTRAINT->events.destroy, &Events::listener_destroyConstraint, CONSTRAINT, "Constraint");
&PCONSTRAINT->events.destroy, &Events::listener_destroyConstraint, CONSTRAINT->hyprListener_setConstraintRegion.initCallback(&PCONSTRAINT->events.set_region, &Events::listener_setConstraintRegion, CONSTRAINT, "Constraint");
CONSTRAINT, "Constraint");
CONSTRAINT->hyprListener_setConstraintRegion.initCallback(
&PCONSTRAINT->events.set_region, &Events::listener_setConstraintRegion,
CONSTRAINT, "Constraint");
if (g_pCompositor->m_pLastFocus == PCONSTRAINT->surface) { if (g_pCompositor->m_pLastFocus == PCONSTRAINT->surface) {
g_pInputManager->constrainMouse(CONSTRAINT->pMouse, PCONSTRAINT); g_pInputManager->constrainMouse(CONSTRAINT->pMouse, PCONSTRAINT);
} }
} }
void Events::listener_destroyConstraint(void *owner, void *data) { void Events::listener_destroyConstraint(void* owner, void* data) {
const auto PCONSTRAINT = (SConstraint *)owner; const auto PCONSTRAINT = (SConstraint*)owner;
if (PCONSTRAINT->pMouse->currentConstraint == PCONSTRAINT->constraint) { if (PCONSTRAINT->pMouse->currentConstraint == PCONSTRAINT->constraint) {
PCONSTRAINT->pMouse->hyprListener_commitConstraint.removeCallback(); PCONSTRAINT->pMouse->hyprListener_commitConstraint.removeCallback();
const auto PWINDOW = const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
if (PWINDOW) { if (PWINDOW) {
if (PWINDOW->m_bIsX11) { if (PWINDOW->m_bIsX11) {
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
PCONSTRAINT->constraint->current.cursor_hint.x + PCONSTRAINT->constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->constraint->current.cursor_hint.y);
PWINDOW->m_uSurface.xwayland->x,
PWINDOW->m_uSurface.xwayland->y +
PCONSTRAINT->constraint->current.cursor_hint.y);
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->constraint->current.cursor_hint.x, PCONSTRAINT->constraint->current.cursor_hint.y);
PCONSTRAINT->constraint->current.cursor_hint.x,
PCONSTRAINT->constraint->current.cursor_hint.y);
} else { } else {
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
PCONSTRAINT->constraint->current.cursor_hint.x + PCONSTRAINT->constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, PCONSTRAINT->constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
PWINDOW->m_vRealPosition.vec().x,
PCONSTRAINT->constraint->current.cursor_hint.y +
PWINDOW->m_vRealPosition.vec().y);
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->constraint->current.cursor_hint.x, PCONSTRAINT->constraint->current.cursor_hint.y);
PCONSTRAINT->constraint->current.cursor_hint.x,
PCONSTRAINT->constraint->current.cursor_hint.y);
} }
} }
@ -156,38 +142,38 @@ void Events::listener_destroyConstraint(void *owner, void *data) {
g_pInputManager->m_lConstraints.remove(*PCONSTRAINT); g_pInputManager->m_lConstraints.remove(*PCONSTRAINT);
} }
void Events::listener_setConstraintRegion(void *owner, void *data) { void Events::listener_setConstraintRegion(void* owner, void* data) {
// no // no
} }
void Events::listener_newVirtPtr(wl_listener *listener, void *data) { void Events::listener_newVirtPtr(wl_listener* listener, void* data) {
const auto EV = (wlr_virtual_pointer_v1_new_pointer_event *)data; const auto EV = (wlr_virtual_pointer_v1_new_pointer_event*)data;
const auto POINTER = EV->new_pointer; const auto POINTER = EV->new_pointer;
const auto DEVICE = &POINTER->pointer.base; const auto DEVICE = &POINTER->pointer.base;
g_pInputManager->newMouse(DEVICE, true); g_pInputManager->newMouse(DEVICE, true);
} }
void Events::listener_destroyMouse(void *owner, void *data) { void Events::listener_destroyMouse(void* owner, void* data) {
const auto PMOUSE = (SMouse *)owner; const auto PMOUSE = (SMouse*)owner;
g_pInputManager->destroyMouse(PMOUSE->mouse); g_pInputManager->destroyMouse(PMOUSE->mouse);
} }
void Events::listener_swipeBegin(wl_listener *listener, void *data) { void Events::listener_swipeBegin(wl_listener* listener, void* data) {
const auto EVENT = (wlr_pointer_swipe_begin_event *)data; const auto EVENT = (wlr_pointer_swipe_begin_event*)data;
g_pInputManager->onSwipeBegin(EVENT); g_pInputManager->onSwipeBegin(EVENT);
} }
void Events::listener_swipeUpdate(wl_listener *listener, void *data) { void Events::listener_swipeUpdate(wl_listener* listener, void* data) {
const auto EVENT = (wlr_pointer_swipe_update_event *)data; const auto EVENT = (wlr_pointer_swipe_update_event*)data;
g_pInputManager->onSwipeUpdate(EVENT); g_pInputManager->onSwipeUpdate(EVENT);
} }
void Events::listener_swipeEnd(wl_listener *listener, void *data) { void Events::listener_swipeEnd(wl_listener* listener, void* data) {
const auto EVENT = (wlr_pointer_swipe_end_event *)data; const auto EVENT = (wlr_pointer_swipe_end_event*)data;
g_pInputManager->onSwipeEnd(EVENT); g_pInputManager->onSwipeEnd(EVENT);
} }