~ubuntu-branches/ubuntu/hardy/sawfish-merlin-ugliness/hardy

« back to all changes in this revision

Viewing changes to x.c.patch

  • Committer: Bazaar Package Importer
  • Author(s): Christian Marillat
  • Date: 2004-07-28 15:21:44 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040728152144-1b1tm5ak371o1pe9
Tags: 1.3.1-1
* New upstream relase.
* Remove old dependency on sawfish-gnome and sawfish2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# version -0.8.3
3
 
#
4
 
# Copyright (C) 2000-2001 merlin <merlin@merlin.org>
5
 
#
6
 
# Built from sawfish 1.00.
 
2
# version -0.8.7
 
3
#
 
4
# Copyright (C) 2000-2002 merlin <merlin@merlin.org>
 
5
#
 
6
# Built from sawfish 1.2
7
7
#
8
8
# *********************
9
9
# ** HERE BE DRAGONS **
86
86
 
87
87
Index: src/x.c
88
88
===================================================================
89
 
RCS file: /cvsroot/sawmill/sawmill/src/x.c,v
90
 
retrieving revision 1.19
91
 
diff -u -r1.19 x.c
92
 
--- src/x.c     2001/04/12 20:02:04     1.19
93
 
+++ src/x.c     2001/07/15 12:46:16
 
89
RCS file: /cvs/gnome/sawfish/src/x.c,v
 
90
retrieving revision 1.23
 
91
diff -u -r1.23 x.c
 
92
--- src/x.c     3 Nov 2002 02:22:43 -0000       1.23
 
93
+++ src/x.c     10 Nov 2002 22:41:28 -0000
94
94
@@ -6,6 +6,9 @@
95
95
    Originally written by merlin <merlin@merlin.org>, with additions
96
96
    from John Harper
97
97
 
98
98
+   Then patched again by merlin to add some wicked functions:
99
 
+   x.c#pl:merlin/-0.8.3
 
99
+   x.c#pl:merlin/-0.8.6
100
100
+
101
101
    This file is part of sawmill.
102
102
 
103
103
    sawmill is free software; you can redistribute it and/or modify it
104
 
@@ -72,6 +75,7 @@
 
104
@@ -73,6 +76,7 @@
105
105
     int is_pixmap : 1;
106
106
     int is_bitmap : 1;                 /* depth == 1 */
107
107
     int width, height;
109
109
 } Lisp_X_Window;
110
110
 
111
111
 #define X_XDRAWABLEP(v) rep_CELL16_TYPEP(v, x_window_type)
112
 
@@ -82,6 +86,8 @@
 
112
@@ -83,6 +87,8 @@
113
113
 #define X_PIXMAPP(v)   (X_DRAWABLEP (v) && VX_DRAWABLE (v)->is_pixmap)
114
114
 #define X_BITMAPP(v)   (X_DRAWABLEP (v) && VX_DRAWABLE (v)->is_bitmap)
115
115
 
118
118
 static Lisp_X_GC *x_gc_list = NULL;
119
119
 int x_gc_type;
120
120
 
121
 
@@ -115,6 +121,35 @@
 
121
@@ -116,6 +122,37 @@
122
122
 DEFSYM (clip_mask, "clip-mask");
123
123
 DEFSYM (clip_x_origin, "clip-x-origin");
124
124
 DEFSYM (clip_y_origin, "clip-y-origin");
151
151
+DEFSYM (message_type, "message-type");
152
152
+DEFSYM (format, "format");
153
153
+DEFSYM (data, "data");
 
154
+DEFSYM (above, "above");
 
155
+DEFSYM (value_mask, "value-mask");
154
156
 
155
157
 DEFSYM (LineSolid, "line-solid");
156
158
 DEFSYM (LineOnOffDash, "line-on-off-dash");
157
 
@@ -216,6 +251,59 @@
 
159
@@ -217,6 +254,54 @@
158
160
     return GXcopy;
159
161
 }
160
162
 
192
194
+    return result;
193
195
+}
194
196
+
195
 
+typedef struct {
196
 
+    char *str;
197
 
+    unsigned int value;
198
 
+} x_str_value;
199
 
+
200
197
+static int
201
 
+x_symbol_match (repv symbol, x_str_value *match) {
 
198
+x_symbol_match (repv symbol, x_value_str *match) {
202
199
+    char *tmp;
203
200
+    if (!rep_SYMBOLP (symbol))
204
201
+      return -1;
214
211
 
215
212
 /* GC Functions */
216
213
 
217
 
@@ -470,6 +558,16 @@
 
214
@@ -500,6 +585,16 @@
218
215
     return Qt;
219
216
 }
220
217
 
231
228
 DEFUN ("x-gc-p", Fx_gc_p, Sx_gc_p, (repv gc), rep_Subr1) /*
232
229
 ::doc:sawfish.wm.util.x#x-gc-p::
233
230
 x-gcp ARG
234
 
@@ -483,6 +581,15 @@
 
231
@@ -513,6 +608,15 @@
235
232
 
236
233
 /* Window functions */
237
234
 
238
 
+static x_str_value x_stack_mode_matches[] = {
239
 
+    { "above", Above },
240
 
+    { "below", Below },
241
 
+    { "top-if", TopIf },
242
 
+    { "bottom-if", BottomIf },
243
 
+    { "opposite", Opposite },
 
235
+static x_value_str x_stack_mode_matches[] = {
 
236
+    { Above, "above" },
 
237
+    { Below, "below" },
 
238
+    { TopIf, "top-if" },
 
239
+    { BottomIf, "bottom-if" },
 
240
+    { Opposite, "opposite" },
244
241
+    { 0, 0 }
245
242
+};
246
243
+
247
244
 static long
248
245
 x_window_parse_changes (XWindowChanges *changes, repv attrs)
249
246
 {
250
 
@@ -520,6 +627,24 @@
 
247
@@ -550,6 +654,24 @@
251
248
                changes->border_width = rep_INT (rep_CDR (tem));
252
249
                changesMask |= CWBorderWidth;
253
250
            }
272
269
        }
273
270
 
274
271
        attrs = rep_CDR (attrs);
275
 
@@ -537,6 +662,35 @@
 
272
@@ -567,6 +689,35 @@
276
273
        w->height = changes->height;
277
274
 }
