summaryrefslogtreecommitdiff
path: root/sysutils/wmbluecpu/files/patch-dockapp.c
blob: 98f58c328ff9a992a4a5f1057f83f0a5045a4f63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--- dockapp.c	2003-03-23 05:10:15.000000000 +1030
+++ dockapp.c	2009-02-11 12:34:18.897651000 +1030
@@ -238,9 +238,9 @@
 		  32, PropModeReplace, (unsigned char *)&mwmhints, 5);
  }
  XMapWindow(display, mapwindow);
- signal(SIGINT, handle_signal);
- signal(SIGQUIT, handle_signal);
- signal(SIGTERM, handle_signal);
+ //signal(SIGINT, handle_signal);
+ //signal(SIGQUIT, handle_signal);
+ //signal(SIGTERM, handle_signal);
 }
 
 void update_window()
@@ -253,42 +253,55 @@
 {
  XEvent event;
  int winx, winy;
+ fd_set fdset;
+ struct timeval timeout;
 
- XNextEvent(display, &event);
- switch(event.type)
- {
-  case Expose:
-   update_window();
-   break;
-  case ButtonPress:
-   if(opt_window && (event.xbutton.button == 1))
-   {
-    XDefineCursor(display, mapwindow, fleur);
-    moving = 1;
-    oldx = event.xbutton.x;
-    oldy = event.xbutton.y;
-   }
-   break;
-  case MotionNotify:
-   winx = event.xmotion.x_root - oldx;
-   winy = event.xmotion.y_root - oldy;
-   if(winx < 0) winx = 0;
-   if(winy < 0) winy = 0;
-   if(winx > (screenwidth - WINDOW_WIDTH)) winx = screenwidth - WINDOW_WIDTH;
-   if(winy > (screenheight - WINDOW_HEIGHT)) winy = screenheight - WINDOW_HEIGHT;
-   if(moving)
-    XMoveWindow(display, mapwindow, winx, winy);
-   break;
-  case ButtonRelease:
-   if(opt_window)
-   {
-    moving = 0;
-    XUndefineCursor(display, mapwindow);
-   }
-   break;
-  case ClientMessage:
-   if(event.xclient.data.l[0] == wm_delete_window)
-    exitloop = 1;
-   break;
+ FD_ZERO(&fdset);
+ FD_SET(ConnectionNumber(display), &fdset);
+ timeout.tv_usec = opt_timer_miliseconds % 1000;
+ timeout.tv_sec = opt_timer_miliseconds/1000;
+
+ if( select(ConnectionNumber(display)+1, &fdset, NULL, NULL, &timeout) > 0 ){
+     while( XPending( display )){
+	 XNextEvent(display, &event);
+	 switch(event.type)
+	 {
+	     case Expose:
+		 update_window();
+		 break;
+	     case ButtonPress:
+		 if(opt_window && (event.xbutton.button == 1))
+		 {
+		     XDefineCursor(display, mapwindow, fleur);
+		     moving = 1;
+		     oldx = event.xbutton.x;
+		     oldy = event.xbutton.y;
+		 }
+		 break;
+	     case MotionNotify:
+		 winx = event.xmotion.x_root - oldx;
+		 winy = event.xmotion.y_root - oldy;
+		 if(winx < 0) winx = 0;
+		 if(winy < 0) winy = 0;
+		 if(winx > (screenwidth - WINDOW_WIDTH)) winx = screenwidth - WINDOW_WIDTH;
+		 if(winy > (screenheight - WINDOW_HEIGHT)) winy = screenheight - WINDOW_HEIGHT;
+		 if(moving)
+		     XMoveWindow(display, mapwindow, winx, winy);
+		 break;
+	     case ButtonRelease:
+		 if(opt_window)
+		 {
+		     moving = 0;
+		     XUndefineCursor(display, mapwindow);
+		 }
+		 break;
+	     case ClientMessage:
+		 if(event.xclient.data.l[0] == wm_delete_window)
+		     exitloop = 1;
+		 break;
+	 }
+     }
+ } else {
+     handle_timer(SIGALRM);
  }
 }