mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-25 22:25:58 +01:00
xwayland/selection: make xwm_selection_init take a wlr_xwm_selection *
This makes it consistent with xwm_selection_finish.
This commit is contained in:
parent
b3d782f818
commit
dd4c8aa45e
3 changed files with 55 additions and 57 deletions
|
@ -77,7 +77,8 @@ bool primary_selection_source_is_xwayland(
|
||||||
|
|
||||||
void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag);
|
void xwm_seat_handle_start_drag(struct wlr_xwm *xwm, struct wlr_drag *drag);
|
||||||
|
|
||||||
void xwm_selection_init(struct wlr_xwm *xwm);
|
void xwm_selection_init(struct wlr_xwm_selection *selection,
|
||||||
|
struct wlr_xwm *xwm, xcb_atom_t atom);
|
||||||
void xwm_selection_finish(struct wlr_xwm_selection *selection);
|
void xwm_selection_finish(struct wlr_xwm_selection *selection);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -179,8 +179,8 @@ int xwm_handle_selection_event(struct wlr_xwm *xwm,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void selection_init(struct wlr_xwm *xwm,
|
void xwm_selection_init(struct wlr_xwm_selection *selection,
|
||||||
struct wlr_xwm_selection *selection, xcb_atom_t atom) {
|
struct wlr_xwm *xwm, xcb_atom_t atom) {
|
||||||
selection->xwm = xwm;
|
selection->xwm = xwm;
|
||||||
selection->atom = atom;
|
selection->atom = atom;
|
||||||
selection->window = xwm->selection_window;
|
selection->window = xwm->selection_window;
|
||||||
|
@ -196,59 +196,6 @@ static void selection_init(struct wlr_xwm *xwm,
|
||||||
selection->atom, mask);
|
selection->atom, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xwm_selection_init(struct wlr_xwm *xwm) {
|
|
||||||
// Clipboard and primary selection
|
|
||||||
uint32_t selection_values[] = {
|
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE
|
|
||||||
};
|
|
||||||
xwm->selection_window = xcb_generate_id(xwm->xcb_conn);
|
|
||||||
xcb_create_window(xwm->xcb_conn,
|
|
||||||
XCB_COPY_FROM_PARENT,
|
|
||||||
xwm->selection_window,
|
|
||||||
xwm->screen->root,
|
|
||||||
0, 0,
|
|
||||||
10, 10,
|
|
||||||
0,
|
|
||||||
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
|
||||||
xwm->screen->root_visual,
|
|
||||||
XCB_CW_EVENT_MASK, selection_values);
|
|
||||||
|
|
||||||
xcb_set_selection_owner(xwm->xcb_conn,
|
|
||||||
xwm->selection_window,
|
|
||||||
xwm->atoms[CLIPBOARD_MANAGER],
|
|
||||||
XCB_TIME_CURRENT_TIME);
|
|
||||||
|
|
||||||
selection_init(xwm, &xwm->clipboard_selection, xwm->atoms[CLIPBOARD]);
|
|
||||||
selection_init(xwm, &xwm->primary_selection, xwm->atoms[PRIMARY]);
|
|
||||||
|
|
||||||
// Drag'n'drop
|
|
||||||
uint32_t dnd_values[] = {
|
|
||||||
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE
|
|
||||||
};
|
|
||||||
xwm->dnd_window = xcb_generate_id(xwm->xcb_conn);
|
|
||||||
xcb_create_window(xwm->xcb_conn,
|
|
||||||
XCB_COPY_FROM_PARENT,
|
|
||||||
xwm->dnd_window,
|
|
||||||
xwm->screen->root,
|
|
||||||
0, 0,
|
|
||||||
8192, 8192,
|
|
||||||
0,
|
|
||||||
XCB_WINDOW_CLASS_INPUT_ONLY,
|
|
||||||
xwm->screen->root_visual,
|
|
||||||
XCB_CW_EVENT_MASK, dnd_values);
|
|
||||||
|
|
||||||
uint32_t version = XDND_VERSION;
|
|
||||||
xcb_change_property(xwm->xcb_conn,
|
|
||||||
XCB_PROP_MODE_REPLACE,
|
|
||||||
xwm->dnd_window,
|
|
||||||
xwm->atoms[DND_AWARE],
|
|
||||||
XCB_ATOM_ATOM,
|
|
||||||
32, // format
|
|
||||||
1, &version);
|
|
||||||
|
|
||||||
selection_init(xwm, &xwm->dnd_selection, xwm->atoms[DND_SELECTION]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void xwm_selection_finish(struct wlr_xwm_selection *selection) {
|
void xwm_selection_finish(struct wlr_xwm_selection *selection) {
|
||||||
if (!selection) {
|
if (!selection) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1927,7 +1927,57 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) {
|
||||||
|
|
||||||
xwm_set_net_active_window(xwm, XCB_WINDOW_NONE);
|
xwm_set_net_active_window(xwm, XCB_WINDOW_NONE);
|
||||||
|
|
||||||
xwm_selection_init(xwm);
|
// Clipboard and primary selection
|
||||||
|
xwm->selection_window = xcb_generate_id(xwm->xcb_conn);
|
||||||
|
xcb_create_window(
|
||||||
|
xwm->xcb_conn,
|
||||||
|
XCB_COPY_FROM_PARENT,
|
||||||
|
xwm->selection_window,
|
||||||
|
xwm->screen->root,
|
||||||
|
0, 0,
|
||||||
|
10, 10,
|
||||||
|
0,
|
||||||
|
XCB_WINDOW_CLASS_INPUT_OUTPUT,
|
||||||
|
xwm->screen->root_visual,
|
||||||
|
XCB_CW_EVENT_MASK, (uint32_t[]){
|
||||||
|
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
xcb_set_selection_owner(xwm->xcb_conn, xwm->selection_window,
|
||||||
|
xwm->atoms[CLIPBOARD_MANAGER], XCB_TIME_CURRENT_TIME);
|
||||||
|
|
||||||
|
xwm_selection_init(&xwm->clipboard_selection, xwm, xwm->atoms[CLIPBOARD]);
|
||||||
|
xwm_selection_init(&xwm->primary_selection, xwm, xwm->atoms[PRIMARY]);
|
||||||
|
|
||||||
|
// Drag'n'drop
|
||||||
|
xwm->dnd_window = xcb_generate_id(xwm->xcb_conn);
|
||||||
|
xcb_create_window(
|
||||||
|
xwm->xcb_conn,
|
||||||
|
XCB_COPY_FROM_PARENT,
|
||||||
|
xwm->dnd_window,
|
||||||
|
xwm->screen->root,
|
||||||
|
0, 0,
|
||||||
|
8192, 8192,
|
||||||
|
0,
|
||||||
|
XCB_WINDOW_CLASS_INPUT_ONLY,
|
||||||
|
xwm->screen->root_visual,
|
||||||
|
XCB_CW_EVENT_MASK, (uint32_t[]){
|
||||||
|
XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
xcb_change_property(
|
||||||
|
xwm->xcb_conn,
|
||||||
|
XCB_PROP_MODE_REPLACE,
|
||||||
|
xwm->dnd_window,
|
||||||
|
xwm->atoms[DND_AWARE],
|
||||||
|
XCB_ATOM_ATOM,
|
||||||
|
32, // format
|
||||||
|
1, &(uint32_t){XDND_VERSION}
|
||||||
|
);
|
||||||
|
|
||||||
|
xwm_selection_init(&xwm->dnd_selection, xwm, xwm->atoms[DND_SELECTION]);
|
||||||
|
|
||||||
xwm->compositor_new_surface.notify = handle_compositor_new_surface;
|
xwm->compositor_new_surface.notify = handle_compositor_new_surface;
|
||||||
wl_signal_add(&xwayland->compositor->events.new_surface,
|
wl_signal_add(&xwayland->compositor->events.new_surface,
|
||||||
|
|
Loading…
Reference in a new issue