… | |
… | |
297 | ///////////////////////////////////////////////////////////////////////////// |
297 | ///////////////////////////////////////////////////////////////////////////// |
298 | |
298 | |
299 | rxvt_display::rxvt_display (const char *id) |
299 | rxvt_display::rxvt_display (const char *id) |
300 | : refcounted (id) |
300 | : refcounted (id) |
301 | , selection_owner (0) |
301 | , selection_owner (0) |
|
|
302 | , clipboard_owner (0) |
302 | { |
303 | { |
303 | x_ev .set<rxvt_display, &rxvt_display::x_cb > (this); |
304 | x_ev .set<rxvt_display, &rxvt_display::x_cb > (this); |
304 | flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this); |
305 | flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this); |
305 | } |
306 | } |
306 | |
307 | |
… | |
… | |
426 | bool rxvt_display::ref_init () |
427 | bool rxvt_display::ref_init () |
427 | { |
428 | { |
428 | #ifdef LOCAL_X_IS_UNIX |
429 | #ifdef LOCAL_X_IS_UNIX |
429 | if (id[0] == ':') |
430 | if (id[0] == ':') |
430 | { |
431 | { |
431 | val = rxvt_malloc (5 + strlen (id) + 1); |
432 | if (!(val = rxvt_temp_buf<char> (5 + strlen (id) + 1))) |
|
|
433 | return false; |
432 | strcpy (val, "unix/"); |
434 | strcpy (val, "unix/"); |
433 | strcat (val, id); |
435 | strcat (val, id); |
434 | dpy = XOpenDisplay (val); |
436 | dpy = XOpenDisplay (val); |
435 | free (val); |
|
|
436 | } |
437 | } |
437 | else |
438 | else |
438 | #endif |
439 | #endif |
439 | dpy = 0; |
440 | dpy = 0; |
440 | |
441 | |
… | |
… | |
600 | xw[w->active - 1] = 0; |
601 | xw[w->active - 1] = 0; |
601 | w->active = 0; |
602 | w->active = 0; |
602 | } |
603 | } |
603 | } |
604 | } |
604 | |
605 | |
605 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
606 | void rxvt_display::set_selection_owner (rxvt_term *owner, bool clipboard) |
606 | { |
607 | { |
|
|
608 | rxvt_term * &cur_owner = !clipboard ? selection_owner : clipboard_owner; |
|
|
609 | |
607 | if (selection_owner && selection_owner != owner) |
610 | if (cur_owner && cur_owner != owner) |
608 | { |
611 | { |
609 | rxvt_term *owner = selection_owner; |
612 | rxvt_term *term = cur_owner; |
610 | |
|
|
611 | owner->selection_clear (); |
613 | term->selection_clear (clipboard); |
612 | owner->flush (); |
614 | term->flush (); |
613 | } |
615 | } |
614 | |
616 | |
615 | selection_owner = owner; |
617 | cur_owner = owner; |
616 | } |
618 | } |
617 | |
619 | |
618 | #ifdef USE_XIM |
620 | #ifdef USE_XIM |
619 | |
621 | |
620 | void rxvt_display::reg (im_watcher *w) |
622 | void rxvt_display::reg (im_watcher *w) |
… | |
… | |
633 | int l, m; |
635 | int l, m; |
634 | |
636 | |
635 | l = strlen (locale); |
637 | l = strlen (locale); |
636 | m = strlen (modifiers); |
638 | m = strlen (modifiers); |
637 | |
639 | |
638 | if (!(id = (char *)malloc (l + m + 2))) |
640 | if (!(id = rxvt_temp_buf<char> (l + m + 2))) |
639 | return 0; |
641 | return 0; |
640 | |
642 | |
641 | memcpy (id, locale, l); id[l] = '\n'; |
643 | memcpy (id, locale, l); id[l] = '\n'; |
642 | memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; |
644 | memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; |
643 | |
645 | |
644 | rxvt_xim *xim = xims.get (id); |
646 | rxvt_xim *xim = xims.get (id); |
645 | |
|
|
646 | free (id); |
|
|
647 | |
647 | |
648 | return xim; |
648 | return xim; |
649 | } |
649 | } |
650 | |
650 | |
651 | void rxvt_display::put_xim (rxvt_xim *xim) |
651 | void rxvt_display::put_xim (rxvt_xim *xim) |
… | |
… | |
720 | c.green = color.g; |
720 | c.green = color.g; |
721 | c.blue = color.b; |
721 | c.blue = color.b; |
722 | |
722 | |
723 | if (screen->visual->c_class == TrueColor) |
723 | if (screen->visual->c_class == TrueColor) |
724 | { |
724 | { |
725 | c.pixel = (color.r >> (16 - popcount (screen->visual->red_mask )) << ctz (screen->visual->red_mask )) |
725 | c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) |
726 | | (color.g >> (16 - popcount (screen->visual->green_mask)) << ctz (screen->visual->green_mask)) |
726 | | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) |
727 | | (color.b >> (16 - popcount (screen->visual->blue_mask )) << ctz (screen->visual->blue_mask )); |
727 | | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); |
728 | |
728 | |
729 | return true; |
729 | return true; |
730 | } |
730 | } |
731 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
731 | else if (XAllocColor (screen->dpy, screen->cmap, &c)) |
732 | return true; |
732 | return true; |