mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-08-28 12:21:55 +00:00
Drop events should use same co-ordinate system as mouse events
This commit is contained in:
parent
c4c31c3bc1
commit
a99103d9a1
4 changed files with 7 additions and 16 deletions
|
|
@ -1611,9 +1611,6 @@ update_drop_state(_GLFWwindow *window, size_t mime_count) {
|
|||
const NSPoint pos = [sender draggingLocation];
|
||||
double xpos = pos.x;
|
||||
double ypos = contentRect.size.height - pos.y;
|
||||
float xscale = 1, yscale = 1;
|
||||
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
||||
xpos *= xscale; ypos *= yscale;
|
||||
free_drop_data(window);
|
||||
|
||||
// Get MIME types from the dragging pasteboard
|
||||
|
|
@ -1685,9 +1682,6 @@ update_drop_state(_GLFWwindow *window, size_t mime_count) {
|
|||
const NSPoint pos = [sender draggingLocation];
|
||||
double xpos = pos.x;
|
||||
double ypos = contentRect.size.height - pos.y;
|
||||
float xscale = 1, yscale = 1;
|
||||
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
||||
xpos *= xscale; ypos *= yscale;
|
||||
|
||||
bool from_self = ([sender draggingSource] != nil);
|
||||
_GLFWDropData *d = &window->ns.drop_data;
|
||||
|
|
@ -1712,9 +1706,6 @@ update_drop_state(_GLFWwindow *window, size_t mime_count) {
|
|||
const NSPoint pos = [sender draggingLocation];
|
||||
double xpos = pos.x;
|
||||
double ypos = contentRect.size.height - pos.y;
|
||||
float xscale = 1, yscale = 1;
|
||||
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
||||
xpos *= xscale; ypos *= yscale;
|
||||
bool from_self = ([sender draggingSource] != nil);
|
||||
_GLFWDropData *d = &window->ns.drop_data;
|
||||
size_t mime_count = _glfwInputDropEvent(window, GLFW_DROP_DROP, xpos, ypos, d->mimes, d->mimes_count, from_self);
|
||||
|
|
|
|||
4
glfw/glfw3.h
vendored
4
glfw/glfw3.h
vendored
|
|
@ -1403,7 +1403,9 @@ typedef enum {
|
|||
typedef struct GLFWDropEvent {
|
||||
GLFWDropEventType type;
|
||||
const char **mimes; size_t num_mimes;
|
||||
double xpos, ypos; // Only valid for GLFW_DROP_ENTER and GLFW_DROP_MOVE
|
||||
// Positions are only valid for GLFW_DROP_ENTER and GLFW_DROP_MOVE.
|
||||
// They are in window co-ordinates same as for mouse events
|
||||
double xpos, ypos;
|
||||
bool from_self; // Only valid upto GLFW_DROP_DROP
|
||||
ssize_t (*read_data)(GLFWwindow *w, struct GLFWDropEvent* ev, char *buffer, size_t sz); // Only valid for GLFW_DROP_DATA_AVAILABLE
|
||||
void (*finish_drop)(GLFWwindow *w, GLFWDragOperationType op); // Only valid for GLFW_DROP_DROP and GLFW_DROP_DATA_AVAILABLE
|
||||
|
|
|
|||
6
glfw/wl_window.c
vendored
6
glfw/wl_window.c
vendored
|
|
@ -2493,9 +2493,8 @@ drag_enter(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED, uint
|
|||
if (window->wl.surface == surface) {
|
||||
double xpos = wl_fixed_to_double(x);
|
||||
double ypos = wl_fixed_to_double(y);
|
||||
double scale = _glfwWaylandWindowScale(window);
|
||||
size_t mime_count = _glfwInputDropEvent(
|
||||
window, GLFW_DROP_ENTER, scale * xpos, scale * ypos,
|
||||
window, GLFW_DROP_ENTER, xpos, ypos,
|
||||
offer->mimes, offer->mimes_count, offer->is_self_offer);
|
||||
update_drop_state(offer, window, mime_count);
|
||||
break;
|
||||
|
|
@ -2633,9 +2632,8 @@ motion(void *data UNUSED, struct wl_data_device *wl_data_device UNUSED, uint32_t
|
|||
if (window->wl.surface == offer->surface) {
|
||||
double xpos = wl_fixed_to_double(x);
|
||||
double ypos = wl_fixed_to_double(y);
|
||||
double scale = _glfwWaylandWindowScale(window);
|
||||
size_t mime_count = _glfwInputDropEvent(
|
||||
window, GLFW_DROP_MOVE, scale * xpos, scale * ypos, offer->mimes, offer->mimes_count, offer->is_self_offer);
|
||||
window, GLFW_DROP_MOVE, xpos, ypos, offer->mimes, offer->mimes_count, offer->is_self_offer);
|
||||
update_drop_state(offer, window, mime_count);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -720,8 +720,8 @@ on_drop(GLFWwindow *window, GLFWDropEvent *ev) {
|
|||
switch (ev->type) {
|
||||
case GLFW_DROP_ENTER:
|
||||
case GLFW_DROP_MOVE:
|
||||
global_state.callback_os_window->last_drag_event.x = (int)ev->xpos;
|
||||
global_state.callback_os_window->last_drag_event.y = (int)ev->ypos;
|
||||
global_state.callback_os_window->last_drag_event.x = (int)(ev->xpos * global_state.callback_os_window->viewport_x_ratio);
|
||||
global_state.callback_os_window->last_drag_event.y = (int)(ev->ypos * global_state.callback_os_window->viewport_y_ratio);
|
||||
/* fallthrough */
|
||||
case GLFW_DROP_STATUS_UPDATE:
|
||||
update_allowed_mimes_for_drop(ev);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue