2 * X11 graphics driver graphics functions
4 * Copyright 1993,1994 Alexandre Julliard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * FIXME: only some of these functions obey the GM_ADVANCED
37 #include <X11/Intrinsic.h>
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(graphics
);
45 #define ABS(x) ((x)<0?(-(x)):(x))
47 /* ROP code to GC function conversion */
48 const int X11DRV_XROPfunction
[16] =
50 GXclear
, /* R2_BLACK */
51 GXnor
, /* R2_NOTMERGEPEN */
52 GXandInverted
, /* R2_MASKNOTPEN */
53 GXcopyInverted
, /* R2_NOTCOPYPEN */
54 GXandReverse
, /* R2_MASKPENNOT */
55 GXinvert
, /* R2_NOT */
56 GXxor
, /* R2_XORPEN */
57 GXnand
, /* R2_NOTMASKPEN */
58 GXand
, /* R2_MASKPEN */
59 GXequiv
, /* R2_NOTXORPEN */
61 GXorInverted
, /* R2_MERGENOTPEN */
62 GXcopy
, /* R2_COPYPEN */
63 GXorReverse
, /* R2_MERGEPENNOT */
64 GXor
, /* R2_MERGEPEN */
69 /***********************************************************************
70 * X11DRV_SetupGCForPatBlt
72 * Setup the GC for a PatBlt operation using current brush.
73 * If fMapColors is TRUE, X pixels are mapped to Windows colors.
74 * Return FALSE if brush is BS_NULL, TRUE otherwise.
76 BOOL
X11DRV_SetupGCForPatBlt( X11DRV_PDEVICE
*physDev
, GC gc
, BOOL fMapColors
)
83 if (physDev
->brush
.style
== BS_NULL
) return FALSE
;
84 if (physDev
->brush
.pixel
== -1)
86 /* Special case used for monochrome pattern brushes.
87 * We need to swap foreground and background because
88 * Windows does it the wrong way...
90 val
.foreground
= physDev
->backgroundPixel
;
91 val
.background
= physDev
->textPixel
;
95 val
.foreground
= physDev
->brush
.pixel
;
96 val
.background
= physDev
->backgroundPixel
;
98 if (fMapColors
&& X11DRV_PALETTE_XPixelToPalette
)
100 val
.foreground
= X11DRV_PALETTE_XPixelToPalette
[val
.foreground
];
101 val
.background
= X11DRV_PALETTE_XPixelToPalette
[val
.background
];
104 val
.function
= X11DRV_XROPfunction
[GetROP2(physDev
->hdc
)-1];
106 ** Let's replace GXinvert by GXxor with (black xor white)
107 ** This solves the selection color and leak problems in excel
108 ** FIXME : Let's do that only if we work with X-pixels, not with Win-pixels
110 if (val
.function
== GXinvert
)
112 val
.foreground
= (WhitePixel( gdi_display
, DefaultScreen(gdi_display
) ) ^
113 BlackPixel( gdi_display
, DefaultScreen(gdi_display
) ));
114 val
.function
= GXxor
;
116 val
.fill_style
= physDev
->brush
.fillStyle
;
117 switch(val
.fill_style
)
120 case FillOpaqueStippled
:
121 if (GetBkMode(physDev
->hdc
)==OPAQUE
) val
.fill_style
= FillOpaqueStippled
;
122 val
.stipple
= physDev
->brush
.pixmap
;
127 if (fMapColors
&& X11DRV_PALETTE_XPixelToPalette
)
132 pixmap
= XCreatePixmap( gdi_display
, root_window
, 8, 8, screen_depth
);
133 image
= XGetImage( gdi_display
, physDev
->brush
.pixmap
, 0, 0, 8, 8,
134 AllPlanes
, ZPixmap
);
135 for (y
= 0; y
< 8; y
++)
136 for (x
= 0; x
< 8; x
++)
137 XPutPixel( image
, x
, y
,
138 X11DRV_PALETTE_XPixelToPalette
[XGetPixel( image
, x
, y
)] );
139 XPutImage( gdi_display
, pixmap
, gc
, image
, 0, 0, 0, 0, 8, 8 );
140 XDestroyImage( image
);
144 else val
.tile
= physDev
->brush
.pixmap
;
152 GetBrushOrgEx( physDev
->hdc
, &pt
);
153 val
.ts_x_origin
= physDev
->org
.x
+ pt
.x
;
154 val
.ts_y_origin
= physDev
->org
.y
+ pt
.y
;
155 val
.fill_rule
= (GetPolyFillMode(physDev
->hdc
) == WINDING
) ? WindingRule
: EvenOddRule
;
157 XChangeGC( gdi_display
, gc
,
158 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
159 GCFillRule
| GCTileStipXOrigin
| GCTileStipYOrigin
| mask
,
161 if (pixmap
) XFreePixmap( gdi_display
, pixmap
);
167 /***********************************************************************
168 * X11DRV_SetupGCForBrush
170 * Setup physDev->gc for drawing operations using current brush.
171 * Return FALSE if brush is BS_NULL, TRUE otherwise.
173 BOOL
X11DRV_SetupGCForBrush( X11DRV_PDEVICE
*physDev
)
175 return X11DRV_SetupGCForPatBlt( physDev
, physDev
->gc
, FALSE
);
179 /***********************************************************************
180 * X11DRV_SetupGCForPen
182 * Setup physDev->gc for drawing operations using current pen.
183 * Return FALSE if pen is PS_NULL, TRUE otherwise.
185 BOOL
X11DRV_SetupGCForPen( X11DRV_PDEVICE
*physDev
)
188 UINT rop2
= GetROP2(physDev
->hdc
);
190 if (physDev
->pen
.style
== PS_NULL
) return FALSE
;
195 val
.foreground
= BlackPixel( gdi_display
, DefaultScreen(gdi_display
) );
196 val
.function
= GXcopy
;
199 val
.foreground
= WhitePixel( gdi_display
, DefaultScreen(gdi_display
) );
200 val
.function
= GXcopy
;
203 val
.foreground
= physDev
->pen
.pixel
;
204 /* It is very unlikely someone wants to XOR with 0 */
205 /* This fixes the rubber-drawings in paintbrush */
206 if (val
.foreground
== 0)
207 val
.foreground
= (WhitePixel( gdi_display
, DefaultScreen(gdi_display
) ) ^
208 BlackPixel( gdi_display
, DefaultScreen(gdi_display
) ));
209 val
.function
= GXxor
;
212 val
.foreground
= physDev
->pen
.pixel
;
213 val
.function
= X11DRV_XROPfunction
[rop2
-1];
215 val
.background
= physDev
->backgroundPixel
;
216 val
.fill_style
= FillSolid
;
217 val
.line_width
= physDev
->pen
.width
;
218 if (val
.line_width
<= 1) {
219 val
.cap_style
= CapNotLast
;
221 switch (physDev
->pen
.endcap
)
223 case PS_ENDCAP_SQUARE
:
224 val
.cap_style
= CapProjecting
;
227 val
.cap_style
= CapButt
;
229 case PS_ENDCAP_ROUND
:
231 val
.cap_style
= CapRound
;
234 switch (physDev
->pen
.linejoin
)
237 val
.join_style
= JoinBevel
;
240 val
.join_style
= JoinMiter
;
244 val
.join_style
= JoinRound
;
247 if ((physDev
->pen
.width
<= 1) &&
248 (physDev
->pen
.style
!= PS_SOLID
) &&
249 (physDev
->pen
.style
!= PS_INSIDEFRAME
))
251 XSetDashes( gdi_display
, physDev
->gc
, 0, physDev
->pen
.dashes
, physDev
->pen
.dash_len
);
252 val
.line_style
= (GetBkMode(physDev
->hdc
) == OPAQUE
) ? LineDoubleDash
: LineOnOffDash
;
254 else val
.line_style
= LineSolid
;
256 XChangeGC( gdi_display
, physDev
->gc
,
257 GCFunction
| GCForeground
| GCBackground
| GCLineWidth
|
258 GCLineStyle
| GCCapStyle
| GCJoinStyle
| GCFillStyle
, &val
);
264 /***********************************************************************
265 * X11DRV_SetupGCForText
267 * Setup physDev->gc for text drawing operations.
268 * Return FALSE if the font is null, TRUE otherwise.
270 BOOL
X11DRV_SetupGCForText( X11DRV_PDEVICE
*physDev
)
272 XFontStruct
* xfs
= XFONT_GetFontStruct( physDev
->font
);
278 val
.function
= GXcopy
; /* Text is always GXcopy */
279 val
.foreground
= physDev
->textPixel
;
280 val
.background
= physDev
->backgroundPixel
;
281 val
.fill_style
= FillSolid
;
285 XChangeGC( gdi_display
, physDev
->gc
,
286 GCFunction
| GCForeground
| GCBackground
| GCFillStyle
|
291 WARN("Physical font failure\n" );
295 /***********************************************************************
298 * Performs a world-to-viewport transformation on the specified width.
300 INT
X11DRV_XWStoDS( X11DRV_PDEVICE
*physDev
, INT width
)
308 LPtoDP( physDev
->hdc
, pt
, 2 );
309 return pt
[1].x
- pt
[0].x
;
312 /***********************************************************************
315 * Performs a world-to-viewport transformation on the specified height.
317 INT
X11DRV_YWStoDS( X11DRV_PDEVICE
*physDev
, INT height
)
325 LPtoDP( physDev
->hdc
, pt
, 2 );
326 return pt
[1].y
- pt
[0].y
;
329 /***********************************************************************
333 X11DRV_LineTo( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
337 if (X11DRV_SetupGCForPen( physDev
)) {
338 /* Update the pixmap from the DIB section */
339 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
341 GetCurrentPositionEx( physDev
->hdc
, &pt
[0] );
344 LPtoDP( physDev
->hdc
, pt
, 2 );
347 XDrawLine(gdi_display
, physDev
->drawable
, physDev
->gc
,
348 physDev
->org
.x
+ pt
[0].x
, physDev
->org
.y
+ pt
[0].y
,
349 physDev
->org
.x
+ pt
[1].x
, physDev
->org
.y
+ pt
[1].y
);
352 /* Update the DIBSection from the pixmap */
353 X11DRV_UnlockDIBSection(physDev
, TRUE
);
360 /***********************************************************************
363 * Helper functions for Arc(), Chord() and Pie().
364 * 'lines' is the number of lines to draw: 0 for Arc, 1 for Chord, 2 for Pie.
368 X11DRV_DrawArc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
369 INT bottom
, INT xstart
, INT ystart
,
370 INT xend
, INT yend
, INT lines
)
372 INT xcenter
, ycenter
, istart_angle
, idiff_angle
;
374 double start_angle
, end_angle
;
380 SetRect(&rc
, left
, top
, right
, bottom
);
385 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
386 LPtoDP(physDev
->hdc
, &start
, 1);
387 LPtoDP(physDev
->hdc
, &end
, 1);
389 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
390 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
391 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)
392 ||(lines
&& ((rc
.right
-rc
.left
==1)||(rc
.bottom
-rc
.top
==1)))) return TRUE
;
394 if (GetArcDirection( physDev
->hdc
) == AD_CLOCKWISE
)
395 { POINT tmp
= start
; start
= end
; end
= tmp
; }
397 oldwidth
= width
= physDev
->pen
.width
;
398 if (!width
) width
= 1;
399 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
401 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
403 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
404 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
405 rc
.left
+= width
/ 2;
406 rc
.right
-= (width
- 1) / 2;
408 rc
.bottom
-= (width
- 1) / 2;
410 if(width
== 0) width
= 1; /* more accurate */
411 physDev
->pen
.width
= width
;
413 xcenter
= (rc
.right
+ rc
.left
) / 2;
414 ycenter
= (rc
.bottom
+ rc
.top
) / 2;
415 start_angle
= atan2( (double)(ycenter
-start
.y
)*(rc
.right
-rc
.left
),
416 (double)(start
.x
-xcenter
)*(rc
.bottom
-rc
.top
) );
417 end_angle
= atan2( (double)(ycenter
-end
.y
)*(rc
.right
-rc
.left
),
418 (double)(end
.x
-xcenter
)*(rc
.bottom
-rc
.top
) );
419 if ((start
.x
==end
.x
)&&(start
.y
==end
.y
))
420 { /* A lazy program delivers xstart=xend=ystart=yend=0) */
424 else /* notorious cases */
425 if ((start_angle
== PI
)&&( end_angle
<0))
428 if ((end_angle
== PI
)&&( start_angle
<0))
430 istart_angle
= (INT
)(start_angle
* 180 * 64 / PI
+ 0.5);
431 idiff_angle
= (INT
)((end_angle
- start_angle
) * 180 * 64 / PI
+ 0.5);
432 if (idiff_angle
<= 0) idiff_angle
+= 360 * 64;
434 /* Update the pixmap from the DIB section */
435 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
437 /* Fill arc with brush if Chord() or Pie() */
439 if ((lines
> 0) && X11DRV_SetupGCForBrush( physDev
)) {
441 XSetArcMode( gdi_display
, physDev
->gc
, (lines
==1) ? ArcChord
: ArcPieSlice
);
442 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
443 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
444 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, istart_angle
, idiff_angle
);
449 /* Draw arc and lines */
451 if (X11DRV_SetupGCForPen( physDev
))
454 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
455 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
456 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, istart_angle
, idiff_angle
);
458 /* use the truncated values */
459 start_angle
=(double)istart_angle
*PI
/64./180.;
460 end_angle
=(double)(istart_angle
+idiff_angle
)*PI
/64./180.;
461 /* calculate the endpoints and round correctly */
462 points
[0].x
= (int) floor(physDev
->org
.x
+ (rc
.right
+rc
.left
)/2.0 +
463 cos(start_angle
) * (rc
.right
-rc
.left
-width
*2+2) / 2. + 0.5);
464 points
[0].y
= (int) floor(physDev
->org
.y
+ (rc
.top
+rc
.bottom
)/2.0 -
465 sin(start_angle
) * (rc
.bottom
-rc
.top
-width
*2+2) / 2. + 0.5);
466 points
[1].x
= (int) floor(physDev
->org
.x
+ (rc
.right
+rc
.left
)/2.0 +
467 cos(end_angle
) * (rc
.right
-rc
.left
-width
*2+2) / 2. + 0.5);
468 points
[1].y
= (int) floor(physDev
->org
.y
+ (rc
.top
+rc
.bottom
)/2.0 -
469 sin(end_angle
) * (rc
.bottom
-rc
.top
-width
*2+2) / 2. + 0.5);
471 /* OK, this stuff is optimized for Xfree86
472 * which is probably the server most used by
473 * wine users. Other X servers will not
474 * display correctly. (eXceed for instance)
475 * so if you feel you must make changes, make sure that
476 * you either use Xfree86 or separate your changes
477 * from these (compile switch or whatever)
481 points
[3] = points
[1];
482 points
[1].x
= physDev
->org
.x
+ xcenter
;
483 points
[1].y
= physDev
->org
.y
+ ycenter
;
484 points
[2] = points
[1];
485 dx1
=points
[1].x
-points
[0].x
;
486 dy1
=points
[1].y
-points
[0].y
;
487 if(((rc
.top
-rc
.bottom
) | -2) == -2)
488 if(dy1
>0) points
[1].y
--;
490 if (((-dx1
)*64)<=ABS(dy1
)*37) points
[0].x
--;
491 if(((-dx1
*9))<(dy1
*16)) points
[0].y
--;
492 if( dy1
<0 && ((dx1
*9)) < (dy1
*16)) points
[0].y
--;
494 if(dy1
< 0) points
[0].y
--;
495 if(((rc
.right
-rc
.left
) | -2) == -2) points
[1].x
--;
497 dx1
=points
[3].x
-points
[2].x
;
498 dy1
=points
[3].y
-points
[2].y
;
499 if(((rc
.top
-rc
.bottom
) | -2 ) == -2)
500 if(dy1
< 0) points
[2].y
--;
502 if( dy1
>0) points
[3].y
--;
503 if(((rc
.right
-rc
.left
) | -2) == -2 ) points
[2].x
--;
506 if( dx1
* 64 < dy1
* -37 ) points
[3].x
--;
510 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
511 points
, lines
+1, CoordModeOrigin
);
517 /* Update the DIBSection of the pixmap */
518 X11DRV_UnlockDIBSection(physDev
, update
);
520 physDev
->pen
.width
= oldwidth
;
525 /***********************************************************************
529 X11DRV_Arc( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
530 INT xstart
, INT ystart
, INT xend
, INT yend
)
532 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
533 xstart
, ystart
, xend
, yend
, 0 );
537 /***********************************************************************
541 X11DRV_Pie( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
542 INT xstart
, INT ystart
, INT xend
, INT yend
)
544 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
545 xstart
, ystart
, xend
, yend
, 2 );
548 /***********************************************************************
552 X11DRV_Chord( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
,
553 INT xstart
, INT ystart
, INT xend
, INT yend
)
555 return X11DRV_DrawArc( physDev
, left
, top
, right
, bottom
,
556 xstart
, ystart
, xend
, yend
, 1 );
560 /***********************************************************************
564 X11DRV_Ellipse( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
)
570 SetRect(&rc
, left
, top
, right
, bottom
);
571 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
573 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)) return TRUE
;
575 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
576 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
578 oldwidth
= width
= physDev
->pen
.width
;
579 if (!width
) width
= 1;
580 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
582 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
584 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
585 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
586 rc
.left
+= width
/ 2;
587 rc
.right
-= (width
- 1) / 2;
589 rc
.bottom
-= (width
- 1) / 2;
591 if(width
== 0) width
= 1; /* more accurate */
592 physDev
->pen
.width
= width
;
594 /* Update the pixmap from the DIB section */
595 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
597 if (X11DRV_SetupGCForBrush( physDev
))
600 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
601 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
602 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, 0, 360*64 );
606 if (X11DRV_SetupGCForPen( physDev
))
609 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
610 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
611 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1, 0, 360*64 );
616 /* Update the DIBSection from the pixmap */
617 X11DRV_UnlockDIBSection(physDev
, update
);
619 physDev
->pen
.width
= oldwidth
;
624 /***********************************************************************
628 X11DRV_Rectangle(X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
, INT bottom
)
630 INT width
, oldwidth
, oldjoinstyle
;
634 TRACE("(%d %d %d %d)\n", left
, top
, right
, bottom
);
636 SetRect(&rc
, left
, top
, right
, bottom
);
637 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
639 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
)) return TRUE
;
641 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
642 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
644 oldwidth
= width
= physDev
->pen
.width
;
645 if (!width
) width
= 1;
646 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
648 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
650 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
651 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
652 rc
.left
+= width
/ 2;
653 rc
.right
-= (width
- 1) / 2;
655 rc
.bottom
-= (width
- 1) / 2;
657 if(width
== 1) width
= 0;
658 physDev
->pen
.width
= width
;
659 oldjoinstyle
= physDev
->pen
.linejoin
;
660 if(physDev
->pen
.type
!= PS_GEOMETRIC
)
661 physDev
->pen
.linejoin
= PS_JOIN_MITER
;
663 /* Update the pixmap from the DIB section */
664 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
666 if ((rc
.right
> rc
.left
+ width
) && (rc
.bottom
> rc
.top
+ width
))
668 if (X11DRV_SetupGCForBrush( physDev
))
671 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
672 physDev
->org
.x
+ rc
.left
+ (width
+ 1) / 2,
673 physDev
->org
.y
+ rc
.top
+ (width
+ 1) / 2,
674 rc
.right
-rc
.left
-width
-1, rc
.bottom
-rc
.top
-width
-1);
679 if (X11DRV_SetupGCForPen( physDev
))
682 XDrawRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
683 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
684 rc
.right
-rc
.left
-1, rc
.bottom
-rc
.top
-1 );
689 /* Update the DIBSection from the pixmap */
690 X11DRV_UnlockDIBSection(physDev
, update
);
692 physDev
->pen
.width
= oldwidth
;
693 physDev
->pen
.linejoin
= oldjoinstyle
;
697 /***********************************************************************
701 X11DRV_RoundRect( X11DRV_PDEVICE
*physDev
, INT left
, INT top
, INT right
,
702 INT bottom
, INT ell_width
, INT ell_height
)
704 INT width
, oldwidth
, oldendcap
;
709 TRACE("(%d %d %d %d %d %d\n",
710 left
, top
, right
, bottom
, ell_width
, ell_height
);
712 SetRect(&rc
, left
, top
, right
, bottom
);
713 LPtoDP(physDev
->hdc
, (POINT
*)&rc
, 2);
715 if ((rc
.left
== rc
.right
) || (rc
.top
== rc
.bottom
))
718 /* Make sure ell_width and ell_height are >= 1 otherwise XDrawArc gets
719 called with width/height < 0 */
720 pts
[0].x
= pts
[0].y
= 0;
721 pts
[1].x
= ell_width
;
722 pts
[1].y
= ell_height
;
723 LPtoDP(physDev
->hdc
, pts
, 2);
724 ell_width
= max(abs( pts
[1].x
- pts
[0].x
), 1);
725 ell_height
= max(abs( pts
[1].y
- pts
[0].y
), 1);
727 /* Fix the coordinates */
729 if (rc
.right
< rc
.left
) { INT tmp
= rc
.right
; rc
.right
= rc
.left
; rc
.left
= tmp
; }
730 if (rc
.bottom
< rc
.top
) { INT tmp
= rc
.bottom
; rc
.bottom
= rc
.top
; rc
.top
= tmp
; }
732 oldwidth
= width
= physDev
->pen
.width
;
733 oldendcap
= physDev
->pen
.endcap
;
734 if (!width
) width
= 1;
735 if(physDev
->pen
.style
== PS_NULL
) width
= 0;
737 if ((physDev
->pen
.style
== PS_INSIDEFRAME
))
739 if (2*width
> (rc
.right
-rc
.left
)) width
=(rc
.right
-rc
.left
+ 1)/2;
740 if (2*width
> (rc
.bottom
-rc
.top
)) width
=(rc
.bottom
-rc
.top
+ 1)/2;
741 rc
.left
+= width
/ 2;
742 rc
.right
-= (width
- 1) / 2;
744 rc
.bottom
-= (width
- 1) / 2;
746 if(width
== 0) width
= 1;
747 physDev
->pen
.width
= width
;
748 physDev
->pen
.endcap
= PS_ENDCAP_SQUARE
;
750 /* Update the pixmap from the DIB section */
751 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
754 if (X11DRV_SetupGCForBrush( physDev
))
756 if (ell_width
> (rc
.right
-rc
.left
) )
757 if (ell_height
> (rc
.bottom
-rc
.top
) )
758 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
759 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
760 rc
.right
- rc
.left
- 1, rc
.bottom
- rc
.top
- 1,
763 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
764 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
765 rc
.right
- rc
.left
- 1, ell_height
, 0, 180 * 64 );
766 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
767 physDev
->org
.x
+ rc
.left
,
768 physDev
->org
.y
+ rc
.bottom
- ell_height
- 1,
769 rc
.right
- rc
.left
- 1, ell_height
, 180 * 64,
772 else if (ell_height
> (rc
.bottom
-rc
.top
) ){
773 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
774 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
775 ell_width
, rc
.bottom
- rc
.top
- 1, 90 * 64, 180 * 64 );
776 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
777 physDev
->org
.x
+ rc
.right
- ell_width
- 1, physDev
->org
.y
+ rc
.top
,
778 ell_width
, rc
.bottom
- rc
.top
- 1, 270 * 64, 180 * 64 );
780 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
781 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
782 ell_width
, ell_height
, 90 * 64, 90 * 64 );
783 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
784 physDev
->org
.x
+ rc
.left
,
785 physDev
->org
.y
+ rc
.bottom
- ell_height
- 1,
786 ell_width
, ell_height
, 180 * 64, 90 * 64 );
787 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
788 physDev
->org
.x
+ rc
.right
- ell_width
- 1,
789 physDev
->org
.y
+ rc
.bottom
- ell_height
- 1,
790 ell_width
, ell_height
, 270 * 64, 90 * 64 );
791 XFillArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
792 physDev
->org
.x
+ rc
.right
- ell_width
- 1,
793 physDev
->org
.y
+ rc
.top
,
794 ell_width
, ell_height
, 0, 90 * 64 );
796 if (ell_width
< rc
.right
- rc
.left
)
798 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
799 physDev
->org
.x
+ rc
.left
+ (ell_width
+ 1) / 2,
800 physDev
->org
.y
+ rc
.top
+ 1,
801 rc
.right
- rc
.left
- ell_width
- 1,
802 (ell_height
+ 1) / 2 - 1);
803 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
804 physDev
->org
.x
+ rc
.left
+ (ell_width
+ 1) / 2,
805 physDev
->org
.y
+ rc
.bottom
- (ell_height
) / 2 - 1,
806 rc
.right
- rc
.left
- ell_width
- 1,
809 if (ell_height
< rc
.bottom
- rc
.top
)
811 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
812 physDev
->org
.x
+ rc
.left
+ 1,
813 physDev
->org
.y
+ rc
.top
+ (ell_height
+ 1) / 2,
814 rc
.right
- rc
.left
- 2,
815 rc
.bottom
- rc
.top
- ell_height
- 1);
819 /* FIXME: this could be done with on X call
820 * more efficient and probably more correct
821 * on any X server: XDrawArcs will draw
822 * straight horizontal and vertical lines
823 * if width or height are zero.
825 * BTW this stuff is optimized for an Xfree86 server
826 * read the comments inside the X11DRV_DrawArc function
828 if (X11DRV_SetupGCForPen( physDev
))
830 if (ell_width
> (rc
.right
-rc
.left
) )
831 if (ell_height
> (rc
.bottom
-rc
.top
) )
832 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
833 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
834 rc
.right
- rc
.left
- 1, rc
.bottom
- rc
.top
- 1, 0 , 360 * 64 );
836 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
837 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
838 rc
.right
- rc
.left
- 1, ell_height
- 1, 0 , 180 * 64 );
839 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
840 physDev
->org
.x
+ rc
.left
,
841 physDev
->org
.y
+ rc
.bottom
- ell_height
,
842 rc
.right
- rc
.left
- 1, ell_height
- 1, 180 * 64 , 180 * 64 );
844 else if (ell_height
> (rc
.bottom
-rc
.top
) ){
845 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
846 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
847 ell_width
- 1 , rc
.bottom
- rc
.top
- 1, 90 * 64 , 180 * 64 );
848 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
849 physDev
->org
.x
+ rc
.right
- ell_width
,
850 physDev
->org
.y
+ rc
.top
,
851 ell_width
- 1 , rc
.bottom
- rc
.top
- 1, 270 * 64 , 180 * 64 );
853 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
854 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.top
,
855 ell_width
- 1, ell_height
- 1, 90 * 64, 90 * 64 );
856 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
857 physDev
->org
.x
+ rc
.left
, physDev
->org
.y
+ rc
.bottom
- ell_height
,
858 ell_width
- 1, ell_height
- 1, 180 * 64, 90 * 64 );
859 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
860 physDev
->org
.x
+ rc
.right
- ell_width
,
861 physDev
->org
.y
+ rc
.bottom
- ell_height
,
862 ell_width
- 1, ell_height
- 1, 270 * 64, 90 * 64 );
863 XDrawArc( gdi_display
, physDev
->drawable
, physDev
->gc
,
864 physDev
->org
.x
+ rc
.right
- ell_width
, physDev
->org
.y
+ rc
.top
,
865 ell_width
- 1, ell_height
- 1, 0, 90 * 64 );
867 if (ell_width
< rc
.right
- rc
.left
)
869 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
870 physDev
->org
.x
+ rc
.left
+ ell_width
/ 2,
871 physDev
->org
.y
+ rc
.top
,
872 physDev
->org
.x
+ rc
.right
- (ell_width
+1) / 2,
873 physDev
->org
.y
+ rc
.top
);
874 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
875 physDev
->org
.x
+ rc
.left
+ ell_width
/ 2 ,
876 physDev
->org
.y
+ rc
.bottom
- 1,
877 physDev
->org
.x
+ rc
.right
- (ell_width
+1)/ 2,
878 physDev
->org
.y
+ rc
.bottom
- 1);
880 if (ell_height
< rc
.bottom
- rc
.top
)
882 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
883 physDev
->org
.x
+ rc
.right
- 1,
884 physDev
->org
.y
+ rc
.top
+ ell_height
/ 2,
885 physDev
->org
.x
+ rc
.right
- 1,
886 physDev
->org
.y
+ rc
.bottom
- (ell_height
+1) / 2);
887 XDrawLine( gdi_display
, physDev
->drawable
, physDev
->gc
,
888 physDev
->org
.x
+ rc
.left
,
889 physDev
->org
.y
+ rc
.top
+ ell_height
/ 2,
890 physDev
->org
.x
+ rc
.left
,
891 physDev
->org
.y
+ rc
.bottom
- (ell_height
+1) / 2);
896 /* Update the DIBSection from the pixmap */
897 X11DRV_UnlockDIBSection(physDev
, update
);
899 physDev
->pen
.width
= oldwidth
;
900 physDev
->pen
.endcap
= oldendcap
;
905 /***********************************************************************
909 X11DRV_SetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
, COLORREF color
)
916 LPtoDP( physDev
->hdc
, &pt
, 1 );
917 pixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
919 /* Update the pixmap from the DIB section */
920 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
922 /* inefficient but simple... */
924 XSetForeground( gdi_display
, physDev
->gc
, pixel
);
925 XSetFunction( gdi_display
, physDev
->gc
, GXcopy
);
926 XDrawPoint( gdi_display
, physDev
->drawable
, physDev
->gc
,
927 physDev
->org
.x
+ pt
.x
, physDev
->org
.y
+ pt
.y
);
930 /* Update the DIBSection from the pixmap */
931 X11DRV_UnlockDIBSection(physDev
, TRUE
);
933 return X11DRV_PALETTE_ToLogical(pixel
);
937 /***********************************************************************
941 X11DRV_GetPixel( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
943 static Pixmap pixmap
= 0;
947 BOOL memdc
= (GetObjectType(physDev
->hdc
) == OBJ_MEMDC
);
951 LPtoDP( physDev
->hdc
, &pt
, 1 );
953 /* Update the pixmap from the DIB section */
954 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
959 image
= XGetImage( gdi_display
, physDev
->drawable
,
960 physDev
->org
.x
+ pt
.x
, physDev
->org
.y
+ pt
.y
,
961 1, 1, AllPlanes
, ZPixmap
);
965 /* If we are reading from the screen, use a temporary copy */
966 /* to avoid a BadMatch error */
967 if (!pixmap
) pixmap
= XCreatePixmap( gdi_display
, root_window
,
968 1, 1, physDev
->depth
);
969 XCopyArea( gdi_display
, physDev
->drawable
, pixmap
, BITMAP_colorGC
,
970 physDev
->org
.x
+ pt
.x
, physDev
->org
.y
+ pt
.y
, 1, 1, 0, 0 );
971 image
= XGetImage( gdi_display
, pixmap
, 0, 0, 1, 1, AllPlanes
, ZPixmap
);
973 pixel
= XGetPixel( image
, 0, 0 );
974 XDestroyImage( image
);
977 /* Update the DIBSection from the pixmap */
978 X11DRV_UnlockDIBSection(physDev
, FALSE
);
980 return X11DRV_PALETTE_ToLogical(pixel
);
984 /***********************************************************************
988 X11DRV_PaintRgn( X11DRV_PDEVICE
*physDev
, HRGN hrgn
)
990 if (X11DRV_SetupGCForBrush( physDev
))
994 RGNDATA
*data
= X11DRV_GetRegionData( hrgn
, physDev
->hdc
);
996 if (!data
) return FALSE
;
997 rect
= (XRectangle
*)data
->Buffer
;
998 for (i
= 0; i
< data
->rdh
.nCount
; i
++)
1000 rect
[i
].x
+= physDev
->org
.x
;
1001 rect
[i
].y
+= physDev
->org
.y
;
1004 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1006 XFillRectangles( gdi_display
, physDev
->drawable
, physDev
->gc
, rect
, data
->rdh
.nCount
);
1007 wine_tsx11_unlock();
1008 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1009 HeapFree( GetProcessHeap(), 0, data
);
1014 /**********************************************************************
1018 X11DRV_Polyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
)
1024 if((oldwidth
= physDev
->pen
.width
) == 0) physDev
->pen
.width
= 1;
1026 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * count
)))
1028 WARN("No memory to convert POINTs to XPoints!\n");
1031 for (i
= 0; i
< count
; i
++)
1034 LPtoDP(physDev
->hdc
, &tmp
, 1);
1035 points
[i
].x
= physDev
->org
.x
+ tmp
.x
;
1036 points
[i
].y
= physDev
->org
.y
+ tmp
.y
;
1039 if (X11DRV_SetupGCForPen ( physDev
))
1041 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1043 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1044 points
, count
, CoordModeOrigin
);
1045 wine_tsx11_unlock();
1046 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1049 HeapFree( GetProcessHeap(), 0, points
);
1050 physDev
->pen
.width
= oldwidth
;
1055 /**********************************************************************
1059 X11DRV_Polygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, INT count
)
1063 BOOL update
= FALSE
;
1065 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * (count
+1) )))
1067 WARN("No memory to convert POINTs to XPoints!\n");
1070 for (i
= 0; i
< count
; i
++)
1073 LPtoDP(physDev
->hdc
, &tmp
, 1);
1074 points
[i
].x
= physDev
->org
.x
+ tmp
.x
;
1075 points
[i
].y
= physDev
->org
.y
+ tmp
.y
;
1077 points
[count
] = points
[0];
1079 /* Update the pixmap from the DIB section */
1080 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1082 if (X11DRV_SetupGCForBrush( physDev
))
1085 XFillPolygon( gdi_display
, physDev
->drawable
, physDev
->gc
,
1086 points
, count
+1, Complex
, CoordModeOrigin
);
1087 wine_tsx11_unlock();
1090 if (X11DRV_SetupGCForPen ( physDev
))
1093 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1094 points
, count
+1, CoordModeOrigin
);
1095 wine_tsx11_unlock();
1099 /* Update the DIBSection from the pixmap */
1100 X11DRV_UnlockDIBSection(physDev
, update
);
1102 HeapFree( GetProcessHeap(), 0, points
);
1107 /**********************************************************************
1108 * X11DRV_PolyPolygon
1111 X11DRV_PolyPolygon( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, const INT
* counts
, UINT polygons
)
1115 /* FIXME: The points should be converted to device coords before */
1116 /* creating the region. */
1118 hrgn
= CreatePolyPolygonRgn( pt
, counts
, polygons
, GetPolyFillMode( physDev
->hdc
) );
1119 X11DRV_PaintRgn( physDev
, hrgn
);
1120 DeleteObject( hrgn
);
1122 /* Draw the outline of the polygons */
1124 if (X11DRV_SetupGCForPen ( physDev
))
1129 /* Update the pixmap from the DIB section */
1130 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1132 for (i
= 0; i
< polygons
; i
++) if (counts
[i
] > max
) max
= counts
[i
];
1133 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * (max
+1) )))
1135 WARN("No memory to convert POINTs to XPoints!\n");
1138 for (i
= 0; i
< polygons
; i
++)
1140 for (j
= 0; j
< counts
[i
]; j
++)
1143 LPtoDP(physDev
->hdc
, &tmp
, 1);
1144 points
[j
].x
= physDev
->org
.x
+ tmp
.x
;
1145 points
[j
].y
= physDev
->org
.y
+ tmp
.y
;
1148 points
[j
] = points
[0];
1150 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1151 points
, j
+ 1, CoordModeOrigin
);
1152 wine_tsx11_unlock();
1155 /* Update the DIBSection of the dc's bitmap */
1156 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1158 HeapFree( GetProcessHeap(), 0, points
);
1164 /**********************************************************************
1165 * X11DRV_PolyPolyline
1168 X11DRV_PolyPolyline( X11DRV_PDEVICE
*physDev
, const POINT
* pt
, const DWORD
* counts
, DWORD polylines
)
1170 if (X11DRV_SetupGCForPen ( physDev
))
1175 /* Update the pixmap from the DIB section */
1176 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1178 for (i
= 0; i
< polylines
; i
++) if (counts
[i
] > max
) max
= counts
[i
];
1179 if (!(points
= HeapAlloc( GetProcessHeap(), 0, sizeof(XPoint
) * max
)))
1181 WARN("No memory to convert POINTs to XPoints!\n");
1184 for (i
= 0; i
< polylines
; i
++)
1186 for (j
= 0; j
< counts
[i
]; j
++)
1189 LPtoDP(physDev
->hdc
, &tmp
, 1);
1190 points
[j
].x
= physDev
->org
.x
+ tmp
.x
;
1191 points
[j
].y
= physDev
->org
.y
+ tmp
.y
;
1195 XDrawLines( gdi_display
, physDev
->drawable
, physDev
->gc
,
1196 points
, j
, CoordModeOrigin
);
1197 wine_tsx11_unlock();
1200 /* Update the DIBSection of the dc's bitmap */
1201 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1203 HeapFree( GetProcessHeap(), 0, points
);
1209 /**********************************************************************
1210 * X11DRV_InternalFloodFill
1212 * Internal helper function for flood fill.
1213 * (xorg,yorg) is the origin of the X image relative to the drawable.
1214 * (x,y) is relative to the origin of the X image.
1216 static void X11DRV_InternalFloodFill(XImage
*image
, X11DRV_PDEVICE
*physDev
,
1219 Pixel pixel
, WORD fillType
)
1223 #define TO_FLOOD(x,y) ((fillType == FLOODFILLBORDER) ? \
1224 (XGetPixel(image,x,y) != pixel) : \
1225 (XGetPixel(image,x,y) == pixel))
1227 if (!TO_FLOOD(x
,y
)) return;
1229 /* Find left and right boundaries */
1232 while ((left
> 0) && TO_FLOOD( left
-1, y
)) left
--;
1233 while ((right
< image
->width
) && TO_FLOOD( right
, y
)) right
++;
1234 XFillRectangle( gdi_display
, physDev
->drawable
, physDev
->gc
,
1235 xOrg
+ left
, yOrg
+ y
, right
-left
, 1 );
1237 /* Set the pixels of this line so we don't fill it again */
1239 for (x
= left
; x
< right
; x
++)
1241 if (fillType
== FLOODFILLBORDER
) XPutPixel( image
, x
, y
, pixel
);
1242 else XPutPixel( image
, x
, y
, ~pixel
);
1245 /* Fill the line above */
1252 while ((x
< right
) && !TO_FLOOD(x
,y
)) x
++;
1253 if (x
>= right
) break;
1254 while ((x
< right
) && TO_FLOOD(x
,y
)) x
++;
1255 X11DRV_InternalFloodFill(image
, physDev
, x
-1, y
,
1256 xOrg
, yOrg
, pixel
, fillType
);
1260 /* Fill the line below */
1262 if ((y
+= 2) < image
->height
)
1267 while ((x
< right
) && !TO_FLOOD(x
,y
)) x
++;
1268 if (x
>= right
) break;
1269 while ((x
< right
) && TO_FLOOD(x
,y
)) x
++;
1270 X11DRV_InternalFloodFill(image
, physDev
, x
-1, y
,
1271 xOrg
, yOrg
, pixel
, fillType
);
1278 /**********************************************************************
1279 * X11DRV_ExtFloodFill
1282 X11DRV_ExtFloodFill( X11DRV_PDEVICE
*physDev
, INT x
, INT y
, COLORREF color
,
1289 TRACE("X11DRV_ExtFloodFill %d,%d %06lx %d\n", x
, y
, color
, fillType
);
1293 LPtoDP( physDev
->hdc
, &pt
, 1 );
1294 if (!PtInRegion( physDev
->region
, pt
.x
, pt
.y
)) return FALSE
;
1295 GetRgnBox( physDev
->region
, &rect
);
1298 image
= XGetImage( gdi_display
, physDev
->drawable
,
1299 physDev
->org
.x
+ rect
.left
, physDev
->org
.y
+ rect
.top
,
1300 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
,
1301 AllPlanes
, ZPixmap
);
1302 wine_tsx11_unlock();
1303 if (!image
) return FALSE
;
1305 if (X11DRV_SetupGCForBrush( physDev
))
1307 /* Update the pixmap from the DIB section */
1308 X11DRV_LockDIBSection(physDev
, DIB_Status_GdiMod
, FALSE
);
1310 /* ROP mode is always GXcopy for flood-fill */
1312 XSetFunction( gdi_display
, physDev
->gc
, GXcopy
);
1313 X11DRV_InternalFloodFill(image
, physDev
,
1314 physDev
->org
.x
+ pt
.x
- rect
.left
,
1315 physDev
->org
.y
+ pt
.y
- rect
.top
,
1316 rect
.left
, rect
.top
,
1317 X11DRV_PALETTE_ToPhysical( physDev
, color
),
1319 wine_tsx11_unlock();
1320 /* Update the DIBSection of the dc's bitmap */
1321 X11DRV_UnlockDIBSection(physDev
, TRUE
);
1325 XDestroyImage( image
);
1326 wine_tsx11_unlock();
1330 /**********************************************************************
1334 X11DRV_SetBkColor( X11DRV_PDEVICE
*physDev
, COLORREF color
)
1336 physDev
->backgroundPixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
1340 /**********************************************************************
1341 * X11DRV_SetTextColor
1344 X11DRV_SetTextColor( X11DRV_PDEVICE
*physDev
, COLORREF color
)
1346 physDev
->textPixel
= X11DRV_PALETTE_ToPhysical( physDev
, color
);
1350 /***********************************************************************
1351 * GetDCOrgEx (X11DRV.@)
1353 BOOL
X11DRV_GetDCOrgEx( X11DRV_PDEVICE
*physDev
, LPPOINT lpp
)
1355 lpp
->x
= physDev
->org
.x
+ physDev
->drawable_org
.x
;
1356 lpp
->y
= physDev
->org
.y
+ physDev
->drawable_org
.y
;
1361 /***********************************************************************
1362 * SetDCOrg (X11DRV.@)
1364 DWORD
X11DRV_SetDCOrg( X11DRV_PDEVICE
*physDev
, INT x
, INT y
)
1366 DWORD ret
= MAKELONG( physDev
->org
.x
+ physDev
->drawable_org
.x
,
1367 physDev
->org
.y
+ physDev
->drawable_org
.y
);
1368 physDev
->org
.x
= x
- physDev
->drawable_org
.x
;
1369 physDev
->org
.y
= y
- physDev
->drawable_org
.y
;