chiark / gitweb /
Bump version to 7.0.1~iwj0
[chiark-utils.git] / cprogs / xduplic-copier.c
index ff0830d27f13ac3ae931db6342c824758660723a..d9703a55e72ed42fb2c51c7ae0a7da054deeda22 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * Copyright (C) 2002 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright (C) 2002,2013 Ian Jackson <ian@chiark.greenend.org.uk>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2,
+ * published by the Free Software Foundation; either version 3,
  * or (at your option) any later version.
  *
  * This is distributed in the hope that it will be useful, but
@@ -11,9 +11,8 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public
- * License along with this file; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <X11/Xlib.h>
 #include <X11/cursorfont.h>
 #include <X11/cursorfont.h>
 #include <X11/Xmu/WinUtil.h>
+#include <X11/XKBlib.h>
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <assert.h>
+#include <string.h>
+#include <unistd.h>
 
 static Display *display;
 static int selecting, l1_x, l1_y;
@@ -143,8 +145,7 @@ static void buttonpress(XButtonEvent *e) {
 
   if (e->window != e->root) return;
 
-  sw= XmuClientWindow(display, e->subwindow);
-  if (!sw) {
+  if (!e->subwindow) {
     if (!rightbutton) {
       stopselecting();
     } else {
@@ -159,6 +160,8 @@ static void buttonpress(XButtonEvent *e) {
     return;
   }
 
+  sw= XmuClientWindow(display, e->subwindow);
+
   if (sw == w) { beep(); return; }
 
   for (ownp=&headwn;
@@ -200,7 +203,7 @@ static void keypress(XKeyEvent *e) {
            (unsigned long)e->time,
            e->x,e->y, e->x_root,e->y_root,
            e->state, e->keycode, (int)e->same_screen);
-    if (XKeycodeToKeysym(display, e->keycode, 0) == XK_q) _exit(1);
+    if (XkbKeycodeToKeysym(display, e->keycode, 0, 0) == XK_q) _exit(1);
     beep(); return;
   }
   for (own=headwn; own; own=own->next) {
@@ -232,6 +235,7 @@ int main(int argc, const char **argv) {
   Font font;
 
   display= XOpenDisplay(0);
+  if (!display) { fputs("XOpenDisplay failed\n",stderr); exit(-1); }
   screen= DefaultScreen(display);
   cmap= DefaultColormap(display,screen);
   root= DefaultRootWindow(display);