278
275
 
279
 
+static x_str_value x_event_mask_matches[] = {
280
 
+    { "key-press", KeyPressMask },
281
 
+    { "key-release", KeyReleaseMask },
282
 
+    { "button-press", ButtonPressMask },
283
 
+    { "button-release", ButtonReleaseMask },
284
 
+    { "enter-window", EnterWindowMask },
285
 
+    { "leave-window", LeaveWindowMask },
286
 
+    { "pointer-motion", PointerMotionMask },
287
 
+    { "pointer-motion-hint", PointerMotionHintMask },
288
 
+    { "button-1-motion", Button1MotionMask },
289
 
+    { "button-2-motion", Button2MotionMask },
290
 
+    { "button-3-motion", Button3MotionMask },
291
 
+    { "button-4-motion", Button4MotionMask },
292
 
+    { "button-5-motion", Button5MotionMask },
293
 
+    { "button-motion", ButtonMotionMask },
294
 
+    { "keymap-state", KeymapStateMask },
295
 
+    { "exposure", ExposureMask },
296
 
+    { "visibility-change", VisibilityChangeMask },
297
 
+    { "structure-notify", StructureNotifyMask },
298
 
+    { "resize-redirect", ResizeRedirectMask },
299
 
+    { "substructure-notify", SubstructureNotifyMask },
300
 
+    { "substructure-redirect", SubstructureRedirectMask },
301
 
+    { "focus-change", FocusChangeMask },
302
 
+    { "property-change", PropertyChangeMask },
303
 
+    { "colormap-change", ColormapChangeMask },
304
 
+    { "owner-grab-button", OwnerGrabButtonMask },
 
276
+static x_value_str x_event_mask_matches[] = {
 
277
+    { KeyPressMask, "key-press" },
 
278
+    { KeyReleaseMask, "key-release" },
 
279
+    { ButtonPressMask, "button-press" },
 
280
+    { ButtonReleaseMask, "button-release" },
 
281
+    { EnterWindowMask, "enter-window" },
 
282
+    { LeaveWindowMask, "leave-window" },
 
283
+    { PointerMotionMask, "pointer-motion" },
 
284
+    { PointerMotionHintMask, "pointer-motion-hint" },
 
285
+    { Button1MotionMask, "button-1-motion" },
 
286
+    { Button2MotionMask, "button-2-motion" },
 
287
+    { Button3MotionMask, "button-3-motion" },
 
288
+    { Button4MotionMask, "button-4-motion" },
 
289
+    { Button5MotionMask, "button-5-motion" },
 
290
+    { ButtonMotionMask, "button-motion" },
 
291
+    { KeymapStateMask, "keymap-state" },
 
292
+    { ExposureMask, "exposure" },
 
293
+    { VisibilityChangeMask, "visibility-change" },
 
294
+    { StructureNotifyMask, "structure-notify" },
 
295
+    { ResizeRedirectMask, "resize-redirect" },
 
296
+    { SubstructureNotifyMask, "substructure-notify" },
 
297
+    { SubstructureRedirectMask, "substructure-redirect" },
 
298
+    { FocusChangeMask, "focus-change" },
 
299
+    { PropertyChangeMask, "property-change" },
 
300
+    { ColormapChangeMask, "colormap-change" },
 
301
+    { OwnerGrabButtonMask, "owner-grab-button" },
305
302
+    { 0, 0 }
306
303
+};
307
304
+                    
308
305
 static long
309
306
 x_window_parse_attributes (XSetWindowAttributes *attributes, repv attrs)
310
307
 {
311
 
@@ -559,6 +713,28 @@
 
308
@@ -589,6 +740,28 @@
312
309
                attributes->border_pixel = VCOLOR (rep_CDR (tem))->pixel;
313
310
                attributesMask |= CWBorderPixel;
314
311
            }
337
334
        }
338
335
 
339
336
        attrs = rep_CDR (attrs);
340
 
@@ -567,32 +743,249 @@
 
337
@@ -597,32 +770,290 @@
341
338
     return attributesMask;
342
339
 }
343
340
 
427
424
+    { 0, 0 }
428
425
+};
429
426
+
 
427
+static x_value_str x_configure_mask_matches[] = {
 
428
+  { CWX, "x" },
 
429
+  { CWY, "y" },
 
430
+  { CWWidth, "width" },
 
431
+  { CWHeight, "height" },
 
432
+  { CWBorderWidth, "border-width" },
 
433
+  { CWSibling, "sibling" },
 
434
+  { CWStackMode, "stack-mode" },
 
435
+  { 0, 0 }
 
436
+};
 
437
+
430
438
+static repv
431
439
+x_encode_keysym (unsigned int keycode, unsigned int state) {
432
440
+   KeySym sym = NoSymbol;
442
450
+
443
451
+#define ALIST_PRE(A,B,C) A = Fcons (Fcons (B, C), A)
444
452
+
 
453
+static repv x_window_or_int_from_id (Window window) {
 
454
+  repv tmp = x_window_from_id (window);
 
455
+  if (tmp == Qnil)
 
456
+    tmp = rep_MAKE_INT (window);
 
457
+  return tmp;
 
458
+}
 
459
+
445
460
+static repv
446
461
+x_encode_event (XEvent *ev)
447
462
+{
448
 
+    repv event = Qnil, data = Qnil, tmp = Qnil;
 
463
+    repv event = Qnil, data = Qnil;
449
464
+
450
465
+    ALIST_PRE (event, Qserial, rep_make_long_uint (ev->xany.serial));
451
466
+    ALIST_PRE (event, Qsend_event, ev->xany.send_event ? Qt : Qnil);
454
469
+    switch (ev->type) {
455
470
+        case KeyPress:
456
471
+        case KeyRelease:
457
 
+            ALIST_PRE (event, Qroot, x_window_from_id (ev->xkey.root));
458
 
+            ALIST_PRE (event, Qsubwindow, x_window_from_id (ev->xkey.subwindow));
 
472
+            ALIST_PRE (event, Qroot, x_window_or_int_from_id (ev->xkey.root));
 
473
+            ALIST_PRE (event, Qsubwindow, x_window_or_int_from_id (ev->xkey.subwindow));
459
474
+            ALIST_PRE (event, Qtime, rep_make_long_uint (ev->xkey.time));
460
475
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xkey.x));
461
476
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xkey.y));
468
483
+          
469
484
+        case ButtonPress:
470
485
+        case ButtonRelease:
471
 
+            ALIST_PRE (event, Qroot, x_window_from_id (ev->xbutton.root));
472
 
+            ALIST_PRE (event, Qsubwindow, x_window_from_id (ev->xbutton.subwindow));
 
486
+            ALIST_PRE (event, Qroot, x_window_or_int_from_id (ev->xbutton.root));
 
487
+            ALIST_PRE (event, Qsubwindow, x_window_or_int_from_id (ev->xbutton.subwindow));
473
488
+            ALIST_PRE (event, Qtime, rep_make_long_uint (ev->xbutton.time));
474
489
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xbutton.x));
475
490
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xbutton.y));
481
496
+            break;
482
497
+            
483
498
+        case MotionNotify:
484
 
+            ALIST_PRE (event, Qroot, x_window_from_id (ev->xmotion.root));
485
 
+            ALIST_PRE (event, Qsubwindow, x_window_from_id (ev->xmotion.subwindow));
 
499
+            ALIST_PRE (event, Qroot, x_window_or_int_from_id (ev->xmotion.root));
 
500
+            ALIST_PRE (event, Qsubwindow, x_window_or_int_from_id (ev->xmotion.subwindow));
486
501
+            ALIST_PRE (event, Qtime, rep_make_long_uint (ev->xmotion.time));
487
502
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xmotion.x));
488
503
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xmotion.y));
495
510
+            
496
511
+        case EnterNotify:
497
512
+        case LeaveNotify:
498
 
+            ALIST_PRE (event, Qroot, x_window_from_id (ev->xcrossing.root));
499
 
+            ALIST_PRE (event, Qsubwindow, x_window_from_id (ev->xcrossing.subwindow));
 
513
+            ALIST_PRE (event, Qroot, x_window_or_int_from_id (ev->xcrossing.root));
 
514
+            ALIST_PRE (event, Qsubwindow, x_window_or_int_from_id (ev->xcrossing.subwindow));
500
515
+            ALIST_PRE (event, Qtime, rep_make_long_uint (ev->xcrossing.time));
501
516
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xcrossing.x));
502
517
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xcrossing.y));
518
533
+            break;
519
534
+            
520
535
+        case DestroyNotify:
521
 
+            ALIST_PRE (event, Qevent, x_window_from_id (ev->xdestroywindow.event));
522
 
+            tmp = x_window_from_id (ev->xdestroywindow.window);
523
 
+            if (tmp == Qnil)
524
 
+                tmp = rep_MAKE_INT (ev->xdestroywindow.window);
525
 
+            ALIST_PRE (event, Qwindow, tmp);
 
536
+            ALIST_PRE (event, Qevent, x_window_or_int_from_id (ev->xdestroywindow.event));
 
537
+            ALIST_PRE (event, Qwindow, x_window_or_int_from_id (ev->xdestroywindow.window));
 
538
+            break;
 
539
+            
 
540
+        case ConfigureNotify:
 
541
+            ALIST_PRE (event, Qevent, x_window_or_int_from_id (ev->xconfigure.event));
 
542
+            ALIST_PRE (event, Qwindow, x_window_or_int_from_id (ev->xconfigure.window));
 
543
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xconfigure.x));
 
544
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xconfigure.y));
 
545
+            ALIST_PRE (event, Qwidth, rep_MAKE_INT (ev->xconfigure.width));
 
546
+            ALIST_PRE (event, Qheight, rep_MAKE_INT (ev->xconfigure.height));
 
547
+            ALIST_PRE (event, Qborder_width, rep_MAKE_INT (ev->xconfigure.border_width));
 
548
+            ALIST_PRE (event, Qabove, x_window_or_int_from_id (ev->xconfigure.above));
 
549
+            ALIST_PRE (event, Qoverride_redirect, ev->xconfigure.override_redirect ? Qt : Qnil);
 
550
+            break;
 
551
+
 
552
+        case ConfigureRequest:
 
553
+            ALIST_PRE (event, Qparent, x_window_or_int_from_id (ev->xconfigurerequest.parent));
 
554
+            ALIST_PRE (event, Qwindow, x_window_or_int_from_id (ev->xconfigurerequest.window));
 
555
+            ALIST_PRE (event, Qx, rep_MAKE_INT (ev->xconfigurerequest.x));
 
556
+            ALIST_PRE (event, Qy, rep_MAKE_INT (ev->xconfigurerequest.y));
 
557
+            ALIST_PRE (event, Qwidth, rep_MAKE_INT (ev->xconfigurerequest.width));
 
558
+            ALIST_PRE (event, Qheight, rep_MAKE_INT (ev->xconfigurerequest.height));
 
559
+            ALIST_PRE (event, Qborder_width, rep_MAKE_INT (ev->xconfigurerequest.border_width));
 
560
+            ALIST_PRE (event, Qabove, x_window_or_int_from_id (ev->xconfigurerequest.above));
 
561
+            ALIST_PRE (event, Qdetail, x_value_match (ev->xconfigurerequest.detail, x_stack_mode_matches));
 
562
+            ALIST_PRE (event, Qvalue_mask, x_valuemask_match (ev->xconfigurerequest.value_mask, x_configure_mask_matches));
526
563
+            break;
527
564
+
528
565
+        case ClientMessage:
558
595
+    not done...
559
596
+    FocusIn FocusOut KeymapNotify GraphicsExpose NoExpose VisibilityNotify
560
597
+    CreateNotify UnmapNotify MapNotify MapRequest ReparentNotify
561
 
+    ConfigureNotify ConfigureRequest GravityNotify ResizeRequest CirculateNotify
 
598
+    ConfigureRequest GravityNotify ResizeRequest CirculateNotify
562
599
+    CirculateRequest PropertyNotify SelectionClear SelectionRequest
563
600
+    SelectionNotify ColormapNotify MappingNotify
564
601
+    */
598
635
+        * zero are silently suppressed. I don't do that because I
599
636
+        * supply the count. Which means that other people's expose
600
637
+        * handlers will be called multiply... */
601
 
+        rep_funcall (VX_DRAWABLE(win)->event_handler, args, rep_FALSE);
 
638
+        if (rep_funcall (VX_DRAWABLE(win)->event_handler, args, rep_FALSE) != Qnil)
 
639
+          return; /* don't call standard event-handler on non-nil result */
602
640
     }
603
641
+    
604
642
+    if (ev->type < LASTEvent && event_handlers[ev->type] != 0)
606
644
 }
607
645
 
608
646
 static Lisp_X_Window *
609
 
@@ -608,10 +1001,37 @@
 
647
@@ -638,10 +1069,37 @@
610
648
     w->height = height;
611
649
     w->is_window = w->is_pixmap = w->is_bitmap = 0;
612
650
     w->event_handler = Qnil;
644
682
 DEFUN ("x-create-window", Fx_create_window, Sx_create_window,
645
683
        (repv xy, repv wh, repv bw, repv attrs, repv ev), rep_Subr5) /*
646
684
 ::doc:sawfish.wm.util.x#x-create-window::
647
 
@@ -619,12 +1039,15 @@
 
685
@@ -649,12 +1107,15 @@
648
686
 
649
687
 Creates a new X-WINDOW with the specified position, dimensions and
650
688
 border width. ATTRS should be a list of cons cells mapping attributes
663
701
     XSetWindowAttributes attributes;
664
702
     long attributesMask;
665
703
     int _x, _y, _w, _h, _bw;
666
 
@@ -636,6 +1059,11 @@
 
704
@@ -666,6 +1127,11 @@
667
705
     rep_DECLARE3 (bw, rep_INTP);
668
706
     rep_DECLARE4 (attrs, rep_LISTP);
669
707
 
675
713
     _x = rep_INT (rep_CAR (xy));
676
714
     _y = rep_INT (rep_CDR (xy));
677
715
     _w = rep_INT (rep_CAR (wh));
678
 
@@ -643,19 +1071,21 @@
 
716
@@ -673,19 +1139,21 @@
679
717
     _bw = rep_INT (bw);
680
718
 
681
719
     attributesMask = x_window_parse_attributes (&attributes, attrs);
693
731
                                              BlackPixel (dpy, screen_num));
694
732
        attributesMask |= CWBorderPixel;
695
733
     }
696
 
-
697
 
-    attributesMask |= CWOverrideRedirect | CWEventMask | CWColormap;
698
734
+    attributes.colormap = image_cmap;
699
735
+    attributesMask |= CWOverrideRedirect;
700
736
 
 
737
-    attributesMask |= CWOverrideRedirect | CWEventMask | CWColormap;
 
738
-
701
739
-    id = XCreateWindow (dpy, root_window, _x, _y, _w, _h, _bw,
702
740
+    id = XCreateWindow (dpy, _parent, _x, _y, _w, _h, _bw,
703
741
                        image_depth, InputOutput, image_visual,
704
742
                        attributesMask, &attributes);
705
743
 
706
 
@@ -708,6 +1138,37 @@
 
744
@@ -738,17 +1206,80 @@
707
745
     return rep_VAL (w);
708
746
 }
709
747
 
741
779
 DEFUN ("x-map-window", Fx_map_window, Sx_map_window,
742
780
        (repv win, repv unraised), rep_Subr2) /*
743
781
 ::doc:sawfish.wm.util.x#x-map-window::
744
 
@@ -722,6 +1183,38 @@
745
 
     return Qt;
746
 
 }
747
 
 
 
782
 x-map-window X-WINDOW [UNRAISED]
 
783
 ::end:: */
 
784
 {
 
785
-    rep_DECLARE1 (win, X_WINDOWP);
 
786
+    rep_DECLARE1 (win, ANY_WINDOWP);
 
787
     if (unraised == Qnil)
 
788
-       XMapRaised (dpy, VX_DRAWABLE (win)->id);
 
789
+       XMapRaised (dpy, window_from_arg (win));
 
790
     else
 
791
-       XMapWindow (dpy, VX_DRAWABLE (win)->id);
 
792
+       XMapWindow (dpy, window_from_arg (win));
 
793
+    return Qt;
 
794
+}
 
795
+
748
796
+DEFUN ("x-x-map-window", Fx_x_map_window, Sx_x_map_window, (repv win), rep_Subr1) /*
749
797
+::doc:sawfish.wm.util.x#x-x-map-window::
750
798
+x-x-map-window X-WINDOW
762
810
+x-map-raised X-WINDOW
763
811
+::end:: */
764
812
+{
765
 
+    rep_DECLARE1(win, X_WINDOWP);
766
 
+    XMapRaised (dpy, VX_DRAWABLE(win)->id);
 
813
+    rep_DECLARE1(win, ANY_WINDOWP);
 
814
+    XMapRaised (dpy, window_from_arg (win));
767
815
+    return Qt;
768
816
+}
769
817
+
772
820
+x-map-subwindows X-WINDOW
773
821
+::end:: */
774
822
+{
775
 
+    rep_DECLARE1(win, X_WINDOWP);
776
 
+    XMapSubwindows (dpy, VX_DRAWABLE(win)->id);
 
823
+    rep_DECLARE1(win, ANY_WINDOWP);
 
824
+    XMapSubwindows (dpy, window_from_arg (win));
 
825
     return Qt;
 
826
 }
 
827
 
 
828
@@ -758,8 +1289,52 @@
 
829
 x-unmap-window X-WINDOW
 
830
 ::end:: */
 
831
 {
 
832
-    rep_DECLARE1 (win, X_WINDOWP);
 
833
-    XUnmapWindow (dpy, VX_DRAWABLE (win)->id);
 
834
+    rep_DECLARE1 (win, ANY_WINDOWP);
 
835
+    XUnmapWindow (dpy, window_from_arg (win));
777
836
+    return Qt;
778
837
+}
779
838
+
780
 
 DEFUN ("x-unmap-window", Fx_unmap_window,
781
 
        Sx_unmap_window, (repv win), rep_Subr1) /*
782
 
 ::doc:sawfish.wm.util.x#x-unmap-window::
783
 
@@ -733,6 +1226,50 @@
784
 
     return Qt;
785
 
 }
786
 
 
787
839
+DEFUN("x-unmap-subwindows", Fx_unmap_subwindows, Sx_unmap_subwindows, (repv win), rep_Subr1) /*
788
840
+::doc:sawfish.wm.util.x#x-unmap-subwindows::
789
841
+x-unmap-subwindows X-WINDOW
790
842
+::end:: */
791
843
+{
792
 
+    rep_DECLARE1(win, X_WINDOWP);
793
 
+    XUnmapSubwindows (dpy, VX_DRAWABLE(win)->id);
 
844
+    rep_DECLARE1(win, ANY_WINDOWP);
 
845
+    XUnmapSubwindows (dpy, window_from_arg (win));
794
846
+    return Qt;
795
847
+}
796
848
+
802
854
+    XWindowChanges changes;
803
855
+    long changesMask;
804
856
+
805
 
+    rep_DECLARE1(window, X_WINDOWP);
 
857
+    rep_DECLARE1(window, ANY_WINDOWP);
806
858
+    rep_DECLARE2(attrs, rep_LISTP);
807
859
+
808
860
+    changesMask = x_window_parse_changes (&changes, attrs);
812
864
+      XEvent fake = { ConfigureRequest };
813
865
+      
814
866
+      fake.xconfigurerequest.display = dpy;
815
 
+      fake.xconfigurerequest.window = VX_DRAWABLE(window)->id;
 
867
+      fake.xconfigurerequest.window = window_from_arg (window);
816
868
+      fake.xconfigurerequest.x = changes.x;
817
869
+      fake.xconfigurerequest.y = changes.y;
818
870
+      fake.xconfigurerequest.width = changes.width;
825
877
+      event_handlers[ConfigureRequest] (&fake);
826
878
+    }
827
879
+
828
 
+    return Qt;
829
 
+}
830
 
+
831
 
 DEFUN ("x-configure-window", Fx_configure_window,
832
 
        Sx_configure_window, (repv window, repv attrs), rep_Subr2) /*
833
 
 ::doc:sawfish.wm.util.x#x-configure-window::
834
 
@@ -740,20 +1277,22 @@
 
880
     return Qt;
 
881
 }
 
882
 
 
883
@@ -770,22 +1345,25 @@
835
884
 
836
885
 Reconfigures the X-WINDOW. ATTRS should be an alist mapping attribute
837
886
 names to values. Known attributes include the symbols `x', `y',
855
904
-       XConfigureWindow (dpy, VX_DRAWABLE (window)->id,
856
905
+       XConfigureWindow (dpy, window_from_arg (window),
857
906
                          changesMask, &changes);
858
 
        x_window_note_changes (VX_DRAWABLE (window), changesMask, &changes);
 
907
-       x_window_note_changes (VX_DRAWABLE (window), changesMask, &changes);
 
908
+        if (X_DRAWABLEP (window))
 
909
+          x_window_note_changes (VX_DRAWABLE (window), changesMask, &changes);
859
910
     }
860
 
@@ -774,20 +1313,118 @@
 
911
 
 
912
     return Qt;
 
913
@@ -804,20 +1382,118 @@
861
914
     XSetWindowAttributes attributes;
862
915
     long attributesMask;
863
916
 
884
937
+The real XRaiseWindow. Raises the X-WINDOW.
885
938
+::end:: */
886
939
+{
887
 
+    rep_DECLARE1(window, X_WINDOWP);
 
940
+    rep_DECLARE1(window, ANY_WINDOWP);
888
941
+
889
 
+    XRaiseWindow (dpy, VX_DRAWABLE(window)->id);
 
942
+    XRaiseWindow (dpy, window_from_arg (window));
890
943
+
891
944
+    return Qt;
892
945
+}
898
951
+The real XLowerWindow. Lowers the X-WINDOW.
899
952
+::end:: */
900
953
+{
901
 
+    rep_DECLARE1(window, X_WINDOWP);
 
954
+    rep_DECLARE1(window, ANY_WINDOWP);
902
955
+
903
 
+    XLowerWindow (dpy, VX_DRAWABLE(window)->id);
 
956
+    XLowerWindow (dpy, window_from_arg (window));
904
957
+
905
958
+    return Qt;
906
959
+}
915
968
+{
916
969
+    int _direction;
917
970
+  
918
 
+    rep_DECLARE1(window, X_WINDOWP);
 
971
+    rep_DECLARE1(window, ANY_WINDOWP);
919
972
+    rep_DECLARE(2, direction, (direction == Qraise_lowest) || (direction == Qlower_highest));
920
973
+    _direction = (direction == Qraise_lowest) ? RaiseLowest : LowerHighest;
921
974
+
922
 
+    XCirculateSubwindows (dpy, VX_DRAWABLE(window)->id, _direction);
 
975
+    XCirculateSubwindows (dpy, window_from_arg (window), _direction);
923
976
+
924
977
+    return Qt;
925
978
+}
931
984
+Circulates up the subwindows of the X-WINDOW.
932
985
+::end:: */
933
986
+{
934
 
+    rep_DECLARE1(window, X_WINDOWP);
 
987
+    rep_DECLARE1(window, ANY_WINDOWP);
935
988
+
936
 
+    XCirculateSubwindowsUp (dpy, VX_DRAWABLE(window)->id);
 
989
+    XCirculateSubwindowsUp (dpy, window_from_arg (window));
937
990
+
938
991
+    return Qt;
939
992
+}
945
998
+Circulates down the subwindows of the X-WINDOW.
946
999
+::end:: */
947
1000
+{
948
 
+    rep_DECLARE1(window, X_WINDOWP);
 
1001
+    rep_DECLARE1(window, ANY_WINDOWP);
949
1002
+
950
 
+    XCirculateSubwindowsDown (dpy, VX_DRAWABLE(window)->id);
 
1003
+    XCirculateSubwindowsDown (dpy, window_from_arg (window));
951
1004
+
952
1005
+    return Qt;
953
1006
+}
967
1020
+    windows = alloca (rep_INT (Flength (list)) * sizeof (Window));
968
1021
+    while (rep_CONSP (list)) {
969
1022
+      if (X_WINDOWP (rep_CAR (list)))
970
 
+        windows[n ++] = VX_DRAWABLE (rep_CAR (list))->id;
 
1023
+        windows[n ++] = window_from_arg (rep_CAR (list));
971
1024
+      list = rep_CDR (list);
972
1025
+    }
973
1026
+    XRestackWindows (dpy, windows, n);
978
1031
 DEFUN ("x-destroy-drawable", Fx_destroy_drawable,
979
1032
        Sx_destroy_drawable, (repv drawable), rep_Subr1) /*
980
1033
 ::doc:sawfish.wm.util.x#x-destroy-drawable::
981
 
@@ -959,6 +1596,268 @@
 
1034
@@ -849,7 +1525,7 @@
 
1035
 Destroys the X-WINDOW.
 
1036
 ::end:: */
 
1037
 {
 
1038
-    return Fx_destroy_drawable (window);
 
1039
+    return Fx_destroy_drawable (window); /* TODO: window_from_arg and below? */
 
1040
 }
 
1041
 
 
1042
 DEFUN ("x-drawable-id", Fx_drawable_id,
 
1043
@@ -989,6 +1665,327 @@
982
1044
 }
983
1045
 
984
1046
 
1051
1113
+    char **_textv;
1052
1114
+    XTextProperty textprop;
1053
1115
+  
1054
 
+    rep_DECLARE1 (window, X_WINDOWP);
 
1116
+    rep_DECLARE1 (window, ANY_WINDOWP);
1055
1117
+    rep_DECLARE2 (textv, rep_VECTORP);
1056
1118
+    n = rep_VECT_LEN (textv);
1057
1119
+    for (i = 0; i < n; ++ i)
1065
1127
+    if (!XStringListToTextProperty (_textv, n, &textprop))
1066
1128
+        return Qnil;
1067
1129
+    
1068
 
+    XSetTextProperty (dpy, VX_DRAWABLE(window)->id, &textprop, _prop);
 
1130
+    XSetTextProperty (dpy, window_from_arg (window), &textprop, _prop);
1069
1131
+    XFree (textprop.value);
1070
1132
+
1071
1133
+    return Qt;
1116
1178
+    repv props = Qnil;
1117
1179
+    int i, n;
1118
1180
+  
1119
 
+    rep_DECLARE1 (window, X_WINDOWP);
 
1181
+    rep_DECLARE1 (window, ANY_WINDOWP);
1120
1182
+
1121
 
+    atoms = XListProperties (dpy, VX_DRAWABLE(window)->id, &n);
 
1183
+    atoms = XListProperties (dpy, window_from_arg (window), &n);
1122
1184
+    if (!atoms)
1123
1185
+      return Qnil;
1124
1186
+    _props = alloca (n * sizeof (char *));
1135
1197
+    return props;
1136
1198
+}
1137
1199
+
1138
 
+static x_str_value x_change_property_mode_matches[] = {
1139
 
+    { "prop-mode-replace", PropModeReplace },
1140
 
+    { "prop-mode-prepend", PropModePrepend },
1141
 
+    { "prop-mode-append", PropModeAppend },
 
1200
+static x_value_str x_change_property_mode_matches[] = {
 
1201
+    { PropModeReplace, "prop-mode-replace" },
 
1202
+    { PropModePrepend, "prop-mode-prepend" },
 
1203
+    { PropModeAppend, "prop-mode-append" },
1142
1204
+    { 0, 0 }
1143
1205
+};
1144
1206
+
1208
1270
+    int n = 0;
1209
1271
+    int _npos;
1210
1272
+
1211
 
+    rep_DECLARE1 (window, X_WINDOWP);
 
1273
+    rep_DECLARE1 (window, ANY_WINDOWP);
1212
1274
+    rep_DECLARE2 (list, rep_LISTP);
1213
1275
+    rep_DECLARE3 (npos, rep_INTP);
1214
1276
+
1220
1282
+        atoms[n ++] = x_symbol_atom (rep_CAR (list));
1221
1283
+      list = rep_CDR (list);
1222
1284
+    }
1223
 
+    XRotateWindowProperties (dpy, VX_DRAWABLE(window)->id, atoms, n, _npos);
 
1285
+    XRotateWindowProperties (dpy, window_from_arg (window), atoms, n, _npos);
1224
1286
+
1225
1287
+    return Qt;
1226
1288
+}
1243
1305
+    return Qt;
1244
1306
+}
1245
1307
+
 
1308
+DEFUN("x-get-window-property", Fx_get_window_property, Sx_get_window_property, (repv args), rep_SubrN) /*
 
1309
+::doc:sawfish.wm.util.x#x-get-window-property::
 
1310
+x-get-window-property X-WINDOW PROPERTY LONG-OFFSET LONG-LENGTH DELETE TYPE
 
1311
+
 
1312
+Gets the specified PROPERTY from the specified X-WINDOW. If
 
1313
+DELETE is non-nil then the property is deleted. The return
 
1314
+is a list (type format bytes-after [value]).
 
1315
+::end:: */
 
