… | |
… | |
80 | new_ref (HV *hv, const char *klass) |
80 | new_ref (HV *hv, const char *klass) |
81 | { |
81 | { |
82 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
82 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
83 | } |
83 | } |
84 | |
84 | |
85 | //TODO: use magic |
|
|
86 | static SV * |
85 | static SV * |
87 | newSVptr (void *ptr, const char *klass) |
86 | newSVptr (void *ptr, const char *klass) |
88 | { |
87 | { |
89 | HV *hv = newHV (); |
88 | HV *hv = newHV (); |
90 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
89 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
… | |
… | |
494 | static void |
493 | static void |
495 | ungrab (rxvt_term *THIS) |
494 | ungrab (rxvt_term *THIS) |
496 | { |
495 | { |
497 | if (THIS->perl.grabtime) |
496 | if (THIS->perl.grabtime) |
498 | { |
497 | { |
499 | XUngrabKeyboard (THIS->xdisp, THIS->perl.grabtime); |
498 | XUngrabKeyboard (THIS->dpy, THIS->perl.grabtime); |
500 | XUngrabPointer (THIS->xdisp, THIS->perl.grabtime); |
499 | XUngrabPointer (THIS->dpy, THIS->perl.grabtime); |
501 | THIS->perl.grabtime = 0; |
500 | THIS->perl.grabtime = 0; |
502 | } |
501 | } |
503 | } |
502 | } |
504 | |
503 | |
505 | bool |
504 | bool |
… | |
… | |
883 | const_iv (XIMDontChange), |
882 | const_iv (XIMDontChange), |
884 | # endif |
883 | # endif |
885 | # endif |
884 | # endif |
886 | }; |
885 | }; |
887 | |
886 | |
888 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
887 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
889 | civ-- > const_iv; ) |
|
|
890 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
888 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
891 | } |
889 | } |
892 | |
890 | |
893 | void |
891 | void |
894 | warn (const char *msg) |
892 | warn (const char *msg) |
… | |
… | |
1020 | THIS->perl.should_invoke [htype] += inc; |
1018 | THIS->perl.should_invoke [htype] += inc; |
1021 | |
1019 | |
1022 | void |
1020 | void |
1023 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1021 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1024 | CODE: |
1022 | CODE: |
1025 | XGrabButton (THIS->xdisp, button, modifiers, window, 1, |
1023 | XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1026 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1024 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1027 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1025 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
1028 | |
1026 | |
1029 | void |
1027 | void |
1030 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
1028 | rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) |
1031 | CODE: |
1029 | CODE: |
1032 | XUngrabButton (THIS->xdisp, button, modifiers, window); |
1030 | XUngrabButton (THIS->dpy, button, modifiers, window); |
1033 | |
1031 | |
1034 | #if 0 |
1032 | #if 0 |
1035 | |
1033 | |
1036 | void |
1034 | void |
1037 | XGrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
1035 | XGrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
1038 | C_ARGS: |
1036 | C_ARGS: |
1039 | THIS->xdisp, keycode, modifiers, window, 1, |
1037 | THIS->dpy, keycode, modifiers, window, 1, |
1040 | GrabModeSync, GrabModeSync |
1038 | GrabModeSync, GrabModeSync |
1041 | |
1039 | |
1042 | void |
1040 | void |
1043 | XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
1041 | XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) |
1044 | C_ARGS: THIS->xdisp, keycode, modifiers, window |
1042 | C_ARGS: THIS->dpy, keycode, modifiers, window |
1045 | |
1043 | |
1046 | #endif |
1044 | #endif |
1047 | |
1045 | |
1048 | bool |
1046 | bool |
1049 | rxvt_term::grab (Time eventtime, int sync = 0) |
1047 | rxvt_term::grab (Time eventtime, int sync = 0) |
… | |
… | |
1051 | { |
1049 | { |
1052 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1050 | int mode = sync ? GrabModeSync : GrabModeAsync; |
1053 | |
1051 | |
1054 | THIS->perl.grabtime = 0; |
1052 | THIS->perl.grabtime = 0; |
1055 | |
1053 | |
1056 | if (!XGrabPointer (THIS->xdisp, THIS->vt, 0, |
1054 | if (!XGrabPointer (THIS->dpy, THIS->vt, 0, |
1057 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1055 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1058 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1056 | mode, mode, None, GRAB_CURSOR, eventtime)) |
1059 | if (!XGrabKeyboard (THIS->xdisp, THIS->vt, 0, mode, mode, eventtime)) |
1057 | if (!XGrabKeyboard (THIS->dpy, THIS->vt, 0, mode, mode, eventtime)) |
1060 | THIS->perl.grabtime = eventtime; |
1058 | THIS->perl.grabtime = eventtime; |
1061 | else |
1059 | else |
1062 | XUngrabPointer (THIS->xdisp, eventtime); |
1060 | XUngrabPointer (THIS->dpy, eventtime); |
1063 | |
1061 | |
1064 | RETVAL = !!THIS->perl.grabtime; |
1062 | RETVAL = !!THIS->perl.grabtime; |
1065 | } |
1063 | } |
1066 | OUTPUT: |
1064 | OUTPUT: |
1067 | RETVAL |
1065 | RETVAL |
1068 | |
1066 | |
1069 | void |
1067 | void |
1070 | rxvt_term::allow_events_async () |
1068 | rxvt_term::allow_events_async () |
1071 | CODE: |
1069 | CODE: |
1072 | XAllowEvents (THIS->xdisp, AsyncBoth, THIS->perl.grabtime); |
1070 | XAllowEvents (THIS->dpy, AsyncBoth, THIS->perl.grabtime); |
1073 | |
1071 | |
1074 | void |
1072 | void |
1075 | rxvt_term::allow_events_sync () |
1073 | rxvt_term::allow_events_sync () |
1076 | CODE: |
1074 | CODE: |
1077 | XAllowEvents (THIS->xdisp, SyncBoth, THIS->perl.grabtime); |
1075 | XAllowEvents (THIS->dpy, SyncBoth, THIS->perl.grabtime); |
1078 | |
1076 | |
1079 | void |
1077 | void |
1080 | rxvt_term::allow_events_replay () |
1078 | rxvt_term::allow_events_replay () |
1081 | CODE: |
1079 | CODE: |
1082 | XAllowEvents (THIS->xdisp, ReplayPointer, THIS->perl.grabtime); |
1080 | XAllowEvents (THIS->dpy, ReplayPointer, THIS->perl.grabtime); |
1083 | XAllowEvents (THIS->xdisp, ReplayKeyboard, THIS->perl.grabtime); |
1081 | XAllowEvents (THIS->dpy, ReplayKeyboard, THIS->perl.grabtime); |
1084 | |
1082 | |
1085 | void |
1083 | void |
1086 | rxvt_term::ungrab () |
1084 | rxvt_term::ungrab () |
1087 | CODE: |
1085 | CODE: |
1088 | ungrab (THIS); |
1086 | ungrab (THIS); |
… | |
… | |
1737 | void |
1735 | void |
1738 | rxvt_term::XListProperties (Window window) |
1736 | rxvt_term::XListProperties (Window window) |
1739 | PPCODE: |
1737 | PPCODE: |
1740 | { |
1738 | { |
1741 | int count; |
1739 | int count; |
1742 | Atom *props = XListProperties (THIS->xdisp, window, &count); |
1740 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1743 | |
1741 | |
1744 | EXTEND (SP, count); |
1742 | EXTEND (SP, count); |
1745 | while (count--) |
1743 | while (count--) |
1746 | PUSHs (newSVuv ((U32)props [count])); |
1744 | PUSHs (newSVuv ((U32)props [count])); |
1747 | |
1745 | |
… | |
… | |
1756 | int format; |
1754 | int format; |
1757 | unsigned long nitems; |
1755 | unsigned long nitems; |
1758 | unsigned long bytes_after; |
1756 | unsigned long bytes_after; |
1759 | unsigned char *prop; |
1757 | unsigned char *prop; |
1760 | |
1758 | |
1761 | XGetWindowProperty (THIS->xdisp, window, property, |
1759 | XGetWindowProperty (THIS->dpy, window, property, |
1762 | 0, 1<<24, 0, AnyPropertyType, |
1760 | 0, 1<<24, 0, AnyPropertyType, |
1763 | &type, &format, &nitems, &bytes_after, &prop); |
1761 | &type, &format, &nitems, &bytes_after, &prop); |
1764 | |
1762 | |
1765 | if (type != None) |
1763 | if (type != None) |
1766 | { |
1764 | { |
… | |
… | |
1785 | |
1783 | |
1786 | int elemsize = format == 16 ? sizeof (short) |
1784 | int elemsize = format == 16 ? sizeof (short) |
1787 | : format == 32 ? sizeof (long) |
1785 | : format == 32 ? sizeof (long) |
1788 | : 1; |
1786 | : 1; |
1789 | |
1787 | |
1790 | XChangeProperty (THIS->xdisp, window, property, |
1788 | XChangeProperty (THIS->dpy, window, property, |
1791 | type, format, PropModeReplace, |
1789 | type, format, PropModeReplace, |
1792 | (unsigned char *)data_, len / elemsize); |
1790 | (unsigned char *)data_, len / elemsize); |
1793 | XSync (THIS->xdisp, 0); |
1791 | XSync (THIS->dpy, 0); |
1794 | } |
1792 | } |
1795 | |
1793 | |
1796 | Atom |
1794 | Atom |
1797 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1795 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1798 | C_ARGS: term->xdisp, atom_name, only_if_exists |
1796 | C_ARGS: term->dpy, atom_name, only_if_exists |
1799 | |
1797 | |
1800 | char * |
1798 | char * |
1801 | XGetAtomName (rxvt_term *term, Atom atom) |
1799 | XGetAtomName (rxvt_term *term, Atom atom) |
1802 | C_ARGS: term->xdisp, atom |
1800 | C_ARGS: term->dpy, atom |
1803 | CLEANUP: |
1801 | CLEANUP: |
1804 | XFree (RETVAL); |
1802 | XFree (RETVAL); |
1805 | |
1803 | |
1806 | void |
1804 | void |
1807 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1805 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1808 | C_ARGS: term->xdisp, window, property |
1806 | C_ARGS: term->dpy, window, property |
1809 | |
1807 | |
1810 | Window |
1808 | Window |
1811 | rxvt_term::DefaultRootWindow () |
1809 | rxvt_term::DefaultRootWindow () |
1812 | CODE: |
1810 | CODE: |
1813 | RETVAL = THIS->display->root; |
1811 | RETVAL = THIS->display->root; |
… | |
… | |
1816 | |
1814 | |
1817 | #if 0 |
1815 | #if 0 |
1818 | |
1816 | |
1819 | Window |
1817 | Window |
1820 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1818 | XCreateSimpleWindow (rxvt_term *term, Window parent, int x, int y, unsigned int width, unsigned int height) |
1821 | C_ARGS: term->xdisp, (Window)parent, |
1819 | C_ARGS: term->dpy, (Window)parent, |
1822 | x, y, width, height, 0, |
1820 | x, y, width, height, 0, |
1823 | term->pix_colors_focused[Color_border], |
1821 | term->pix_colors_focused[Color_border], |
1824 | term->pix_colors_focused[Color_border] |
1822 | term->pix_colors_focused[Color_border] |
1825 | |
1823 | |
1826 | #endif |
1824 | #endif |
1827 | |
1825 | |
1828 | void |
1826 | void |
1829 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1827 | XReparentWindow (rxvt_term *term, Window window, Window parent, int x = 0, int y = 0) |
1830 | C_ARGS: term->xdisp, window, parent, x, y |
1828 | C_ARGS: term->dpy, window, parent, x, y |
1831 | |
1829 | |
1832 | void |
1830 | void |
1833 | XMapWindow (rxvt_term *term, Window window) |
1831 | XMapWindow (rxvt_term *term, Window window) |
1834 | C_ARGS: term->xdisp, window |
1832 | C_ARGS: term->dpy, window |
1835 | |
1833 | |
1836 | void |
1834 | void |
1837 | XUnmapWindow (rxvt_term *term, Window window) |
1835 | XUnmapWindow (rxvt_term *term, Window window) |
1838 | C_ARGS: term->xdisp, window |
1836 | C_ARGS: term->dpy, window |
1839 | |
1837 | |
1840 | void |
1838 | void |
1841 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1839 | XMoveResizeWindow (rxvt_term *term, Window window, int x, int y, unsigned int width, unsigned int height) |
1842 | C_ARGS: term->xdisp, window, x, y, width, height |
1840 | C_ARGS: term->dpy, window, x, y, width, height |
1843 | |
1841 | |
1844 | void |
1842 | void |
1845 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1843 | rxvt_term::XChangeInput (Window window, U32 add_events, U32 del_events = 0) |
1846 | CODE: |
1844 | CODE: |
1847 | { |
1845 | { |
1848 | XWindowAttributes attr; |
1846 | XWindowAttributes attr; |
1849 | XGetWindowAttributes (THIS->xdisp, window, &attr); |
1847 | XGetWindowAttributes (THIS->dpy, window, &attr); |
1850 | XSelectInput (THIS->xdisp, window, attr.your_event_mask | add_events & ~del_events); |
1848 | XSelectInput (THIS->dpy, window, attr.your_event_mask | add_events & ~del_events); |
1851 | } |
1849 | } |
1852 | |
1850 | |
1853 | void |
1851 | void |
1854 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1852 | rxvt_term::XTranslateCoordinates (Window src, Window dst, int x, int y) |
1855 | PPCODE: |
1853 | PPCODE: |
1856 | { |
1854 | { |
1857 | int dx, dy; |
1855 | int dx, dy; |
1858 | Window child; |
1856 | Window child; |
1859 | |
1857 | |
1860 | if (XTranslateCoordinates (THIS->xdisp, src, dst, x, y, &dx, &dy, &child)) |
1858 | if (XTranslateCoordinates (THIS->dpy, src, dst, x, y, &dx, &dy, &child)) |
1861 | { |
1859 | { |
1862 | EXTEND (SP, 3); |
1860 | EXTEND (SP, 3); |
1863 | PUSHs (newSViv (dx)); |
1861 | PUSHs (newSViv (dx)); |
1864 | PUSHs (newSViv (dy)); |
1862 | PUSHs (newSViv (dy)); |
1865 | PUSHs (newSVuv (child)); |
1863 | PUSHs (newSVuv (child)); |