1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvttoolkit.C |
2 | * File: rxvttoolkit.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2011 Marc Lehmann <schmorp@schmorp.de> |
7 | * Copyright (c) 2011 Emanuele Giaquinta <e.giaquinta@glauco.it> |
7 | * Copyright (c) 2011 Emanuele Giaquinta <e.giaquinta@glauco.it> |
8 | * |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
11 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
703 | c.color.red = color.r; |
703 | c.color.red = color.r; |
704 | c.color.green = color.g; |
704 | c.color.green = color.g; |
705 | c.color.blue = color.b; |
705 | c.color.blue = color.b; |
706 | c.color.alpha = alpha; |
706 | c.color.alpha = alpha; |
707 | |
707 | |
|
|
708 | // ARGB visuals use premultiplied alpha |
|
|
709 | if (format->direct.alphaMask) |
|
|
710 | { |
|
|
711 | c.color.red = c.color.red * alpha / 0xffff; |
|
|
712 | c.color.green = c.color.green * alpha / 0xffff; |
|
|
713 | c.color.blue = c.color.blue * alpha / 0xffff; |
|
|
714 | } |
|
|
715 | |
708 | c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) |
716 | c.pixel = insert_component (c.color.red , format->direct.redMask , format->direct.red ) |
709 | | insert_component (color.g, format->direct.greenMask, format->direct.green) |
717 | | insert_component (c.color.green, format->direct.greenMask, format->direct.green) |
710 | | insert_component (color.b, format->direct.blueMask , format->direct.blue ) |
718 | | insert_component (c.color.blue , format->direct.blueMask , format->direct.blue ) |
711 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
719 | | insert_component (alpha , format->direct.alphaMask, format->direct.alpha); |
712 | |
720 | |
713 | return true; |
721 | return true; |
714 | } |
722 | } |
715 | else |
723 | else |
716 | { |
724 | { |
… | |
… | |
892 | lerp (c.a, to.a, percent) |
900 | lerp (c.a, to.a, percent) |
893 | ) |
901 | ) |
894 | ); |
902 | ); |
895 | } |
903 | } |
896 | |
904 | |
897 | rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term, void *cb_sv) |
905 | rxvt_selection::rxvt_selection (rxvt_display *disp, int selnum, Time tm, Window win, Atom prop, rxvt_term *term) |
898 | : display (disp), request_time (tm), request_win (win), request_prop (prop), term (term), cb_sv (cb_sv) |
906 | : display (disp), request_time (tm), request_win (win), request_prop (prop), term (term) |
899 | { |
907 | { |
900 | assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard); |
908 | assert (selnum >= Sel_Primary && selnum <= Sel_Clipboard); |
901 | |
909 | |
902 | timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this); |
910 | timer_ev.set<rxvt_selection, &rxvt_selection::timer_cb> (this); |
903 | timer_ev.repeat = 10.; |
911 | timer_ev.repeat = 10.; |
… | |
… | |
925 | |
933 | |
926 | void |
934 | void |
927 | rxvt_selection::run () |
935 | rxvt_selection::run () |
928 | { |
936 | { |
929 | int selnum = selection_type; |
937 | int selnum = selection_type; |
|
|
938 | |
|
|
939 | #if ENABLE_FRILLS |
|
|
940 | if (selnum == Sel_Primary && display->selection_owner) |
|
|
941 | { |
|
|
942 | /* internal selection */ |
|
|
943 | char *str = rxvt_wcstombs (display->selection_owner->selection.text, display->selection_owner->selection.len); |
|
|
944 | finish (str, strlen (str)); |
|
|
945 | free (str); |
|
|
946 | return; |
|
|
947 | } |
|
|
948 | #endif |
930 | |
949 | |
931 | #if X_HAVE_UTF8_STRING |
950 | #if X_HAVE_UTF8_STRING |
932 | selection_type = Sel_UTF8String; |
951 | selection_type = Sel_UTF8String; |
933 | if (request (display->xa[XA_UTF8_STRING], selnum)) |
952 | if (request (display->xa[XA_UTF8_STRING], selnum)) |
934 | return; |
953 | return; |
… | |
… | |
954 | delete this; |
973 | delete this; |
955 | } |
974 | } |
956 | #if ENABLE_PERL |
975 | #if ENABLE_PERL |
957 | else |
976 | else |
958 | { |
977 | { |
959 | stop (); |
978 | stop (); // we do not really trust perl callbacks |
960 | abort (); //TODO |
979 | rxvt_perl.selection_finish (this, data, len); |
961 | } |
980 | } |
962 | #endif |
981 | #endif |
963 | } |
982 | } |
964 | |
983 | |
965 | bool |
984 | bool |