Skip to content

Commit c744bfd

Browse files
committed
Fix cross-platform build and type errors in tab drag implementation
- Add _glfwPlatformSetDragTitle stub for X11, Wayland, and null platforms - Fix _glfwInputDrop declaration to match implementation (void return) - Fix drop_callback return type to match GLFWdropfun typedef - Fix type error: use 0 instead of None for dragging_tab_id - Add freeDragMimes cleanup in _glfwPlatformDestroyWindow to prevent memory leak
1 parent fb96781 commit c744bfd

7 files changed

Lines changed: 26 additions & 9 deletions

File tree

glfw/cocoa_window.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
23602360
window->ns.dragTitle = NULL;
23612361
}
23622362

2363+
// Clean up cached drag MIME types
2364+
freeDragMimes(window);
2365+
23632366
if (_glfw.ns.disabledCursorWindow == window)
23642367
_glfw.ns.disabledCursorWindow = NULL;
23652368

glfw/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ void _glfwInputScroll(_GLFWwindow* window, const GLFWScrollEvent *ev);
824824
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
825825
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
826826
void _glfwInputCursorEnter(_GLFWwindow* window, bool entered);
827-
int _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz);
827+
void _glfwInputDrop(_GLFWwindow* window, const char *mime, const char *text, size_t sz);
828828
int _glfwInputDragEvent(_GLFWwindow* window, int event, double xpos, double ypos, const char** mime_types, int* mime_count);
829829
void _glfwInputDragEnd(_GLFWwindow* window, bool accepted, double screen_x, double screen_y);
830830
void _glfwInputColorScheme(GLFWColorScheme, bool);

glfw/null_window.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,11 @@ void _glfwPlatformUpdateDragState(_GLFWwindow* window UNUSED)
544544
// No-op for null platform
545545
}
546546

547+
void _glfwPlatformSetDragTitle(_GLFWwindow* window UNUSED, const char* title UNUSED)
548+
{
549+
// No-op for null platform
550+
}
551+
547552
void _glfwPlatformSetClipboardString(const char* string)
548553
{
549554
char* copy = _glfw_strdup(string);

glfw/wl_window.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,3 +3198,8 @@ _glfwPlatformUpdateDragState(_GLFWwindow* window) {
31983198
}
31993199
}
32003200

3201+
void _glfwPlatformSetDragTitle(_GLFWwindow* window UNUSED, const char* title UNUSED)
3202+
{
3203+
// No-op: drag title display not supported on Wayland
3204+
}
3205+

glfw/x11_window.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,3 +3868,8 @@ void _glfwPlatformUpdateDragState(_GLFWwindow* window) {
38683868
XFlush(_glfw.x11.display);
38693869
}
38703870

3871+
void _glfwPlatformSetDragTitle(_GLFWwindow* window UNUSED, const char* title UNUSED)
3872+
{
3873+
// No-op: drag title display not supported on X11
3874+
}
3875+

kitty/glfw.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,24 +757,23 @@ drag_callback(GLFWwindow *w, GLFWDragEventType event, double xpos, double ypos,
757757
return ret;
758758
}
759759

760-
static int
760+
static void
761761
drop_callback(GLFWwindow *w, const char *mime, const char *data, size_t sz) {
762-
if (!set_callback_window(w)) return 0;
763-
#define RETURN(x) { global_state.callback_os_window = NULL; return x; }
762+
if (!set_callback_window(w)) return;
763+
#define RETURN { global_state.callback_os_window = NULL; return; }
764764

765765
// Handle kitty tab drop
766766
if (is_kitty_tab_mime(mime)) {
767-
if (!data) RETURN(1); // Accept kitty tab MIMEs during ENTER check
767+
if (!data) RETURN; // Accept kitty tab MIMEs during ENTER check
768768
WINDOW_CALLBACK(on_tab_drop, "s#", data, (Py_ssize_t)sz);
769769
request_tick_callback();
770-
RETURN(1);
770+
RETURN;
771771
}
772772
// Handle other drops (files, text, etc.)
773-
if (!data) RETURN(is_droppable_mime(mime) ? 1 : 0);
773+
if (!data) RETURN;
774774
WINDOW_CALLBACK(on_drop, "sy#", mime, data, (Py_ssize_t)sz);
775775
request_tick_callback();
776776
global_state.callback_os_window = NULL;
777-
return 1;
778777
#undef RETURN
779778
}
780779

kitty/tabs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,7 @@ def _cancel_tab_drag(self) -> None:
16951695
"""Cancel the current tab drag operation and clean up state."""
16961696
if self.tab_drag_state is not None:
16971697
self.tab_drag_state = None
1698-
self.tab_bar.dragging_tab_id = None
1698+
self.tab_bar.dragging_tab_id = 0
16991699
self.tab_bar.update_drag_indicator(None, None)
17001700
set_tab_bar_drag_in_progress(False)
17011701
self.mark_tab_bar_dirty()

0 commit comments

Comments
 (0)