Fix some more misc bugs in the DnD code
This commit is contained in:
parent
78d474fee3
commit
27ad4bc070
2 changed files with 12 additions and 10 deletions
|
|
@ -794,6 +794,7 @@ on_drop(GLFWwindow *window, GLFWDropEvent *ev) {
|
|||
case GLFW_DROP_ENTER:
|
||||
case GLFW_DROP_MOVE:
|
||||
global_state.drop_dest.drop_has_happened = false;
|
||||
global_state.drop_dest.os_window_id = os_window->id;
|
||||
os_window->last_drag_event.x = (int)(ev->xpos * os_window->viewport_x_ratio);
|
||||
os_window->last_drag_event.y = (int)(ev->ypos * os_window->viewport_y_ratio);
|
||||
on_mouse_position_update(ev->xpos, ev->ypos);
|
||||
|
|
@ -826,6 +827,7 @@ on_drop(GLFWwindow *window, GLFWDropEvent *ev) {
|
|||
Py_CLEAR(global_state.drop_dest.data);
|
||||
global_state.drop_dest.drop_has_happened = true;
|
||||
global_state.drop_dest.client_window_data_request = 0;
|
||||
global_state.drop_dest.os_window_id = os_window->id;
|
||||
if (is_kitty_ui_drag) {
|
||||
if (ev->from_self) {
|
||||
if (global_state.drag_source.drag_data) {
|
||||
|
|
@ -864,8 +866,9 @@ on_drop(GLFWwindow *window, GLFWDropEvent *ev) {
|
|||
|
||||
void
|
||||
request_drop_status_update(OSWindow *osw) {
|
||||
if (osw && osw->handle && !global_state.drop_dest.drop_has_happened && global_state.drop_dest.os_window_id == osw->id)
|
||||
if (osw && osw->handle && !global_state.drop_dest.drop_has_happened && global_state.drop_dest.os_window_id == osw->id) {
|
||||
glfwRequestDropUpdate(osw->handle);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@ import (
|
|||
"strings"
|
||||
|
||||
kitty "github.com/kovidgoyal/kitty"
|
||||
"github.com/kovidgoyal/kitty/tools/tty"
|
||||
"github.com/kovidgoyal/kitty/tools/tui/loop"
|
||||
)
|
||||
|
||||
var _ = fmt.Print
|
||||
var debugprintln = tty.DebugPrintln
|
||||
|
||||
const dnd_accepted_mimes = "text/plain text/uri-list"
|
||||
|
||||
|
|
@ -301,15 +303,12 @@ func Run(args []string) (rc int, err error) {
|
|||
mimes := strings.Fields(payload)
|
||||
dnd.drop_mimes = mimes
|
||||
// Request data for text/plain first, then text/uri-list
|
||||
if slices.Contains(mimes, "text/plain") {
|
||||
dnd.collecting = "text/plain"
|
||||
lp.QueueWriteString(dnd_request_data("text/plain"))
|
||||
return nil
|
||||
}
|
||||
if slices.Contains(mimes, "text/uri-list") {
|
||||
dnd.collecting = "text/uri-list"
|
||||
lp.QueueWriteString(dnd_request_data("text/uri-list"))
|
||||
return nil
|
||||
for _, x := range []string{"text/plain", "text/uri-list"} {
|
||||
if slices.Contains(mimes, x) {
|
||||
dnd.collecting = x
|
||||
lp.QueueWriteString(dnd_request_data(x))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// Nothing to collect, signal done
|
||||
lp.QueueWriteString(dnd_finish())
|
||||
|
|
|
|||
Loading…
Reference in a new issue