set _NET_WM_USER_TIME on the window
[dana/urxvt.git] / src / command.C
index 986fc7f..78fa3b5 100644 (file)
@@ -200,7 +200,7 @@ rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y)
   fname = rxvt_temp_buf<wchar_t *> (len);
   for (int i = 0; i < len; i++)
     {
-      rxvt_font *f = fs->get (chr[i]);
+      rxvt_font *f = (*fs)[fs->find_font_idx (chr[i])];
       fname[i] = rxvt_utf8towcs (f->name);
       max_it (width, wcswidth (fname[i], wcslen (fname[i])));
     }
@@ -290,7 +290,7 @@ rxvt_term::commit_iso14755 ()
 static int
 hex_keyval (XKeyEvent &ev)
 {
-  // check wether this event corresponds to a hex digit
+  // check whether this event corresponds to a hex digit
   // if the modifiers had not been pressed.
   for (int index = 0; index < 8; index++)
     {
@@ -402,6 +402,13 @@ map_function_key (KeySym keysym)
 }
 
 void
+rxvt_term::update_user_time (Time time)
+{
+  XChangeProperty (dpy, parent[0], xa[XA_NET_WM_USER_TIME], XA_CARDINAL,
+                   32, PropModeReplace, (unsigned char*)&time, 1);
+}
+
+void
 rxvt_term::key_press (XKeyEvent &ev)
 {
   int ctrl, meta, shft, len;
@@ -424,12 +431,6 @@ rxvt_term::key_press (XKeyEvent &ev)
   ctrl = ev.state & ControlMask;
   meta = ev.state & ModMetaMask;
 
-  if (numlock_state || (ev.state & ModNumLockMask))
-    {
-      numlock_state = (ev.state & ModNumLockMask);
-      set_privmode (PrivMode_aplKP, !numlock_state);
-    }
-
   kbuf[0] = 0;
 
 #ifdef USE_XIM
@@ -604,6 +605,24 @@ rxvt_term::key_press (XKeyEvent &ev)
 # endif
               return;
             }
+          else if (keysym == XK_C)
+            {
+              selection_make (ev.time, true);
+# if ISO_14755
+              scr_overlay_off ();
+# endif
+              iso14755buf = 0;
+              return;
+            }
+          else if (keysym == XK_V)
+            {
+              selection_request (ev.time, Sel_Clipboard);
+# if ISO_14755
+              scr_overlay_off ();
+# endif
+              iso14755buf = 0;
+              return;
+            }
           else if (keysym == XK_BackSpace)
             {
               iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51;
@@ -655,7 +674,12 @@ rxvt_term::key_press (XKeyEvent &ev)
           bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
           unsigned int newlen = 1;
 
-          switch (translate_keypad (keysym, kp))
+          if (ev.state & ModNumLockMask)
+            kp = false;
+
+          keysym = translate_keypad (keysym, kp);
+
+          switch (keysym)
             {
 #ifndef NO_BACKSPACE_KEY
               case XK_BackSpace:
@@ -1035,7 +1059,7 @@ rxvt_term::flush ()
   display->flush ();
 }
 
-/* checks wether a refresh is requested and starts the refresh timer */
+/* checks whether a refresh is requested and starts the refresh timer */
 void
 rxvt_term::refresh_check ()
 {
@@ -1139,7 +1163,7 @@ static struct event_handler
     // ones with high nice levels is a useful thing to do. It surely is is
     // allowed by the sus... as is returning ENOSYS.
     // since the linux guys additionally thought that breaking the only
-    // known workaroudn against their unusable sched_yield hack is cool,
+    // known workaround against their unusable sched_yield hack is cool,
     // we just nanosleep a bit and hope for the best.
 
     struct timespec ts = { 0, 1000 };
@@ -1345,6 +1369,7 @@ rxvt_term::x_cb (XEvent &ev)
   switch (ev.type)
     {
       case KeyPress:
+        update_user_time (ev.xkey.time);
         key_press (ev.xkey);
         break;
 
@@ -1353,6 +1378,7 @@ rxvt_term::x_cb (XEvent &ev)
         break;
 
       case ButtonPress:
+        update_user_time (ev.xbutton.time);
         button_press (ev.xbutton);
         break;
 
@@ -1840,6 +1866,8 @@ rxvt_term::button_press (XButtonEvent &ev)
 {
   int reportmode = 0, clickintime;
 
+  button_state[ev.button - Button1] = true;
+
   bypass_keystate = ev.state & (ModMetaMask | ShiftMask);
 
   if (!bypass_keystate)
@@ -2086,6 +2114,11 @@ rxvt_term::button_release (XButtonEvent &ev)
 {
   int reportmode = 0;
 
+  if (button_state[ev.button - Button1] == false)
+      return; /* it wasn't pressed so why is it released? */
+
+  button_state[ev.button - Button1] = false;
+
   csrO = 0;            /* reset csr Offset */
   if (!bypass_keystate)
     reportmode = !! (priv_modes & PrivMode_mouse_report);
@@ -2153,7 +2186,7 @@ rxvt_term::button_release (XButtonEvent &ev)
 
           case Button2:
             if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
-             selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
+              selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
             break;
 
 #ifdef MOUSE_WHEEL
@@ -3397,15 +3430,18 @@ rxvt_term::process_xterm_seq (int op, char *str, char resp)
       case XTerm_Color_pointer_bg:
         process_color_seq (op, Color_pointer_bg, str, resp);
         break;
-#ifndef NO_BOLD_UNDERLINE_REVERSE
-      case XTerm_Color_RV:
-        process_color_seq (op, Color_RV, str, resp);
+#ifdef OPTION_HC
+      case XTerm_Color_HC:
+        process_color_seq (op, Color_HC, str, resp);
         break;
-      case Rxvt_Color_BD:
+      case XTerm_Color_HTC:
+        process_color_seq (op, Color_HTC, str, resp);
+        break;
+#endif
+#ifndef NO_BOLD_UNDERLINE_REVERSE
       case URxvt_Color_BD:
         process_color_seq (op, Color_BD, str, resp);
         break;
-      case Rxvt_Color_UL:
       case URxvt_Color_UL:
         process_color_seq (op, Color_UL, str, resp);
         break;