[Bf-blender-cvs] [5e5fe217caa] master: Cleanup: rename internal cursor grabbing function

Campbell Barton noreply at git.blender.org
Fri Jul 1 12:55:33 CEST 2022


Commit: 5e5fe217caaed35d6a39744d4f22b38793beae8f
Author: Campbell Barton
Date:   Fri Jul 1 20:35:11 2022 +1000
Branches: master
https://developer.blender.org/rB5e5fe217caaed35d6a39744d4f22b38793beae8f

Cleanup: rename internal cursor grabbing function

This function was named as if it was part of GHOST's API but was
in fact an internal utility.

===================================================================

M	intern/ghost/intern/GHOST_SystemWayland.cpp
M	intern/ghost/intern/GHOST_SystemWayland.h
M	intern/ghost/intern/GHOST_WindowWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 09784c67fda..6a419fc718d 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -3281,10 +3281,106 @@ static input_grab_state_t input_grab_state_from_mode(const GHOST_TGrabCursorMode
   return grab_state;
 }
 
-GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mode,
-                                                  const GHOST_TGrabCursorMode mode_current,
-                                                  int32_t init_grab_xy[2],
-                                                  wl_surface *surface)
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Public WAYLAND Direct Data Access
+ *
+ * Expose some members via methods.
+ * \{ */
+
+wl_display *GHOST_SystemWayland::display()
+{
+  return d->display;
+}
+
+wl_compositor *GHOST_SystemWayland::compositor()
+{
+  return d->compositor;
+}
+
+#ifdef WITH_GHOST_WAYLAND_LIBDECOR
+
+libdecor *GHOST_SystemWayland::decor_context()
+{
+  return d->decor_context;
+}
+
+#else /* WITH_GHOST_WAYLAND_LIBDECOR */
+
+xdg_wm_base *GHOST_SystemWayland::xdg_shell()
+{
+  return d->xdg_shell;
+}
+
+zxdg_decoration_manager_v1 *GHOST_SystemWayland::xdg_decoration_manager()
+{
+  return d->xdg_decoration_manager;
+}
+
+#endif /* !WITH_GHOST_WAYLAND_LIBDECOR */
+
+const std::vector<output_t *> &GHOST_SystemWayland::outputs() const
+{
+  return d->outputs;
+}
+
+wl_shm *GHOST_SystemWayland::shm() const
+{
+  return d->shm;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Public WAYLAND Query Access
+ * \{ */
+
+output_t *GHOST_SystemWayland::output_find_by_wl(const struct wl_output *output) const
+{
+  for (output_t *reg_output : this->outputs()) {
+    if (reg_output->wl_output == output) {
+      return reg_output;
+    }
+  }
+  return nullptr;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Public WAYLAND Utility Functions
+ *
+ * Functionality only used for the WAYLAND implementation.
+ * \{ */
+
+void GHOST_SystemWayland::selection_set(const std::string &selection)
+{
+  this->selection = selection;
+}
+
+void GHOST_SystemWayland::window_surface_unref(const wl_surface *surface)
+{
+#define SURFACE_CLEAR_PTR(surface_test) \
+  if (surface_test == surface) { \
+    surface_test = nullptr; \
+  } \
+  ((void)0);
+
+  /* Only clear window surfaces (not cursors, off-screen surfaces etc). */
+  for (input_t *input : d->inputs) {
+    SURFACE_CLEAR_PTR(input->pointer.wl_surface);
+    SURFACE_CLEAR_PTR(input->tablet.wl_surface);
+    SURFACE_CLEAR_PTR(input->keyboard.wl_surface);
+    SURFACE_CLEAR_PTR(input->focus_dnd);
+  }
+#undef SURFACE_CLEAR_PTR
+}
+
+bool GHOST_SystemWayland::window_cursor_grab_set(const GHOST_TGrabCursorMode mode,
+                                                 const GHOST_TGrabCursorMode mode_current,
+                                                 int32_t init_grab_xy[2],
+                                                 wl_surface *surface)
 {
   /* Ignore, if the required protocols are not supported. */
   if (!d->relative_pointer_manager || !d->pointer_constraints) {
@@ -3461,99 +3557,3 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mo
 }
 
 /** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Public WAYLAND Direct Data Access
- *
- * Expose some members via methods.
- * \{ */
-
-wl_display *GHOST_SystemWayland::display()
-{
-  return d->display;
-}
-
-wl_compositor *GHOST_SystemWayland::compositor()
-{
-  return d->compositor;
-}
-
-#ifdef WITH_GHOST_WAYLAND_LIBDECOR
-
-libdecor *GHOST_SystemWayland::decor_context()
-{
-  return d->decor_context;
-}
-
-#else /* WITH_GHOST_WAYLAND_LIBDECOR */
-
-xdg_wm_base *GHOST_SystemWayland::xdg_shell()
-{
-  return d->xdg_shell;
-}
-
-zxdg_decoration_manager_v1 *GHOST_SystemWayland::xdg_decoration_manager()
-{
-  return d->xdg_decoration_manager;
-}
-
-#endif /* !WITH_GHOST_WAYLAND_LIBDECOR */
-
-const std::vector<output_t *> &GHOST_SystemWayland::outputs() const
-{
-  return d->outputs;
-}
-
-wl_shm *GHOST_SystemWayland::shm() const
-{
-  return d->shm;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Public WAYLAND Query Access
- * \{ */
-
-output_t *GHOST_SystemWayland::output_find_by_wl(const struct wl_output *output) const
-{
-  for (output_t *reg_output : this->outputs()) {
-    if (reg_output->wl_output == output) {
-      return reg_output;
-    }
-  }
-  return nullptr;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Public WAYLAND Utility Functions
- *
- * Functionality only used for the WAYLAND implementation.
- * \{ */
-
-void GHOST_SystemWayland::selection_set(const std::string &selection)
-{
-  this->selection = selection;
-}
-
-void GHOST_SystemWayland::window_surface_unref(const wl_surface *surface)
-{
-#define SURFACE_CLEAR_PTR(surface_test) \
-  if (surface_test == surface) { \
-    surface_test = nullptr; \
-  } \
-  ((void)0);
-
-  /* Only clear window surfaces (not cursors, off-screen surfaces etc). */
-  for (input_t *input : d->inputs) {
-    SURFACE_CLEAR_PTR(input->pointer.wl_surface);
-    SURFACE_CLEAR_PTR(input->tablet.wl_surface);
-    SURFACE_CLEAR_PTR(input->keyboard.wl_surface);
-    SURFACE_CLEAR_PTR(input->focus_dnd);
-  }
-#undef SURFACE_CLEAR_PTR
-}
-
-/** \} */
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index 4286aa9d183..cf9ec5d0757 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -130,11 +130,6 @@ class GHOST_SystemWayland : public GHOST_System {
 
   bool getCursorGrabUseSoftwareDisplay(const GHOST_TGrabCursorMode mode);
 
-  GHOST_TSuccess setCursorGrab(const GHOST_TGrabCursorMode mode,
-                               const GHOST_TGrabCursorMode mode_current,
-                               int32_t init_grab_xy[2],
-                               wl_surface *surface);
-
   /* WAYLAND direct-data access. */
 
   wl_display *display();
@@ -163,6 +158,11 @@ class GHOST_SystemWayland : public GHOST_System {
   /** Clear all references to this surface to prevent accessing NULL pointers. */
   void window_surface_unref(const wl_surface *surface);
 
+  bool window_cursor_grab_set(const GHOST_TGrabCursorMode mode,
+                              const GHOST_TGrabCursorMode mode_current,
+                              int32_t init_grab_xy[2],
+                              wl_surface *surface);
+
  private:
   struct display_t *d;
   std::string selection;
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 00d75d62c9f..6cae60fc4b5 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -484,7 +484,10 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
 
 GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
 {
-  return m_system->setCursorGrab(mode, m_cursorGrab, m_cursorGrabInitPos, w->wl_surface);
+  if (m_system->window_cursor_grab_set(mode, m_cursorGrab, m_cursorGrabInitPos, w->wl_surface)) {
+    return GHOST_kSuccess;
+  }
+  return GHOST_kFailure;
 }
 
 GHOST_TSuccess GHOST_WindowWayland::setWindowCursorShape(GHOST_TStandardCursor shape)



More information about the Bf-blender-cvs mailing list