This is the mail archive of the cygwin-xfree@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Development Status Update 2


Today I figured out a workable solution for making the X headers play nice
with the Windows headers; the solution involves using the Wine headers for
Windows (as they allow more precise control over which headers are included)
and the user headers for X (think Xlib.h instead of pixmap.h). I'm satisfied
with this solution, at this point, as it allows us to move on with
programming instead of rewriting or adding #ifdef's to lots of header files.
We might want to revisit the header issue when we get more of a product in
place.

As a simple test I threw some Win32 API calls into the stub for GetSpans
that creates a Windows window and draws a line; the test works and it
compiles with gcc under Cygwin; the successful compilation with gcc under
Cygwin means that we can move away from a seperate dll compiled with Visual
C++.

My immediate steps will be to yank out any references to xf_dx.dll from my
source files, essentially copying the relevent code from xf_dx.dll to the
appropriate files for xwin.exe; next I'll setup includes for all of the stub
files that will allow the Device Dependent X functions to compile with Win32
API calls; at that point I will probably make the skeleton source available
via the web so that other developers can see what I am up to.  After that,
we just have to fill in the stubs with useful functions :)  Err... that will
only take about three months :)

I'll keep you posted,

Harold

P.S.  Following is the sample code that I through together in
xc/programs/Xserver/hw/xwin/wingetsp.c, for your enjoyment; note that this
code compiles under Cygwin with gcc and gets linked into XWin.exe:

#include "Xlib.h"
typedef struct _xPoint *DDXPointPtr;

#include "windef.h"
#include "winbase.h"
#include "gdi.h"
#include "user.h"
#include "winuser.h"

#include <stdio.h>

#define NAME "cygwin/xfree86"
#define TITLE "Cywgin/XFree86"

LRESULT CALLBACK
WindowProc (HWND hWnd, UINT message, 
	    WPARAM wParam, LPARAM lParam)
{
  return DefWindowProc (hWnd, message, wParam, lParam);
}

void
winGetSpans (Drawable		*pDrawable, 
	     int		wMax, 
	     DDXPointPtr	pPoint, 
	     int		*pwidth, 
	     int		nspans, 
	     char		*pchardstStart)
{
  static Bool		fRunOnce = FALSE;
  WNDCLASS		wc;
  HWND			hwnd;
  HDC			hdc;

  fprintf (stderr, "winGetSpans()\n");

  if (!fRunOnce)
    {
      /* only run this code once */
      fRunOnce = TRUE;

      // Setup our window class
      wc.style = CS_HREDRAW | CS_VREDRAW;
      wc.lpfnWndProc = WindowProc;
      wc.cbClsExtra = 0;
      wc.cbWndExtra = 0;
      wc.hInstance = GetModuleHandle(NULL);
      wc.hIcon = 0;
      wc.hCursor = 0;
      wc.hbrBackground = 0;
      wc.lpszMenuName = NULL;
      wc.lpszClassName = NAME;
      RegisterClass (&wc);

      // Create the window
      hwnd = CreateWindowEx (0,			// Extended styles
			     NAME,		// Class name
			     TITLE,		// Window name
			     WS_OVERLAPPED
			     | WS_CAPTION
			     | WS_SYSMENU
			     | WS_MINIMIZEBOX,	// Almost an
OverlappedWindow
			     CW_USEDEFAULT,	// Horizontal position
			     CW_USEDEFAULT,	// Vertical position
			     CW_USEDEFAULT,	// Right edge
			     CW_USEDEFAULT,	// Bottom edge
			     (HWND) NULL,	// No parent or owner window
			     (HMENU) NULL,	// No menu
			     GetModuleHandle (NULL),	// Instance handle
			     NULL);		// No window creation data
      
      /* Show the window */
      ShowWindow (hwnd, SW_SHOW);
      UpdateWindow (hwnd);
      
      /* Get the device context */
      hdc = GetDC (hwnd);

      /* Draw something */
      MoveToEx (hdc, 0, 0, NULL);
      LineTo (hdc, 100, 100);

      ReleaseDC (hwnd, hdc);
    }
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]