Lines Matching refs:wm
48 struct weston_wm *wm = data; in writable_callback() local
52 property = xcb_get_property_value(wm->property_reply); in writable_callback()
53 remainder = xcb_get_property_value_length(wm->property_reply) - in writable_callback()
54 wm->property_start; in writable_callback()
56 len = write(fd, property + wm->property_start, remainder); in writable_callback()
58 free(wm->property_reply); in writable_callback()
59 wm->property_reply = NULL; in writable_callback()
60 if (wm->property_source) in writable_callback()
61 wl_event_source_remove(wm->property_source); in writable_callback()
62 wm->property_source = NULL; in writable_callback()
69 wm->property_start + len, in writable_callback()
70 len, xcb_get_property_value_length(wm->property_reply)); in writable_callback()
72 wm->property_start += len; in writable_callback()
74 free(wm->property_reply); in writable_callback()
75 wm->property_reply = NULL; in writable_callback()
76 if (wm->property_source) in writable_callback()
77 wl_event_source_remove(wm->property_source); in writable_callback()
78 wm->property_source = NULL; in writable_callback()
80 if (wm->incr) { in writable_callback()
81 xcb_delete_property(wm->conn, in writable_callback()
82 wm->selection_window, in writable_callback()
83 wm->atom.wl_selection); in writable_callback()
94 weston_wm_write_property(struct weston_wm *wm, xcb_get_property_reply_t *reply) in weston_wm_write_property() argument
96 wm->property_start = 0; in weston_wm_write_property()
97 wm->property_reply = reply; in weston_wm_write_property()
98 writable_callback(wm->data_source_fd, WL_EVENT_WRITABLE, wm); in weston_wm_write_property()
100 if (wm->property_reply) in weston_wm_write_property()
101 wm->property_source = in weston_wm_write_property()
102 wl_event_loop_add_fd(wm->server->loop, in weston_wm_write_property()
103 wm->data_source_fd, in weston_wm_write_property()
105 writable_callback, wm); in weston_wm_write_property()
109 weston_wm_get_incr_chunk(struct weston_wm *wm) in weston_wm_get_incr_chunk() argument
117 cookie = xcb_get_property(wm->conn, in weston_wm_get_incr_chunk()
119 wm->selection_window, in weston_wm_get_incr_chunk()
120 wm->atom.wl_selection, in weston_wm_get_incr_chunk()
125 reply = xcb_get_property_reply(wm->conn, cookie, NULL); in weston_wm_get_incr_chunk()
131 dump_property(fp, wm, wm->atom.wl_selection, reply); in weston_wm_get_incr_chunk()
140 weston_wm_write_property(wm, reply); in weston_wm_get_incr_chunk()
143 close(wm->data_source_fd); in weston_wm_get_incr_chunk()
150 struct weston_wm *wm; member
164 struct weston_wm *wm = source->wm; in data_source_send() local
168 xcb_convert_selection(wm->conn, in data_source_send()
169 wm->selection_window, in data_source_send()
170 wm->atom.clipboard, in data_source_send()
171 wm->atom.utf8_string, in data_source_send()
172 wm->atom.wl_selection, in data_source_send()
175 xcb_flush(wm->conn); in data_source_send()
178 wm->data_source_fd = fd; in data_source_send()
188 weston_wm_get_selection_targets(struct weston_wm *wm) in weston_wm_get_selection_targets() argument
192 struct weston_seat *seat = weston_wm_pick_seat(wm); in weston_wm_get_selection_targets()
202 cookie = xcb_get_property(wm->conn, in weston_wm_get_selection_targets()
204 wm->selection_window, in weston_wm_get_selection_targets()
205 wm->atom.wl_selection, in weston_wm_get_selection_targets()
210 reply = xcb_get_property_reply(wm->conn, cookie, NULL); in weston_wm_get_selection_targets()
216 dump_property(fp, wm, wm->atom.wl_selection, reply); in weston_wm_get_selection_targets()
237 source->wm = wm; in weston_wm_get_selection_targets()
242 if (value[i] == wm->atom.utf8_string) { in weston_wm_get_selection_targets()
249 compositor = wm->server->compositor; in weston_wm_get_selection_targets()
257 weston_wm_get_selection_data(struct weston_wm *wm) in weston_wm_get_selection_data() argument
265 cookie = xcb_get_property(wm->conn, in weston_wm_get_selection_data()
267 wm->selection_window, in weston_wm_get_selection_data()
268 wm->atom.wl_selection, in weston_wm_get_selection_data()
273 reply = xcb_get_property_reply(wm->conn, cookie, NULL); in weston_wm_get_selection_data()
277 dump_property(fp, wm, wm->atom.wl_selection, reply); in weston_wm_get_selection_data()
285 } else if (reply->type == wm->atom.incr) { in weston_wm_get_selection_data()
286 wm->incr = 1; in weston_wm_get_selection_data()
289 wm->incr = 0; in weston_wm_get_selection_data()
292 weston_wm_write_property(wm, reply); in weston_wm_get_selection_data()
297 weston_wm_handle_selection_notify(struct weston_wm *wm, in weston_wm_handle_selection_notify() argument
305 } else if (selection_notify->target == wm->atom.targets) { in weston_wm_handle_selection_notify()
306 weston_wm_get_selection_targets(wm); in weston_wm_handle_selection_notify()
308 weston_wm_get_selection_data(wm); in weston_wm_handle_selection_notify()
315 weston_wm_send_selection_notify(struct weston_wm *wm, xcb_atom_t property) in weston_wm_send_selection_notify() argument
322 selection_notify.time = wm->selection_request.time; in weston_wm_send_selection_notify()
323 selection_notify.requestor = wm->selection_request.requestor; in weston_wm_send_selection_notify()
324 selection_notify.selection = wm->selection_request.selection; in weston_wm_send_selection_notify()
325 selection_notify.target = wm->selection_request.target; in weston_wm_send_selection_notify()
328 xcb_send_event(wm->conn, 0, /* propagate */ in weston_wm_send_selection_notify()
329 wm->selection_request.requestor, in weston_wm_send_selection_notify()
334 weston_wm_send_targets(struct weston_wm *wm) in weston_wm_send_targets() argument
337 wm->atom.timestamp, in weston_wm_send_targets()
338 wm->atom.targets, in weston_wm_send_targets()
339 wm->atom.utf8_string, in weston_wm_send_targets()
341 wm->atom.text, in weston_wm_send_targets()
345 xcb_change_property(wm->conn, in weston_wm_send_targets()
347 wm->selection_request.requestor, in weston_wm_send_targets()
348 wm->selection_request.property, in weston_wm_send_targets()
353 weston_wm_send_selection_notify(wm, wm->selection_request.property); in weston_wm_send_targets()
357 weston_wm_send_timestamp(struct weston_wm *wm) in weston_wm_send_timestamp() argument
359 xcb_change_property(wm->conn, in weston_wm_send_timestamp()
361 wm->selection_request.requestor, in weston_wm_send_timestamp()
362 wm->selection_request.property, in weston_wm_send_timestamp()
365 1, &wm->selection_timestamp); in weston_wm_send_timestamp()
367 weston_wm_send_selection_notify(wm, wm->selection_request.property); in weston_wm_send_timestamp()
371 weston_wm_flush_source_data(struct weston_wm *wm) in weston_wm_flush_source_data() argument
375 xcb_change_property(wm->conn, in weston_wm_flush_source_data()
377 wm->selection_request.requestor, in weston_wm_flush_source_data()
378 wm->selection_request.property, in weston_wm_flush_source_data()
379 wm->selection_target, in weston_wm_flush_source_data()
381 wm->source_data.size, in weston_wm_flush_source_data()
382 wm->source_data.data); in weston_wm_flush_source_data()
383 wm->selection_property_set = 1; in weston_wm_flush_source_data()
384 length = wm->source_data.size; in weston_wm_flush_source_data()
385 wm->source_data.size = 0; in weston_wm_flush_source_data()
393 struct weston_wm *wm = data; in weston_wm_read_data_source() local
397 current = wm->source_data.size; in weston_wm_read_data_source()
398 if (wm->source_data.size < incr_chunk_size) in weston_wm_read_data_source()
399 p = wl_array_add(&wm->source_data, incr_chunk_size); in weston_wm_read_data_source()
401 p = (char *) wm->source_data.data + wm->source_data.size; in weston_wm_read_data_source()
402 available = wm->source_data.alloc - current; in weston_wm_read_data_source()
408 weston_wm_send_selection_notify(wm, XCB_ATOM_NONE); in weston_wm_read_data_source()
409 if (wm->property_source) in weston_wm_read_data_source()
410 wl_event_source_remove(wm->property_source); in weston_wm_read_data_source()
411 wm->property_source = NULL; in weston_wm_read_data_source()
413 wl_array_release(&wm->source_data); in weston_wm_read_data_source()
420 wm->source_data.size = current + len; in weston_wm_read_data_source()
421 if (wm->source_data.size >= incr_chunk_size) { in weston_wm_read_data_source()
422 if (!wm->incr) { in weston_wm_read_data_source()
424 wm->source_data.size); in weston_wm_read_data_source()
425 wm->incr = 1; in weston_wm_read_data_source()
426 xcb_change_property(wm->conn, in weston_wm_read_data_source()
428 wm->selection_request.requestor, in weston_wm_read_data_source()
429 wm->selection_request.property, in weston_wm_read_data_source()
430 wm->atom.incr, in weston_wm_read_data_source()
433 wm->selection_property_set = 1; in weston_wm_read_data_source()
434 wm->flush_property_on_delete = 1; in weston_wm_read_data_source()
435 if (wm->property_source) in weston_wm_read_data_source()
436 wl_event_source_remove(wm->property_source); in weston_wm_read_data_source()
437 wm->property_source = NULL; in weston_wm_read_data_source()
438 weston_wm_send_selection_notify(wm, wm->selection_request.property); in weston_wm_read_data_source()
439 } else if (wm->selection_property_set) { in weston_wm_read_data_source()
441 "property delete\n", wm->source_data.size); in weston_wm_read_data_source()
443 wm->flush_property_on_delete = 1; in weston_wm_read_data_source()
444 if (wm->property_source) in weston_wm_read_data_source()
445 wl_event_source_remove(wm->property_source); in weston_wm_read_data_source()
446 wm->property_source = NULL; in weston_wm_read_data_source()
450 wm->source_data.size); in weston_wm_read_data_source()
451 weston_wm_flush_source_data(wm); in weston_wm_read_data_source()
453 } else if (len == 0 && !wm->incr) { in weston_wm_read_data_source()
456 weston_wm_flush_source_data(wm); in weston_wm_read_data_source()
457 weston_wm_send_selection_notify(wm, wm->selection_request.property); in weston_wm_read_data_source()
458 xcb_flush(wm->conn); in weston_wm_read_data_source()
459 if (wm->property_source) in weston_wm_read_data_source()
460 wl_event_source_remove(wm->property_source); in weston_wm_read_data_source()
461 wm->property_source = NULL; in weston_wm_read_data_source()
463 wl_array_release(&wm->source_data); in weston_wm_read_data_source()
464 wm->selection_request.requestor = XCB_NONE; in weston_wm_read_data_source()
465 } else if (len == 0 && wm->incr) { in weston_wm_read_data_source()
468 wm->flush_property_on_delete = 1; in weston_wm_read_data_source()
469 if (wm->selection_property_set) { in weston_wm_read_data_source()
471 "property delete\n", wm->source_data.size); in weston_wm_read_data_source()
475 wm->source_data.size); in weston_wm_read_data_source()
476 weston_wm_flush_source_data(wm); in weston_wm_read_data_source()
478 xcb_flush(wm->conn); in weston_wm_read_data_source()
479 if (wm->property_source) in weston_wm_read_data_source()
480 wl_event_source_remove(wm->property_source); in weston_wm_read_data_source()
481 wm->property_source = NULL; in weston_wm_read_data_source()
482 close(wm->data_source_fd); in weston_wm_read_data_source()
483 wm->data_source_fd = -1; in weston_wm_read_data_source()
493 weston_wm_send_data(struct weston_wm *wm, xcb_atom_t target, const char *mime_type) in weston_wm_send_data() argument
496 struct weston_seat *seat = weston_wm_pick_seat(wm); in weston_wm_send_data()
501 weston_wm_send_selection_notify(wm, XCB_ATOM_NONE); in weston_wm_send_data()
505 wl_array_init(&wm->source_data); in weston_wm_send_data()
506 wm->selection_target = target; in weston_wm_send_data()
507 wm->data_source_fd = p[0]; in weston_wm_send_data()
508 wm->property_source = wl_event_loop_add_fd(wm->server->loop, in weston_wm_send_data()
509 wm->data_source_fd, in weston_wm_send_data()
512 wm); in weston_wm_send_data()
520 weston_wm_send_incr_chunk(struct weston_wm *wm) in weston_wm_send_incr_chunk() argument
526 wm->selection_property_set = 0; in weston_wm_send_incr_chunk()
527 if (wm->flush_property_on_delete) { in weston_wm_send_incr_chunk()
529 wm->source_data.size); in weston_wm_send_incr_chunk()
530 wm->flush_property_on_delete = 0; in weston_wm_send_incr_chunk()
531 length = weston_wm_flush_source_data(wm); in weston_wm_send_incr_chunk()
533 if (wm->data_source_fd >= 0) { in weston_wm_send_incr_chunk()
534 wm->property_source = in weston_wm_send_incr_chunk()
535 wl_event_loop_add_fd(wm->server->loop, in weston_wm_send_incr_chunk()
536 wm->data_source_fd, in weston_wm_send_incr_chunk()
539 wm); in weston_wm_send_incr_chunk()
545 wm->flush_property_on_delete = 1; in weston_wm_send_incr_chunk()
546 wl_array_release(&wm->source_data); in weston_wm_send_incr_chunk()
548 wm->selection_request.requestor = XCB_NONE; in weston_wm_send_incr_chunk()
554 weston_wm_handle_selection_property_notify(struct weston_wm *wm, in weston_wm_handle_selection_property_notify() argument
560 if (property_notify->window == wm->selection_window) { in weston_wm_handle_selection_property_notify()
562 property_notify->atom == wm->atom.wl_selection && in weston_wm_handle_selection_property_notify()
563 wm->incr) in weston_wm_handle_selection_property_notify()
564 weston_wm_get_incr_chunk(wm); in weston_wm_handle_selection_property_notify()
566 } else if (property_notify->window == wm->selection_request.requestor) { in weston_wm_handle_selection_property_notify()
568 property_notify->atom == wm->selection_request.property && in weston_wm_handle_selection_property_notify()
569 wm->incr) in weston_wm_handle_selection_property_notify()
570 weston_wm_send_incr_chunk(wm); in weston_wm_handle_selection_property_notify()
578 weston_wm_handle_selection_request(struct weston_wm *wm, in weston_wm_handle_selection_request() argument
585 get_atom_name(wm->conn, selection_request->selection)); in weston_wm_handle_selection_request()
587 get_atom_name(wm->conn, selection_request->target)); in weston_wm_handle_selection_request()
589 get_atom_name(wm->conn, selection_request->property)); in weston_wm_handle_selection_request()
591 wm->selection_request = *selection_request; in weston_wm_handle_selection_request()
592 wm->incr = 0; in weston_wm_handle_selection_request()
593 wm->flush_property_on_delete = 0; in weston_wm_handle_selection_request()
595 if (selection_request->selection == wm->atom.clipboard_manager) { in weston_wm_handle_selection_request()
600 weston_wm_send_selection_notify(wm, wm->selection_request.property); in weston_wm_handle_selection_request()
604 if (selection_request->target == wm->atom.targets) { in weston_wm_handle_selection_request()
605 weston_wm_send_targets(wm); in weston_wm_handle_selection_request()
606 } else if (selection_request->target == wm->atom.timestamp) { in weston_wm_handle_selection_request()
607 weston_wm_send_timestamp(wm); in weston_wm_handle_selection_request()
608 } else if (selection_request->target == wm->atom.utf8_string || in weston_wm_handle_selection_request()
609 selection_request->target == wm->atom.text) { in weston_wm_handle_selection_request()
610 weston_wm_send_data(wm, wm->atom.utf8_string, in weston_wm_handle_selection_request()
614 weston_wm_send_selection_notify(wm, XCB_ATOM_NONE); in weston_wm_handle_selection_request()
619 weston_wm_handle_xfixes_selection_notify(struct weston_wm *wm, in weston_wm_handle_xfixes_selection_notify() argument
625 struct weston_seat *seat = weston_wm_pick_seat(wm); in weston_wm_handle_xfixes_selection_notify()
628 if (xfixes_selection_notify->selection != wm->atom.clipboard) in weston_wm_handle_xfixes_selection_notify()
635 if (wm->selection_owner != wm->selection_window) { in weston_wm_handle_xfixes_selection_notify()
638 compositor = wm->server->compositor; in weston_wm_handle_xfixes_selection_notify()
643 wm->selection_owner = XCB_WINDOW_NONE; in weston_wm_handle_xfixes_selection_notify()
648 wm->selection_owner = xfixes_selection_notify->owner; in weston_wm_handle_xfixes_selection_notify()
653 if (xfixes_selection_notify->owner == wm->selection_window) { in weston_wm_handle_xfixes_selection_notify()
654 wm->selection_timestamp = xfixes_selection_notify->timestamp; in weston_wm_handle_xfixes_selection_notify()
659 wm->incr = 0; in weston_wm_handle_xfixes_selection_notify()
660 xcb_convert_selection(wm->conn, wm->selection_window, in weston_wm_handle_xfixes_selection_notify()
661 wm->atom.clipboard, in weston_wm_handle_xfixes_selection_notify()
662 wm->atom.targets, in weston_wm_handle_xfixes_selection_notify()
663 wm->atom.wl_selection, in weston_wm_handle_xfixes_selection_notify()
666 xcb_flush(wm->conn); in weston_wm_handle_xfixes_selection_notify()
672 weston_wm_handle_selection_event(struct weston_wm *wm, in weston_wm_handle_selection_event() argument
677 weston_wm_handle_selection_notify(wm, event); in weston_wm_handle_selection_event()
680 return weston_wm_handle_selection_property_notify(wm, event); in weston_wm_handle_selection_event()
682 weston_wm_handle_selection_request(wm, event); in weston_wm_handle_selection_event()
686 switch (event->response_type - wm->xfixes->first_event) { in weston_wm_handle_selection_event()
688 return weston_wm_handle_xfixes_selection_notify(wm, event); in weston_wm_handle_selection_event()
698 struct weston_wm *wm = in weston_wm_set_selection() local
703 if (wm->selection_owner == wm->selection_window) in weston_wm_set_selection()
704 xcb_set_selection_owner(wm->conn, in weston_wm_set_selection()
706 wm->atom.clipboard, in weston_wm_set_selection()
707 wm->selection_timestamp); in weston_wm_set_selection()
714 xcb_set_selection_owner(wm->conn, in weston_wm_set_selection()
715 wm->selection_window, in weston_wm_set_selection()
716 wm->atom.clipboard, in weston_wm_set_selection()
721 weston_wm_selection_init(struct weston_wm *wm) in weston_wm_selection_init() argument
726 wl_list_init(&wm->selection_listener.link); in weston_wm_selection_init()
728 wm->selection_request.requestor = XCB_NONE; in weston_wm_selection_init()
731 wm->selection_window = xcb_generate_id(wm->conn); in weston_wm_selection_init()
732 xcb_create_window(wm->conn, in weston_wm_selection_init()
734 wm->selection_window, in weston_wm_selection_init()
735 wm->screen->root, in weston_wm_selection_init()
740 wm->screen->root_visual, in weston_wm_selection_init()
743 xcb_set_selection_owner(wm->conn, in weston_wm_selection_init()
744 wm->selection_window, in weston_wm_selection_init()
745 wm->atom.clipboard_manager, in weston_wm_selection_init()
752 xcb_xfixes_select_selection_input(wm->conn, wm->selection_window, in weston_wm_selection_init()
753 wm->atom.clipboard, mask); in weston_wm_selection_init()
755 seat = weston_wm_pick_seat(wm); in weston_wm_selection_init()
758 wm->selection_listener.notify = weston_wm_set_selection; in weston_wm_selection_init()
759 wl_signal_add(&seat->selection_signal, &wm->selection_listener); in weston_wm_selection_init()
761 weston_wm_set_selection(&wm->selection_listener, seat); in weston_wm_selection_init()