From 70d99d80630d6e5ab0a95bd17ed928f94258b2a5 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Jul 2006 23:48:10 +0000 Subject: [PATCH] *** empty log message *** --- Changes | 4 +++- MANIFEST | 1 + src/command.C | 8 ++++++- src/hookinc.h | 1 + src/main.C | 7 ++++-- src/perl/kuake | 52 +++++++++++++++++++++++++++++++++++++++++ src/rxvt.h | 2 +- src/rxvtperl.xs | 62 +++++++++++++++++++++++++++++++++++++------------ src/urxvt.pm | 23 ++++++++++++++++++ 9 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 src/perl/kuake diff --git a/Changes b/Changes index 9a47a7a5..9aed84e6 100644 --- a/Changes +++ b/Changes @@ -19,14 +19,16 @@ WISH: anyevent mouse notification / manage MotionMask better. WISH: http://www120.pair.com/mccarthy/nextstep/intro.htmld/Workspace.html is the correct nextstep look. DUMB: support tex fonts +7.8 TODO: investigate -pe tabbed -g 80x25 being 23 not 24 or 25 lines TODO: zero scorllback buffer should free memory -TODO: kuake - INCOMPATIBLE CHANGE: this version will always read ~/.Xdefaults, earlier versions only read it if display-resources (usually from .Xresources) are not set. This avoids the #1 FAQ ("why isn't my resource used") and seems to be logical behaviour, too. .Xdefaults resources have a lower priority than display-specific resources. + - add "kuake" perl extension that does a similar thing to the kuake + terminal emulator (see man urxtvperl). - use less "correct" color scaling that is compatible with libX11 and Xft (avoids off-by-one colors resulting in striped backgrounds). - the "depth" resource is now respected. diff --git a/MANIFEST b/MANIFEST index a6ce565d..96ddd8fe 100644 --- a/MANIFEST +++ b/MANIFEST @@ -171,6 +171,7 @@ src/perl/tabbed src/perl/xim-onthespot src/perl/readline src/perl/remote-clipboard +src/perl/kuake src/perl/example-refresh-hooks src/perl/block-graphics-to-ascii src/perl/digital-clock diff --git a/src/command.C b/src/command.C index c405c811..b4097bc1 100644 --- a/src/command.C +++ b/src/command.C @@ -1790,12 +1790,17 @@ rxvt_term::update_fade_color (unsigned int idx) #endif } -#if TRANSPARENT +#if TRANSPARENT || ENABLE_PERL void rxvt_term::rootwin_cb (XEvent &ev) { make_current (); + if (SHOULD_INVOKE (HOOK_ROOT_EVENT) + && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) + return; + +# if TRANSPARENT switch (ev.type) { case PropertyNotify: @@ -1813,6 +1818,7 @@ rxvt_term::rootwin_cb (XEvent &ev) want_refresh = want_full_refresh = 1; break; } +# endif } #endif diff --git a/src/hookinc.h b/src/hookinc.h index 603ebe77..346fc595 100644 --- a/src/hookinc.h +++ b/src/hookinc.h @@ -27,6 +27,7 @@ def (USER_COMMAND) + def (ROOT_EVENT) def (X_EVENT) def (FOCUS_IN) def (FOCUS_OUT) diff --git a/src/main.C b/src/main.C index 1acc5f7d..8b28c7fa 100644 --- a/src/main.C +++ b/src/main.C @@ -145,7 +145,7 @@ int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) rxvt_term::rxvt_term () : -#if TRANSPARENT +#if TRANSPARENT || ENABLE_PERL rootwin_ev (this, &rxvt_term::rootwin_cb), #endif #ifdef HAVE_SCROLLBARS @@ -328,7 +328,7 @@ rxvt_term::destroy () #if HAVE_SCROLLBARS scrollbar_ev.stop (display); #endif -#if TRANSPARENT +#if TRANSPARENT || ENABLE_PERL rootwin_ev.stop (display); #endif incr_ev.stop (); @@ -506,6 +506,9 @@ rxvt_term::init (int argc, const char *const *argv, stringvec *envv) rootwin_ev.start (display, display->root); } #endif +#if ENABLE_PERL + rootwin_ev.start (display, display->root); +#endif set_colorfgbg (); diff --git a/src/perl/kuake b/src/perl/kuake new file mode 100644 index 00000000..9ea51663 --- /dev/null +++ b/src/perl/kuake @@ -0,0 +1,52 @@ +#! perl + +sub on_start { + my ($self) = @_; + + $self->{key} = $self->{argv}[0] || "F10"; + + $self->{keysym} = $self->XStringToKeysym ($self->{key}) + or urxvt::fatal "cannot convert requested kuake wake-up key '$self->{key}' to keysym, unable to continue.\n"; + + $self->{keycode} = $self->XKeysymToKeycode ($self->{keysym}) + or urxvt::fatal "cannot convert requested kuake wake-up key '$self->{key}' to keycode, unable to continue.\n"; + + $self->XGrabKey ($self->{keycode}, urxvt::AnyModifier, $self->DefaultRootWindow); + + $self->XUnmapWindow ($self->parent); + + $self->{unmap_me} = 1; + + () +} + +sub on_map_notify { + my ($self) = @_; + + # suppress initial map event + $self->XUnmapWindow ($self->parent) + if delete $self->{unmap_me}; + + () +} + +sub on_root_event { + my ($self, $event) = @_; + + return unless $event->{type} == urxvt::KeyPress && $event->{keycode} == $self->{keycode}; + + $self->mapped + ? $self->XUnmapWindow ($self->parent) + : $self->XMapWindow ($self->parent); + + 1 +} + +sub on_destroy { + my ($self) = @_; + + $self->XUngrabKey ($self->XKeysymToKeycode ($self->{keysym}), 0, $self->DefaultRootWindow) + if $self->{keysym}; + + () +} diff --git a/src/rxvt.h b/src/rxvt.h index e71e9af5..82dc3ec4 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -1101,7 +1101,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen { XSelectInput (dpy, vt, vt_emask | vt_emask_perl | vt_emask_xim); } -#if TRANSPARENT +#if TRANSPARENT || ENABLE_PERL void rootwin_cb (XEvent &xev); xevent_watcher rootwin_ev; #endif diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs index 6ebbe1f9..ebf88649 100644 --- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -790,6 +790,10 @@ BOOT: const_iv (Button5Mask), const_iv (AnyModifier), + const_iv (NoSymbol), + const_iv (GrabModeSync), + const_iv (GrabModeAsync), + const_iv (EVENT_NONE), const_iv (EVENT_READ), const_iv (EVENT_WRITE), @@ -1014,31 +1018,35 @@ rxvt_term::set_should_invoke (int htype, int inc) CODE: THIS->perl.should_invoke [htype] += inc; -void +int rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) CODE: - XGrabButton (THIS->dpy, button, modifiers, window, 1, - ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, - GrabModeSync, GrabModeSync, None, GRAB_CURSOR); + RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, + ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, + GrabModeSync, GrabModeSync, None, GRAB_CURSOR); + OUTPUT: RETVAL -void +int rxvt_term::ungrab_button (int button, U32 modifiers, Window window = THIS->vt) CODE: - XUngrabButton (THIS->dpy, button, modifiers, window); - -#if 0 + RETVAL = XUngrabButton (THIS->dpy, button, modifiers, window); + OUTPUT: RETVAL void -XGrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) - C_ARGS: - THIS->dpy, keycode, modifiers, window, 1, - GrabModeSync, GrabModeSync +rxvt_term::XGrabKey (int keycode, U32 modifiers, Window window = THIS->vt, \ + int owner_events = 1, int pointer_mode = GrabModeAsync, int keyboard_mode = GrabModeAsync) + CODE: + XGrabKey (THIS->dpy, keycode, modifiers, window, owner_events, pointer_mode, keyboard_mode); void -XUngrabKey (rxvt_term *THIS, int keycode, U32 modifiers, Window window = THIS->vt) - C_ARGS: THIS->dpy, keycode, modifiers, window +rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) + CODE: + XUngrabKey (THIS->dpy, keycode, modifiers, window); -#endif +void +rxvt_term::XUngrabKeyboard (Time eventtime) + CODE: + XUngrabKeyboard (THIS->dpy, eventtime); bool rxvt_term::grab (Time eventtime, int sync = 0) @@ -1082,6 +1090,30 @@ rxvt_term::ungrab () CODE: ungrab (THIS); +int +rxvt_term::XStringToKeysym (char *string) + CODE: + RETVAL = XStringToKeysym (string); + OUTPUT: RETVAL + +char * +rxvt_term::XKeysymToString (int sym) + CODE: + RETVAL = XKeysymToString (sym); + OUTPUT: RETVAL + +int +rxvt_term::XKeysymToKeycode (int sym) + CODE: + RETVAL = XKeysymToKeycode (THIS->dpy, sym); + OUTPUT: RETVAL + +int +rxvt_term::XKeycodeToKeysym (int code, int index) + CODE: + RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); + OUTPUT: RETVAL + int rxvt_term::strwidth (SV *str) CODE: diff --git a/src/urxvt.pm b/src/urxvt.pm index a9265809..948c0d05 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -261,6 +261,25 @@ C, i.e.: @@RXVT_NAME@@ -pt OnTheSpot -pe xim-onthespot +=item kuake + +A very primitive quake-console-like extension. It was inspired by a +description of how the programs C and C work: Whenever the +user presses a global accelerator key (by default C), the terminal +will show or hide itself. Another press of the accelerator key will hide +or show it again. + +Initially, the window will not be shown when using this extension. + +This is useful if you need a single terminal thats not using any desktop +space most of the time but is quickly available at the press of a key. + +The accelerator key is grabbed regardless of any modifers, so this +extension will actually grab a physical key just for this function. + +If you want a quake-like animation, tell your window manager to do so +(fvwm can do it). + =item automove-background This is basically a very small extension that dynamically changes the @@ -584,6 +603,10 @@ Called on every X event received on the vt window (and possibly other windows). Should only be used as a last resort. Most event structure members are not passed. +=item on_root_event $term, $event + +Like C, but is called for events on the root window. + =item on_focus_in $term Called whenever the window gets the keyboard focus, before rxvt-unicode -- 2.34.1