implement PS_USERSTYLE handling - obviously not correct ;)

Hans Breuer hans at breuer.org
Sat Apr 4 16:49:43 CDT 2009


Hi,
just read again http://www.winehq.org/sending_patches and noticed that my 
first wine patch may fall in the category of not deserving an answer at all 
(to your standards).

The one thing I noticed is my mail client putting line-wrapping into the 
patch, which should be easy to correct.

But before resending it, I would appreciate some feedback if something else 
is 'obviously' wrong with it. To me it seems to be very difficult for the 
issue at hand to fall into the category of being "Obvious(ly) Correct".

Although the X11 and win32 concepts of extended line styles are very 
similar, at least I did not know the scaling issues involved without trying 
it out.

One thing which may be considered critical is my selection of the test 
program. As noted it is Dia for win32 (ported by me [1]) through 
gdk-win32-drawing code (PS_USERSTYLE usage implemented by me [2]).
So if I have misunderstood something there seven years ago, that two bugs 
could compensate each other ;)

Another issue might be the unconditional implementation of PS_USERSTYLE. 
After all it is only available with NT-based windows. Should x11drv check 
for the version being emulated to also reproduce the failing behaviour? Or 
would that be too much compatibility?

What can I do to increase the probability of the patch being accepted?

Thanks,
	Hans

[1] http://hans.breuer.org/dia/
[2] http://svn.gnome.org/viewvc/gtk%2B?view=revision&revision=6330
[3] http://hans.breuer.org/dia/dia-wine.htm

-------- Original-Nachricht --------
Betreff: implement PS_USERSTYLE handling, tested with Dia(win32)
Datum: Sun, 29 Mar 2009 19:45:05 +0200
Von: Hans Breuer <hans at breuer.org>
An: wine-patches at winehq.org

 From b89af7d06fc8cbf5210c61fd58ed62caeddad968 Mon Sep 17 00:00:00 2001
From: Hans Breuer <hans at breuer.org>
Date: Sun, 29 Mar 2009 18:27:29 +0200
Subject: implement PS_USERSTYLE handling, tested with Dia(win32) - see
  http://hans.breuer.org/dia/dia-wine.htm

---
  dlls/winex11.drv/pen.c |   31 +++++++++++++++++++++++++++----
  1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/dlls/winex11.drv/pen.c b/dlls/winex11.drv/pen.c
index 49fe74c..039798e 100644
--- a/dlls/winex11.drv/pen.c
+++ b/dlls/winex11.drv/pen.c
@@ -54,12 +54,33 @@ HPEN CDECL X11DRV_SelectPen( X11DRV_PDEVICE *physDev,
HPEN hpen )
          elp = HeapAlloc( GetProcessHeap(), 0, size );

          GetObjectW( hpen, size, elp );
-        /* FIXME: add support for user style pens */
          logpen.lopnStyle = elp->elpPenStyle;
          logpen.lopnWidth.x = elp->elpWidth;
          logpen.lopnWidth.y = 0;
          logpen.lopnColor = elp->elpColor;
-
+        /* support for user style pens */
+        if (MAX_DASHLEN < elp->elpNumEntries)
+        {
+            FIXME("PS_USERSTYLE: len(dashes)>MAX_DASHLEN %d,%d\n", 
elp->elpNumEntries, MAX_DASHLEN);
+            physDev->pen.dash_len = 0;
+        }
+        else
+        {
+            BOOL overflow = FALSE;
+            physDev->pen.dash_len = elp->elpNumEntries;
+            for (i = 0; i < elp->elpNumEntries; ++i)
+            {
+                if (elp->elpStyleEntry[i] > 255)
+                {
+                    overflow = TRUE; /* can't fit the type */
+                    physDev->pen.dashes[i] = 255;
+                }
+                else
+                    physDev->pen.dashes[i] = (char)elp->elpStyleEntry[i];
+            }
+            if (overflow)
+                FIXME("PS_USERSTYLE: dashes clipped (type overflow)\n");
+        }
          HeapFree( GetProcessHeap(), 0, elp );
      }
      else
@@ -108,14 +129,16 @@ HPEN CDECL X11DRV_SelectPen( X11DRV_PDEVICE *physDev,
HPEN hpen )
              memcpy(physDev->pen.dashes, PEN_alternate,
physDev->pen.dash_len);
              break;
        case PS_USERSTYLE:
-        FIXME("PS_USERSTYLE is not supported\n");
+            /* handled above */
+            break;
          /* fall through */
        default:
          physDev->pen.dash_len = 0;
          break;
      }
      if(physDev->pen.ext && physDev->pen.dash_len &&
-        (logpen.lopnStyle & PS_STYLE_MASK) != PS_ALTERNATE)
+        (logpen.lopnStyle & PS_STYLE_MASK) != PS_ALTERNATE &&
+        (logpen.lopnStyle & PS_STYLE_MASK) != PS_USERSTYLE)
          for(i = 0; i < physDev->pen.dash_len; i++)
              physDev->pen.dashes[i] *= (physDev->pen.width ?
physDev->pen.width : 1);

-- 
1.6.0.6


-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert



More information about the wine-devel mailing list