mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-09 15:19:11 +02:00
Fix segmentation fault due to drag icons
This commit is contained in:
parent
2457a37da8
commit
33877210d9
3 changed files with 13 additions and 40 deletions
|
|
@ -1007,7 +1007,7 @@ keybinding_dump(struct cg_server *server) {
|
|||
struct dyn_str str;
|
||||
str.len=0;
|
||||
str.cur_pos=0;
|
||||
uint32_t nmemb=11;
|
||||
uint32_t nmemb=10;
|
||||
str.str_arr=calloc(nmemb,sizeof(char *));
|
||||
|
||||
print_str(&str,"{");
|
||||
|
|
@ -1021,8 +1021,6 @@ keybinding_dump(struct cg_server *server) {
|
|||
print_str(&str,"%s",outps_str);
|
||||
free(outps_str);
|
||||
print_str(&str,"\"cursor_coords\":{\"x\":%f,\"y\":%f},\n",server->seat->cursor->x,server->seat->cursor->y);
|
||||
struct cg_view *focused_view=seat_desktop_view_at(server,server->seat->cursor->x,server->seat->cursor->y,NULL,NULL,NULL);
|
||||
print_str(&str,"\"cursor_focused_view\":%d,\n",focused_view==NULL?-1:(int) focused_view->id);
|
||||
print_str(&str,"}");
|
||||
|
||||
char *send_str=dyn_str_to_str(&str);
|
||||
|
|
|
|||
46
seat.c
46
seat.c
|
|
@ -47,25 +47,6 @@
|
|||
static void
|
||||
drag_icon_update_position(struct cg_drag_icon *drag_icon);
|
||||
|
||||
/* If seat_desktop_view_at returns a view, there is also a
|
||||
* surface. There cannot be a surface without a view, either. It's
|
||||
* both or nothing. */
|
||||
struct cg_view *
|
||||
seat_desktop_view_at(const struct cg_server *server, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy) {
|
||||
struct wlr_scene_node *node=wlr_scene_node_at(&server->scene->node, lx,ly,sx,sy);
|
||||
if(node == NULL || node->type != WLR_SCENE_NODE_SURFACE) {
|
||||
return NULL;
|
||||
}
|
||||
if(surface!=NULL) {
|
||||
*surface = wlr_scene_surface_from_node(node)->surface;
|
||||
}
|
||||
while(node != NULL && node->data == NULL) {
|
||||
node=node->parent;
|
||||
}
|
||||
return node->data;
|
||||
}
|
||||
|
||||
static void
|
||||
update_capabilities(const struct cg_seat *seat) {
|
||||
uint32_t caps = 0;
|
||||
|
|
@ -529,14 +510,12 @@ handle_touch_down(struct wl_listener *listener, void *data) {
|
|||
event->y, &lx, &ly);
|
||||
|
||||
double sx, sy;
|
||||
struct wlr_surface *surface;
|
||||
struct cg_view *view =
|
||||
seat_desktop_view_at(seat->server, lx, ly, &surface, &sx, &sy);
|
||||
struct wlr_scene_node *node=wlr_scene_node_at(&seat->server->scene->node, lx,ly,&sx,&sy);
|
||||
|
||||
uint32_t serial = 0;
|
||||
if(view) {
|
||||
if(node&&node->type == WLR_SCENE_NODE_SURFACE) {
|
||||
serial = wlr_seat_touch_notify_down(
|
||||
seat->seat, surface, event->time_msec, event->touch_id, sx, sy);
|
||||
seat->seat, wlr_scene_surface_from_node(node)->surface, event->time_msec, event->touch_id, sx, sy);
|
||||
}
|
||||
|
||||
if(serial && wlr_seat_touch_num_points(seat->seat) == 1) {
|
||||
|
|
@ -575,12 +554,10 @@ handle_touch_motion(struct wl_listener *listener, void *data) {
|
|||
event->y, &lx, &ly);
|
||||
|
||||
double sx, sy;
|
||||
struct wlr_surface *surface;
|
||||
struct cg_view *view =
|
||||
seat_desktop_view_at(seat->server, lx, ly, &surface, &sx, &sy);
|
||||
struct wlr_scene_node *node=wlr_scene_node_at(&seat->server->scene->node, lx,ly,&sx,&sy);
|
||||
|
||||
if(view) {
|
||||
wlr_seat_touch_point_focus(seat->seat, surface, event->time_msec,
|
||||
if(node&&node->type == WLR_SCENE_NODE_SURFACE) {
|
||||
wlr_seat_touch_point_focus(seat->seat, wlr_scene_surface_from_node(node)->surface, event->time_msec,
|
||||
event->touch_id, sx, sy);
|
||||
wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
|
||||
event->touch_id, sx, sy);
|
||||
|
|
@ -632,18 +609,19 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time) {
|
|||
struct wlr_seat *wlr_seat = seat->seat;
|
||||
struct wlr_surface *surface = NULL;
|
||||
|
||||
struct cg_view *view = seat_desktop_view_at(seat->server, seat->cursor->x,
|
||||
seat->cursor->y, &surface, &sx, &sy);
|
||||
struct wlr_scene_node *node=wlr_scene_node_at(&seat->server->scene->node, seat->cursor->x,seat->cursor->y,&sx,&sy);
|
||||
|
||||
if(!view) {
|
||||
wlr_seat_pointer_clear_focus(wlr_seat);
|
||||
} else {
|
||||
|
||||
if(node&&node->type == WLR_SCENE_NODE_SURFACE) {
|
||||
surface=wlr_scene_surface_from_node(node)->surface;
|
||||
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
|
||||
|
||||
bool focus_changed = wlr_seat->pointer_state.focused_surface != surface;
|
||||
if(!focus_changed && time > 0) {
|
||||
wlr_seat_pointer_notify_motion(wlr_seat, time, sx, sy);
|
||||
}
|
||||
} else {
|
||||
wlr_seat_pointer_clear_focus(wlr_seat);
|
||||
}
|
||||
|
||||
struct cg_drag_icon *drag_icon;
|
||||
|
|
|
|||
3
seat.h
3
seat.h
|
|
@ -94,9 +94,6 @@ struct cg_drag_icon {
|
|||
struct wl_listener destroy;
|
||||
};
|
||||
|
||||
struct cg_view *
|
||||
seat_desktop_view_at(const struct cg_server *server, double lx, double ly,
|
||||
struct wlr_surface **surface, double *sx, double *sy);
|
||||
struct cg_seat *
|
||||
seat_create(struct cg_server *server, struct wlr_backend *backend);
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue