summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/src/kernel/tqcursor_x11.cpp
blob: aac33360765f14f07775059e7f1b80ffbfdf720a (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
/****************************************************************************
**
** Implementation of TQCursor class for X11
**
** Created : 940219
**
** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA.
**
** This file is part of the kernel module of the TQt GUI Toolkit.
**
** This file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the files LICENSE.GPL2
** and LICENSE.GPL3 included in the packaging of this file.
** Alternatively you may (at your option) use any later version
** of the GNU General Public License if such license has been
** publicly approved by Trolltech ASA (or its successors, if any)
** and the KDE Free TQt Foundation.
**
** Please review the following information to ensure GNU General
** Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/.
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** This file may be used under the terms of the Q Public License as
** defined by Trolltech ASA and appearing in the file LICENSE.TQPL
** included in the packaging of this file.  Licensees holding valid TQt
** Commercial licenses may use this file in accordance with the TQt
** Commercial License Agreement provided with the Software.
**
** This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted
** herein.
**
**********************************************************************/

#include "tqcursor.h"
#include "tqbitmap.h"
#include "tqimage.h"
#include "tqapplication.h"
#include "tqdatastream.h"
#include "tqnamespace.h"
#include "tqt_x11_p.h"
#include <X11/cursorfont.h>

#ifndef TQT_NO_XCURSOR
#  include <X11/Xcursor/Xcursor.h>
#endif // TQT_NO_XCURSOR

#ifdef USE_QT4

/*****************************************************************************
  Global cursors
 *****************************************************************************/

static TQCursor cursorTable[TQt::LastCursor+1];

static const int arrowCursorIdx = 0;

TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = cursorTable[0];
TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = cursorTable[1];
TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = cursorTable[2];
TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = cursorTable[3];
TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = cursorTable[4];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = cursorTable[5];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = cursorTable[6];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = cursorTable[7];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = cursorTable[8];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = cursorTable[9];
TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = cursorTable[10];
TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = cursorTable[11];
TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = cursorTable[12];
TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = cursorTable[13];
TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = cursorTable[14];
TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = cursorTable[15];
TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = cursorTable[16];

//     TQT_STATIC_CONST TQCursor & arrowCursor = Qt::ArrowCursor;
//     TQT_STATIC_CONST TQCursor & upArrowCursor = Qt::UpArrowCursor;
//     TQT_STATIC_CONST TQCursor & crossCursor = Qt::CrossCursor;
//     TQT_STATIC_CONST TQCursor & waitCursor = Qt::WaitCursor;
//     TQT_STATIC_CONST TQCursor & ibeamCursor = Qt::IBeamCursor;
//     TQT_STATIC_CONST TQCursor & sizeVerCursor = Qt::SizeVerCursor;
//     TQT_STATIC_CONST TQCursor & sizeHorCursor = Qt::SizeHorCursor;
//     TQT_STATIC_CONST TQCursor & sizeBDiagCursor = Qt::SizeBDiagCursor;
//     TQT_STATIC_CONST TQCursor & sizeFDiagCursor = Qt::SizeFDiagCursor;
//     TQT_STATIC_CONST TQCursor & sizeAllCursor = Qt::SizeAllCursor;
//     TQT_STATIC_CONST TQCursor & blankCursor = Qt::BlankCursor;
//     TQT_STATIC_CONST TQCursor & splitVCursor = Qt::SplitVCursor;
//     TQT_STATIC_CONST TQCursor & splitHCursor = Qt::SplitHCursor;
//     TQT_STATIC_CONST TQCursor & pointingHandCursor = Qt::PointingHandCursor;
//     TQT_STATIC_CONST TQCursor & forbiddenCursor = Qt::ForbiddenCursor;
//     TQT_STATIC_CONST TQCursor & whatsThisCursor = Qt::WhatsThisCursor;
//     TQT_STATIC_CONST TQCursor & busyCursor = Qt::BusyCursor;

// TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = Qt::ArrowCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = Qt::UpArrowCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = Qt::CrossCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = Qt::WaitCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = Qt::IBeamCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = Qt::SizeVerCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = Qt::SizeHorCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = Qt::SizeBDiagCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = Qt::SizeFDiagCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = Qt::SizeAllCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = Qt::BlankCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = Qt::SplitVCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = Qt::SplitHCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = Qt::PointingHandCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = Qt::ForbiddenCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = Qt::WhatsThisCursor;
// TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = Qt::BusyCursor;

/*****************************************************************************
  Internal TQCursorData class
 *****************************************************************************/

// struct TQCursorData : public TQShared
// {
//     TQCursorData( int s = 0 );
//    ~TQCursorData();
//     int	      ctqshape;
//     TQBitmap  *bm, *bmm;
//     short     hx, hy;
//     XColor    fg,bg;
//     Cursor    hcurs;
//     Pixmap    pm, pmm;
// };
// 
// TQCursorData::TQCursorData( int s )
// {
//     ctqshape = s;
//     hcurs = 0;
//     bm = bmm = 0;
//     hx = hy  = 0;
//     pm = pmm = 0;
// }

// TQCursorData::~TQCursorData()
// {
//     Display *dpy = TQPaintDevice::x11AppDisplay();
// 
//     // Add in checking for the display too as on HP-UX
//     // we seem to get a core dump as the cursor data is
//     // deleted again from main() on exit...
//     if ( hcurs && dpy )
// 	XFreeCursor( dpy, hcurs );
//     if ( pm && dpy )
// 	XFreePixmap( dpy, pm );
//     if ( pmm && dpy )
// 	XFreePixmap( dpy, pmm );
//     delete bm;
//     delete bmm;
// }

static bool initialized = FALSE;

/*!
    Internal function that deinitializes the predefined cursors.
    This function is called from the TQApplication destructor.

    \sa initialize()
*/
void TQCursor::cleanup()
{
    if ( !initialized )
	return;

//     int tqshape;
//     for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) {
// 	if ( cursorTable[tqshape].data && cursorTable[tqshape].data->deref() )
// 	    delete cursorTable[tqshape].data;
// 	cursorTable[tqshape].data = 0;
//     }

    initialized = FALSE;
}


/*!
    Internal function that initializes the predefined cursors.
    This function is called from the TQApplication constructor.

    \sa cleanup()
*/

void TQCursor::initialize()
{
//     int tqshape;
//     for( tqshape = 0; tqshape <= LastCursor; tqshape++ )
// 	cursorTable[tqshape].data = new TQCursorData( tqshape );
//     initialized = TRUE;
//     qAddPostRoutine( cleanup );

    int tqshape;
    for( tqshape = 0; tqshape <= TQt::LastCursor; tqshape++ ) {
        switch(tqshape) {
	   case  0: new(&cursorTable[tqshape]) TQCursor(Qt::ArrowCursor);		break;
	   case  1: new(&cursorTable[tqshape]) TQCursor(Qt::UpArrowCursor);		break;
	   case  2: new(&cursorTable[tqshape]) TQCursor(Qt::CrossCursor);		break;
	   case  3: new(&cursorTable[tqshape]) TQCursor(Qt::WaitCursor);		break;
	   case  4: new(&cursorTable[tqshape]) TQCursor(Qt::IBeamCursor);		break;
	   case  5: new(&cursorTable[tqshape]) TQCursor(Qt::SizeVerCursor);		break;
	   case  6: new(&cursorTable[tqshape]) TQCursor(Qt::SizeHorCursor);		break;
	   case  7: new(&cursorTable[tqshape]) TQCursor(Qt::SizeBDiagCursor);		break;
	   case  8: new(&cursorTable[tqshape]) TQCursor(Qt::SizeFDiagCursor);		break;
	   case  9: new(&cursorTable[tqshape]) TQCursor(Qt::SizeAllCursor);		break;
	   case 10: new(&cursorTable[tqshape]) TQCursor(Qt::BlankCursor);		break;
	   case 11: new(&cursorTable[tqshape]) TQCursor(Qt::SplitVCursor);		break;
	   case 12: new(&cursorTable[tqshape]) TQCursor(Qt::SplitHCursor);		break;
	   case 13: new(&cursorTable[tqshape]) TQCursor(Qt::PointingHandCursor);	break;
	   case 14: new(&cursorTable[tqshape]) TQCursor(Qt::ForbiddenCursor);		break;
	   case 15: new(&cursorTable[tqshape]) TQCursor(Qt::WhatsThisCursor);		break;
	   case 16: new(&cursorTable[tqshape]) TQCursor(Qt::BusyCursor);		break;
	   case 17: new(&cursorTable[tqshape]) TQCursor(Qt::OpenHandCursor);		break;
	   case 18: new(&cursorTable[tqshape]) TQCursor(Qt::ClosedHandCursor);		break;
	   case 19: new(&cursorTable[tqshape]) TQCursor(Qt::DragCopyCursor);		break;
	   case 20: new(&cursorTable[tqshape]) TQCursor(Qt::DragMoveCursor);		break;
	   case 21: new(&cursorTable[tqshape]) TQCursor(Qt::DragLinkCursor);		break;
        }
    }
    initialized = TRUE;
    qAddPostRoutine( cleanup );
}

#else // USE_QT4

// Define TQT_USE_APPROXIMATE_CURSORS when compiling if you REALLY want to
// use the ugly X11 cursors.

/*****************************************************************************
  Internal TQCursorData class
 *****************************************************************************/

struct TQCursorData : public TQShared
{
    TQCursorData( int s = 0 );
   ~TQCursorData();
    int	      ctqshape;
    TQBitmap  *bm, *bmm;
    short     hx, hy;
    XColor    fg,bg;
    Cursor    hcurs;
    Pixmap    pm, pmm;
};

TQCursorData::TQCursorData( int s )
{
    ctqshape = s;
    hcurs = 0;
    bm = bmm = 0;
    hx = hy  = 0;
    pm = pmm = 0;
}

TQCursorData::~TQCursorData()
{
    Display *dpy = TQPaintDevice::x11AppDisplay();

    // Add in checking for the display too as on HP-UX
    // we seem to get a core dump as the cursor data is
    // deleted again from main() on exit...
    if ( hcurs && dpy )
	XFreeCursor( dpy, hcurs );
    if ( pm && dpy )
	XFreePixmap( dpy, pm );
    if ( pmm && dpy )
	XFreePixmap( dpy, pmm );
    delete bm;
    delete bmm;
}


/*****************************************************************************
  Global cursors
 *****************************************************************************/

static TQCursor cursorTable[TQt::LastCursor+1];

static const int arrowCursorIdx = 0;

TQT_STATIC_CONST_IMPL TQCursor & TQt::arrowCursor = cursorTable[0];
TQT_STATIC_CONST_IMPL TQCursor & TQt::upArrowCursor = cursorTable[1];
TQT_STATIC_CONST_IMPL TQCursor & TQt::crossCursor = cursorTable[2];
TQT_STATIC_CONST_IMPL TQCursor & TQt::waitCursor = cursorTable[3];
TQT_STATIC_CONST_IMPL TQCursor & TQt::ibeamCursor = cursorTable[4];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeVerCursor = cursorTable[5];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeHorCursor = cursorTable[6];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeBDiagCursor = cursorTable[7];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeFDiagCursor = cursorTable[8];
TQT_STATIC_CONST_IMPL TQCursor & TQt::sizeAllCursor = cursorTable[9];
TQT_STATIC_CONST_IMPL TQCursor & TQt::blankCursor = cursorTable[10];
TQT_STATIC_CONST_IMPL TQCursor & TQt::splitVCursor = cursorTable[11];
TQT_STATIC_CONST_IMPL TQCursor & TQt::splitHCursor = cursorTable[12];
TQT_STATIC_CONST_IMPL TQCursor & TQt::pointingHandCursor = cursorTable[13];
TQT_STATIC_CONST_IMPL TQCursor & TQt::forbiddenCursor = cursorTable[14];
TQT_STATIC_CONST_IMPL TQCursor & TQt::whatsThisCursor = cursorTable[15];
TQT_STATIC_CONST_IMPL TQCursor & TQt::busyCursor = cursorTable[16];


TQCursor *TQCursor::find_cur( int tqshape )		// find predefined cursor
{
    return (uint)tqshape <= LastCursor ? &cursorTable[tqshape] : 0;
}


static bool initialized = FALSE;

/*!
    Internal function that deinitializes the predefined cursors.
    This function is called from the TQApplication destructor.

    \sa initialize()
*/
void TQCursor::cleanup()
{
    if ( !initialized )
	return;

    int tqshape;
    for( tqshape = 0; tqshape <= LastCursor; tqshape++ ) {
	if ( cursorTable[tqshape].data && cursorTable[tqshape].data->deref() )
	    delete cursorTable[tqshape].data;
	cursorTable[tqshape].data = 0;
    }
    initialized = FALSE;
}


/*!
    Internal function that initializes the predefined cursors.
    This function is called from the TQApplication constructor.

    \sa cleanup()
*/

void TQCursor::initialize()
{
    int tqshape;
    for( tqshape = 0; tqshape <= LastCursor; tqshape++ )
	cursorTable[tqshape].data = new TQCursorData( tqshape );
    initialized = TRUE;
    qAddPostRoutine( cleanup );
}


/*!
    Constructs a cursor with the default arrow tqshape.
*/
TQCursor::TQCursor()
{
    if ( !initialized ) {
	if ( tqApp->startingUp() ) {
	    data = 0;
	    return;
	}
	initialize();
    }
    TQCursor* c = &cursorTable[arrowCursorIdx];
    c->data->ref();
    data = c->data;
}



/*!
    Constructs a cursor with the specified \a tqshape.

    See \l tqCursorShape for a list of tqshapes.

    \sa setShape()
*/

TQCursor::TQCursor( int tqshape )
{
    if ( !initialized )
	initialize();
    TQCursor *c = find_cur( tqshape );
    if ( !c )					// not found
	c = &cursorTable[arrowCursorIdx];	//   then use arrowCursor
    c->data->ref();
    data = c->data;
}

/*!
    Constructs a cursor from the window system cursor \a cursor.

    \warning Using this function is not portable. This function is only
    available on X11 and Windows.
*/
TQCursor::TQCursor( HANDLE cursor )
{
    if ( !initialized )
	initialize();

    data = new TQCursorData;
    TQ_CHECK_PTR( data );
    data->hcurs = cursor;
}



void TQCursor::setBitmap( const TQBitmap &bitmap, const TQBitmap &tqmask,
			 int hotX, int hotY )
{
    if ( !initialized )
	initialize();
    if ( bitmap.depth() != 1 || tqmask.depth() != 1 ||
	 bitmap.size() != tqmask.size() ) {
#if defined(TQT_CHECK_NULL)
	qWarning( "TQCursor: Cannot create bitmap cursor; invalid bitmap(s)" );
#endif
	TQCursor *c = &cursorTable[arrowCursorIdx];
	c->data->ref();
	data = c->data;
	return;
    }
    data = new TQCursorData;
    TQ_CHECK_PTR( data );
    data->bm  = new TQBitmap( bitmap );
    data->bmm = new TQBitmap( tqmask );
    data->hcurs = 0;
    data->ctqshape = BitmapCursor;
    data->hx = hotX >= 0 ? hotX : bitmap.width()/2;
    data->hy = hotY >= 0 ? hotY : bitmap.height()/2;
    data->fg.red   = 0 << 8;
    data->fg.green = 0 << 8;
    data->fg.blue  = 0 << 8;
    data->bg.red   = 255 << 8;
    data->bg.green = 255 << 8;
    data->bg.blue  = 255 << 8;
    update(); // Xcursor's backward compatibility hack needs the cursor to be created
              // right after the bitmaps are created and filled with data
}


/*!
    Constructs a copy of the cursor \a c.
*/

TQCursor::TQCursor( const TQCursor &c )
{
    if ( !initialized )
	initialize();
    data = c.data;				// shallow copy
    data->ref();
}

/*!
    Destroys the cursor.
*/

TQCursor::~TQCursor()
{
    if ( data && data->deref() )
	delete data;
}


/*!
    Assigns \a c to this cursor and returns a reference to this
    cursor.
*/

TQCursor &TQCursor::operator=( const TQCursor &c )
{
    if ( !initialized )
	initialize();
    c.data->ref();				// avoid c = c
    if ( data->deref() )
	delete data;
    data = c.data;
    return *this;
}


/*!
    Returns the cursor tqshape identifier. The return value is one of
    the \l tqCursorShape enum values (cast to an int).

    \sa setShape()
*/

int TQCursor::tqshape() const
{
    if ( !initialized )
	initialize();
    return data->ctqshape;
}

/*!
    Sets the cursor to the tqshape identified by \a tqshape.

    See \l tqCursorShape for the list of cursor tqshapes.

    \sa tqshape()
*/

void TQCursor::setShape( int tqshape )
{
    if ( !initialized )
	initialize();
    TQCursor *c = find_cur( tqshape );		// find one of the global ones
    if ( !c )					// not found
	c = &cursorTable[arrowCursorIdx];	//   then use arrowCursor
    c->data->ref();
    if ( data->deref() )			// make shallow copy
	delete data;
    data = c->data;
}


/*!
    Returns the cursor bitmap, or 0 if it is one of the standard
    cursors.
*/
const TQBitmap *TQCursor::bitmap() const
{
    if ( !initialized )
	initialize();
    return data->bm;
}

/*!
    Returns the cursor bitmap tqmask, or 0 if it is one of the standard
    cursors.
*/

const TQBitmap *TQCursor::tqmask() const
{
    if ( !initialized )
	initialize();
    return data->bmm;
}

/*!
    Returns the cursor hot spot, or (0, 0) if it is one of the
    standard cursors.
*/

TQPoint TQCursor::hotSpot() const
{
    if ( !initialized )
	initialize();
    return TQPoint( data->hx, data->hy );
}


/*!
    Returns the window system cursor handle.

    \warning
    Portable in principle, but if you use it you are probably about to
    do something non-portable. Be careful.
*/

TQt::HANDLE TQCursor::handle() const
{
    if ( !initialized )
	initialize();
    if ( !data->hcurs )
	update();
    return data->hcurs;
}

/*!
    \fn TQCursor::TQCursor( HCURSOR handle )

    Creates a cursor with the specified window system handle \a
    handle.

    \warning
    Portable in principle, but if you use it you are probably about to
    do something non-portable. Be careful.
*/

/*!
    Returns the position of the cursor (hot spot) in global screen
    coordinates.

    You can call TQWidget::mapFromGlobal() to translate it to widget
    coordinates.

    \sa setPos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal()
*/
TQPoint TQCursor::pos()
{
    Window root;
    Window child;
    int root_x, root_y, win_x, win_y;
    uint buttons;
    Display* dpy = TQPaintDevice::x11AppDisplay();
    for ( int i = 0; i < ScreenCount( dpy ); i++ ) {
	if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child,
			    &root_x, &root_y, &win_x, &win_y, &buttons ) )

	    return TQPoint( root_x, root_y );
    }
    return TQPoint();
}

/*! \internal
*/
int TQCursor::x11Screen()
{
    Window root;
    Window child;
    int root_x, root_y, win_x, win_y;
    uint buttons;
    Display* dpy = TQPaintDevice::x11AppDisplay();
    for ( int i = 0; i < ScreenCount( dpy ); i++ ) {
	if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( i ), &root, &child,
			    &root_x, &root_y, &win_x, &win_y, &buttons ) )
	    return i;
    }
    return -1;
}

/*!
    Moves the cursor (hot spot) to the global screen position (\a x,
    \a y).

    You can call TQWidget::mapToGlobal() to translate widget
    coordinates to global screen coordinates.

    \sa pos(), TQWidget::mapFromGlobal(), TQWidget::mapToGlobal()
*/

void TQCursor::setPos( int x, int y )
{
    TQPoint current, target(x, y);

    // this is copied from pos(), since we need the screen number for the correct
    // root window in the XWarpPointer call
    Window root;
    Window child;
    int root_x, root_y, win_x, win_y;
    uint buttons;
    Display* dpy = TQPaintDevice::x11AppDisplay();
    int screen;
    for ( screen = 0; screen < ScreenCount( dpy ); screen++ ) {
	if ( XQueryPointer( dpy, TQPaintDevice::x11AppRootWindow( screen ), &root, &child,
			    &root_x, &root_y, &win_x, &win_y, &buttons ) ) {
	    current = TQPoint( root_x, root_y );
	    break;
	}
    }

    if ( screen >= ScreenCount( dpy ) )
	return;

    // Need to check, since some X servers generate null mouse move
    // events, causing looping in applications which call setPos() on
    // every mouse move event.
    //
    if ( current == target )
	return;

    XWarpPointer( TQPaintDevice::x11AppDisplay(), None,
		  TQPaintDevice::x11AppRootWindow( screen ),
		  0, 0, 0, 0, x, y );
}

/*!
    \overload void TQCursor::setPos ( const TQPoint & )
*/


/*!
    \internal

    Creates the cursor.
*/

void TQCursor::update() const
{
    if ( !initialized )
	initialize();
    register TQCursorData *d = data;		// cheat const!
    if ( d->hcurs )				// already loaded
	return;

    Display *dpy = TQPaintDevice::x11AppDisplay();
    Window rootwin = TQPaintDevice::x11AppRootWindow();

    if ( d->ctqshape == BitmapCursor ) {
	d->hcurs = XCreatePixmapCursor( dpy, d->bm->handle(), d->bmm->handle(),
					&d->fg, &d->bg, d->hx, d->hy );
	return;
    }

#ifndef TQT_NO_XCURSOR
    static const char *cursorNames[] = {
	"left_ptr",
	"up_arrow",
	"cross",
	"wait",
	"ibeam",
	"size_ver",
	"size_hor",
	"size_bdiag",
	"size_fdiag",
	"size_all",
	"blank",
	"split_v",
	"split_h",
	"pointing_hand",
	"forbidden",
	"whats_this",
	"left_ptr_watch"
    };

    d->hcurs = XcursorLibraryLoadCursor( dpy, cursorNames[d->ctqshape] );
    if ( d->hcurs )
	return;
#endif // TQT_NO_XCURSOR

    static uchar cur_blank_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

    // Non-standard X11 cursors are created from bitmaps

#ifndef TQT_USE_APPROXIMATE_CURSORS
    static const uchar cur_ver_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
	0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
	0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
    static const uchar mcur_ver_bits[] = {
	0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
	0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
	0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
    static const uchar cur_hor_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
	0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar mcur_hor_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
	0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
	0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
    static const uchar cur_bdiag_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
	0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
	0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar mcur_bdiag_bits[] = {
	0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
	0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
	0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
    static const uchar cur_fdiag_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
	0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
	0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
    static const uchar mcur_fdiag_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
	0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
	0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
    static const uchar *cursor_bits16[] = {
	cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits,
	cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits,
	0, 0, cur_blank_bits, cur_blank_bits };

    static const uchar vsplit_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
	0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
	0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
	0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
	0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
	0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar vsplitm_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
	0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
	0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
	0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
	0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
	0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
	0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
	0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar hsplit_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
	0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
	0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
	0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
	0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
	0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar hsplitm_bits[] = {
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
	0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
	0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
	0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
	0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
	0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar whatsthis_bits[] = {
        0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
        0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
        0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
        0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
        0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
        0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
        0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
    static const uchar whatsthism_bits[] = {
        0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
        0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
        0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
        0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
        0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
        0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
        0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
    static const uchar busy_bits[] = {
	0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
	0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
	0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
	0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
	0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
	0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
	0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
	0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    static const uchar busym_bits[] = {
	0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
	0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
	0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
	0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
	0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
	0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
	0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
	0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    static const uchar * const cursor_bits32[] = {
	vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
	0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits
    };

    static const uchar forbidden_bits[] = {
	0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
	0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
	0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
	0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };

    static const unsigned char forbiddenm_bits[] = {
	0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
	0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
	0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
	0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};

    static const uchar * const cursor_bits20[] = {
	forbidden_bits, forbiddenm_bits
    };

    if ( d->ctqshape >= SizeVerCursor && d->ctqshape < SizeAllCursor ||
	 d->ctqshape == BlankCursor ) {
	XColor bg, fg;
	bg.red   = 255 << 8;
	bg.green = 255 << 8;
	bg.blue  = 255 << 8;
	fg.red   = 0;
	fg.green = 0;
	fg.blue  = 0;
	int i = (d->ctqshape - SizeVerCursor)*2;
	d->pm  = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i],
					16, 16 );
	d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits16[i+1],
					16,16);
	d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 8, 8 );
	return;
    }
    if ( ( d->ctqshape >= SplitVCursor && d->ctqshape <= SplitHCursor ) ||
         d->ctqshape == WhatsThisCursor || d->ctqshape == BusyCursor ) {
	XColor bg, fg;
	bg.red   = 255 << 8;
	bg.green = 255 << 8;
	bg.blue  = 255 << 8;
	fg.red   = 0;
	fg.green = 0;
	fg.blue  = 0;
	int i = (d->ctqshape - SplitVCursor)*2;
	d->pm  = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i],
					32, 32 );
	d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits32[i+1],
					32, 32);
	int hs = ( d->ctqshape == PointingHandCursor ||
		   d->ctqshape == WhatsThisCursor ||
		   d->ctqshape == BusyCursor ) ? 0 : 16;
	d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, hs, hs );
	return;
    }
    if ( d->ctqshape == ForbiddenCursor ) {
	XColor bg, fg;
	bg.red   = 255 << 8;
	bg.green = 255 << 8;
	bg.blue  = 255 << 8;
	fg.red   = 0;
	fg.green = 0;
	fg.blue  = 0;
	int i = (d->ctqshape - ForbiddenCursor)*2;
	d->pm  = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i],
					20, 20 );
	d->pmm = XCreateBitmapFromData( dpy, rootwin, (char *)cursor_bits20[i+1],
					20, 20);
	d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg, &bg, 10, 10 );
	return;
    }
#endif /* ! TQT_USE_APPROXIMATE_CURSORS */

    uint sh;
    switch ( d->ctqshape ) {			// map Q cursor to X cursor
    case ArrowCursor:
	sh = XC_left_ptr;
	break;
    case UpArrowCursor:
	sh = XC_center_ptr;
	break;
    case CrossCursor:
	sh = XC_crosshair;
	break;
    case WaitCursor:
	sh = XC_watch;
	break;
    case IbeamCursor:
	sh = XC_xterm;
	break;
    case SizeAllCursor:
	sh = XC_fleur;
	break;
    case PointingHandCursor:
	sh = XC_hand2;
	break;
#ifdef TQT_USE_APPROXIMATE_CURSORS
    case SizeBDiagCursor:
	sh = XC_top_right_corner;
	break;
    case SizeFDiagCursor:
	sh = XC_bottom_right_corner;
	break;
    case BlankCursor:
	XColor bg, fg;
	bg.red   = 255 << 8;
	bg.green = 255 << 8;
	bg.blue  = 255 << 8;
	fg.red   = 0;
	fg.green = 0;
	fg.blue  = 0;
	d->pm  = XCreateBitmapFromData( dpy, rootwin,
					(char *)cur_blank_bits, 16, 16 );
	d->pmm = XCreateBitmapFromData( dpy, rootwin,
					(char *)cur_blank_bits, 16,16);
	d->hcurs = XCreatePixmapCursor( dpy, d->pm, d->pmm, &fg,
					&bg, 8, 8 );
	return;
	break;
    case SizeVerCursor:
    case SplitVCursor:
	sh = XC_sb_v_double_arrow;
	break;
    case SizeHorCursor:
    case SplitHCursor:
	sh = XC_sb_h_double_arrow;
	break;
    case WhatsThisCursor:
	sh = XC_question_arrow;
	break;
    case ForbiddenCursor:
	sh = XC_circle;
	break;
    case BusyCursor:
	sh = XC_watch;
	break;
#endif /* TQT_USE_APPROXIMATE_CURSORS */
    default:
#if defined(TQT_CHECK_RANGE)
	qWarning( "TQCursor::update: Invalid cursor tqshape %d", d->ctqshape );
#endif
	return;
    }
    d->hcurs = XCreateFontCursor( dpy, sh );
}

#endif // USE_QT4