1316
+{
 
1317
+    repv window, property, offset, length, delete, type, format, nbytes, data;
 
1318
+    Window _window;
 
1319
+    Atom _property, _type, _ret_type;
 
1320
+    Bool _delete;
 
1321
+    long _offset, _length;
 
1322
+    int _ret_fmt;
 
1323
+    unsigned long _ret_nitems, _ret_nbytes;
 
1324
+    unsigned char *_ret;
 
1325
+    int i, n;
 
1326
+
 
1327
+    /* I'm careless with my ints and longs */
 
1328
+
 
1329
+    nDECLARE (1, window, ANY_WINDOWP (window));
 
1330
+    _window = window_from_arg (window);
 
1331
+    nDECLARE (2, property, rep_SYMBOLP (property));
 
1332
+    _property = x_symbol_atom (property);
 
1333
+    nDECLARE (3, offset, rep_INTP (offset));
 
1334
+    _offset = rep_INT (offset);
 
1335
+    nDECLARE (4, length, rep_INTP (length));
 
1336
+    _length = rep_INT (length);
 
1337
+    nDECLARE (5, delete, 1);
 
1338
+    _delete = delete != Qnil;
 
1339
+    nDECLARE (6, type, rep_SYMBOLP (type));
 
1340
+    _type = x_symbol_atom (type);
 
1341
+
 
1342
+    XGetWindowProperty (dpy, _window, _property, _offset, _length, _delete,
 
1343
+        _type, &_ret_type, &_ret_fmt, &_ret_nitems, &_ret_nbytes, &_ret);
 
1344
+
 
1345
+    type = x_atom_symbol (_ret_type);
 
1346
+    format = rep_MAKE_INT (_ret_fmt);
 
1347
+    nbytes = rep_MAKE_INT (_ret_nbytes);
 
1348
+    n = (int) _ret_nitems;
 
1349
+    data = Fmake_vector (rep_MAKE_INT (n), Qnil);
 
1350
+    for (i = 0; i < n; ++ i) {
 
1351
+      switch (_ret_fmt) {
 
1352
+        case 8:
 
1353
+          rep_VECTI (data, i) = rep_MAKE_INT (_ret[i]);
 
1354
+          break;
 
1355
+        case 16:
 
1356
+          rep_VECTI (data, i) = rep_MAKE_INT (((unsigned short *) _ret)[i]);
 
1357
+          break;
 
1358
+        case 32:
 
1359
+          rep_VECTI (data, i) = rep_MAKE_INT (((unsigned int *) _ret)[i]);
 
1360
+          break;
 
1361
+      }
 
1362
+    }
 
1363
+
 
1364
+    return Fcons (type, Fcons (format, Fcons (nbytes, Fcons (data, Qnil))));
 
1365
+}
 
1366
+
1246
1367
+
1247
1368
 /* Drawing functions */
1248
1369
 
1249
1370
 DEFUN ("x-clear-window", Fx_clear_window,
1250
 
@@ -1425,6 +2324,7 @@
 
1371
@@ -1456,6 +2453,7 @@
1251
1372
 x_window_mark (repv obj)
1252
1373
 {
1253
1374
     rep_MARKVAL (VX_DRAWABLE (obj)->event_handler);
1255
1376
 }
1256
1377
 
1257
1378
 static void
1258
 
@@ -1470,6 +2370,7 @@
 
1379
@@ -1501,6 +2499,7 @@
1259
1380
     rep_ADD_SUBR (Sx_create_root_xor_gc);
1260
1381
     rep_ADD_SUBR (Sx_change_gc);
1261
1382
     rep_ADD_SUBR (Sx_destroy_gc);
1263
1384
     rep_ADD_SUBR (Sx_gc_p);
1264
1385
 
1265
1386
     x_drawable_context = XUniqueContext ();
1266
 
@@ -1479,12 +2380,26 @@
 
1387
@@ -1510,12 +2509,26 @@
1267
1388
                                           x_window_sweep, x_window_mark,
1268
1389
                                           0, 0, 0, 0, 0, 0, 0);
1269
1390
     rep_ADD_SUBR (Sx_create_window);
1290
1411
     rep_ADD_SUBR (Sx_destroy_drawable);
1291
1412
     rep_ADD_SUBR (Sx_destroy_window);
1292
1413
     rep_ADD_SUBR (Sx_drawable_p);
1293
 
@@ -1498,6 +2413,16 @@
 
1414
@@ -1529,6 +2542,17 @@
1294
1415
     rep_ADD_SUBR (Sx_window_back_buffer);
1295
1416
     rep_ADD_SUBR (Sx_window_swap_buffers);
1296
1417
 
1299
1420
+
1300
1421
+    rep_ADD_SUBR (Sx_set_text_property);
1301
1422
+    rep_ADD_SUBR (Sx_get_text_property);
 
1423
+    rep_ADD_SUBR (Sx_get_window_property);
1302
1424
+    rep_ADD_SUBR (Sx_list_properties);
1303
1425
+    rep_ADD_SUBR (Sx_change_property);
1304
1426
+    rep_ADD_SUBR (Sx_rotate_window_properties);
1307
1429
     rep_ADD_SUBR (Sx_clear_window);
1308
1430
     rep_ADD_SUBR (Sx_draw_string);
1309
1431
     rep_ADD_SUBR (Sx_draw_line);
1310
 
@@ -1534,6 +2459,35 @@
 
1432
@@ -1565,6 +2589,37 @@
1311
1433
     rep_INTERN (clip_mask);
1312
1434
     rep_INTERN (clip_x_origin);
1313
1435
     rep_INTERN (clip_y_origin);
1338
1460
+    rep_INTERN (message_type);
1339
1461
+    rep_INTERN (format);
1340
1462
+    rep_INTERN (data);
 
1463
+    rep_INTERN (above);
 
1464
+    rep_INTERN (value_mask);
1341
1465
+    rep_INTERN (raise_lowest);
1342
1466
+    rep_INTERN (lower_highest);
1343
1467