diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2026-01-05 01:17:30 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2026-01-05 01:17:30 -0700 |
| commit | f6497f43b02e8b0351d0bbf0446c037161cda430 (patch) | |
| tree | e22df1dc0d053444c8129a596a6fe2f4e7f68a92 | |
| parent | 34e0354bb2d07ce0ad8a6e83e226370cfb9904da (diff) | |
| download | montis-f6497f43b02e8b0351d0bbf0446c037161cda430.tar.gz montis-f6497f43b02e8b0351d0bbf0446c037161cda430.tar.bz2 montis-f6497f43b02e8b0351d0bbf0446c037161cda430.zip | |
[fix] issue where dragging doesn't work on native.
| -rw-r--r-- | plug/src/Montis/Core/Internal/Foreign/Export.hs | 56 | ||||
| -rw-r--r-- | rt/include/plugin.h | 6 | ||||
| -rw-r--r-- | rt/src/wl.c | 7 |
3 files changed, 45 insertions, 24 deletions
diff --git a/plug/src/Montis/Core/Internal/Foreign/Export.hs b/plug/src/Montis/Core/Internal/Foreign/Export.hs index 132273a..faa1964 100644 --- a/plug/src/Montis/Core/Internal/Foreign/Export.hs +++ b/plug/src/Montis/Core/Internal/Foreign/Export.hs @@ -17,20 +17,18 @@ import Foreign mallocBytes, newStablePtr, ) -import Foreign.C (CChar, CDouble(..), CInt (..)) +import Foreign.C (CChar, CDouble (..), CInt (..)) import Foreign.Ptr (castPtr) import Montis.Base.Foreign.WlRoots.Types ( ForeignSurface (toSurface), ForeignWlrInputDevice, ForeignWlrPointer, - ForeignWlrPointerMotionAbsoluteEvent, ForeignWlrXWaylandSurface, ForeignWlrXdgSurface, WlrEventKeyboardKey, WlrInputDevice (WlrInputDevice), WlrPointer (WlrPointer), WlrPointerButtonEvent, - WlrPointerMotionAbsoluteEvent, ) import Montis.Core import Montis.Core.State @@ -156,27 +154,45 @@ pluginHandleKeybinding inputDevicePtr eventPtr mods sym cp = -- Motion handler foreign export ccall "plugin_handle_motion" - pluginHandleMotion :: Ptr WlrPointerMotionAbsoluteEvent -> Word32 -> CDouble -> CDouble -> OpqStT -> IO OpqStT + pluginHandleMotion :: Ptr Void -> Word32 -> Word32 -> CDouble -> CDouble -> OpqStT -> IO OpqStT -pluginHandleMotion :: Ptr WlrPointerMotionAbsoluteEvent -> Word32 -> CDouble -> CDouble -> OpqStT -> IO OpqStT -pluginHandleMotion eventPtr modifiers lx ly = +pluginHandleMotion :: Ptr Void -> Word32 -> Word32 -> CDouble -> CDouble -> OpqStT -> IO OpqStT +pluginHandleMotion eventPtr modifiers isAbsolute lx ly = runForeign $ do s <- gets currentHooks event <- liftIO $ - runDemarshal (castPtr eventPtr) $ do - -- After time_msec, wlroots pads to 8-byte alignment for doubles. - pointerPtr <- demarshal :: Demarshal (Ptr ForeignWlrPointer) - tMs <- demarshal - _ <- demarshal :: Demarshal Word32 - rawX <- demarshal - rawY <- demarshal - return $ - MotionEvent - (WlrPointer pointerPtr) - tMs - modifiers - (realToFrac lx, realToFrac ly) - (rawX, rawY) + if isAbsolute == 0 + then + runDemarshal (castPtr eventPtr) $ do + pointerPtr <- demarshal :: Demarshal (Ptr ForeignWlrPointer) + tMs <- demarshal + _ <- demarshal :: Demarshal Word32 + _ <- demarshal :: Demarshal Double + _ <- demarshal :: Demarshal Double + _ <- demarshal :: Demarshal Double + _ <- demarshal :: Demarshal Double + return $ + MotionEvent + (WlrPointer pointerPtr) + tMs + modifiers + (realToFrac lx, realToFrac ly) + (0, 0) + else + runDemarshal (castPtr eventPtr) $ do + -- After time_msec, wlroots pads to 8-byte alignment for doubles. + pointerPtr <- demarshal :: Demarshal (Ptr ForeignWlrPointer) + tMs <- demarshal + _ <- demarshal :: Demarshal Word32 + rawX <- demarshal + rawY <- demarshal + return $ + MotionEvent + (WlrPointer pointerPtr) + tMs + modifiers + (realToFrac lx, realToFrac ly) + (rawX, rawY) motionHook s event diff --git a/rt/include/plugin.h b/rt/include/plugin.h index d7ae18b..3098602 100644 --- a/rt/include/plugin.h +++ b/rt/include/plugin.h @@ -144,9 +144,9 @@ typedef struct PLUGIN { uint32_t modifiers, opqst_t state)); /* Absolute motion only for now; relative motion stays in the runtime. */ - EXPORT(opqst_t (*plugin_handle_motion)( - struct wlr_pointer_motion_absolute_event *event, uint32_t modifiers, - double lx, double ly, opqst_t state)); + EXPORT(opqst_t (*plugin_handle_motion)(void *event, uint32_t modifiers, + uint32_t is_absolute, double lx, + double ly, opqst_t state)); /* * Handles a surface being mapped, unmapped or destroyed. diff --git a/rt/src/wl.c b/rt/src/wl.c index f528c22..8963e39 100644 --- a/rt/src/wl.c +++ b/rt/src/wl.c @@ -429,6 +429,9 @@ static void server_cursor_motion(struct wl_listener *listener, void *data) struct montis_server *server = wl_container_of(listener, server, cursor_motion); struct wlr_pointer_motion_event *event = data; + struct wlr_seat *seat = server->seat; + struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat); + uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; /* The cursor doesn't move unless we tell it to. The cursor automatically * handles constraining the motion to the output layout, as well as any * special configuration applied for the specific input device which @@ -437,6 +440,8 @@ static void server_cursor_motion(struct wl_listener *listener, void *data) wlr_cursor_move(server->cursor, &event->pointer->base, event->delta_x, event->delta_y); process_cursor_motion(server, event->time_msec); + plugin_call_update_state(server->plugin, plugin_handle_motion, event, + modifiers, 0, server->cursor->x, server->cursor->y); } static void server_cursor_motion_absolute(struct wl_listener *listener, @@ -460,7 +465,7 @@ static void server_cursor_motion_absolute(struct wl_listener *listener, event->y); process_cursor_motion(server, event->time_msec); plugin_call_update_state(server->plugin, plugin_handle_motion, event, - modifiers, server->cursor->x, server->cursor->y); + modifiers, 1, server->cursor->x, server->cursor->y); } static void server_cursor_button(struct wl_listener *listener, void *data) |