Tk Source Code

View Ticket
Login
Ticket UUID: 220661
Title: XGetGeometry in tkWinPixmap.c should handle windows as well as bitmaps
Type: Bug Version: obsolete: 8.3b2
Submitter: welch Created on: 2000-10-31 23:48:04
Subsystem: 68. Win Window Operations Assigned To: nobody
Priority: 2 Severity:
Status: Closed Last Modified: 2001-03-28 05:09:11
Resolution: Fixed Closed By: dgp
    Closed on: 2001-03-27 22:09:11
Description:
OriginalBugID: 4069 RFE
Version: 8.3b2
SubmitDate: '2000-01-24'
LastModified: '2000-02-01'
Severity: MED
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: All Windows
FixedDate: '2000-02-01'
FixedInVersion: 8.3


Name:

Edward Lam


CustomShell:

Only added functionality was patched into the XGetGeometry function of the win\tkWinPixmap.c file. This should not affect existing behaviour.


Comments:

An added bonus with the way the Windows port is done is that simple X11 tcl/tk applications can be easily ported over to Windows as well with minimal hassle. This is exactly what caused me to patch my version tk. Perhaps an explicit export of the other functions in the Xlib library should be added to the X11 include files. This patch works for tk 8.2.3 and up. I haven't looked at this in the earlier versions.


DesiredBehavior:

This allows XGetGeometry to be used in Windows applications that get linked with the Tcl/Tk libraries (when ported from X11).


Patch:

*** tkWinPixmap.old.cMon Sep 14 14:24:00 1998

--- tkWinPixmap.cMon Jan 24 07:52:00 2000

***************

*** 165,184 ****

      TkWinDrawable *twdPtr = (TkWinDrawable *)d;

      HDC dc;

      BITMAPINFO info;


!     if ((twdPtr->type != TWD_BITMAP) || (twdPtr->bitmap.handle == NULL)) {

! panic("XGetGeometry: invalid pixmap");

!     }

!     dc = GetDC(NULL);

!     info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

!     info.bmiHeader.biBitCount = 0;

!     if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info,

!     DIB_RGB_COLORS)) {

! panic("XGetGeometry: unable to get bitmap size");

!     }

!     ReleaseDC(NULL, dc);


!     *width_return = info.bmiHeader.biWidth;

!     *height_return = info.bmiHeader.biHeight;

      return 1;

  }

--- 165,196 ----

      TkWinDrawable *twdPtr = (TkWinDrawable *)d;

      HDC dc;

      BITMAPINFO info;

+     RECT rect;


!     if (twdPtr->type == TWD_BITMAP) {

! if (twdPtr->bitmap.handle == NULL) {

!     panic("XGetGeometry: invalid pixmap");

! }

! dc = GetDC(NULL);

! info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);

! info.bmiHeader.biBitCount = 0;

! if (!GetDIBits(dc, twdPtr->bitmap.handle, 0, 0, NULL, &info,

! DIB_RGB_COLORS)) {

!     panic("XGetGeometry: unable to get bitmap size");

! }

! ReleaseDC(NULL, dc);


! *width_return = info.bmiHeader.biWidth;

! *height_return = info.bmiHeader.biHeight;

!     } else if (twdPtr->type == TWD_WINDOW) {

! if (twdPtr->window.handle == NULL) {

!     panic("XGetGeometry: invalid window");

! }

! GetClientRect(twdPtr->window.handle, &rect);

! *width_return = rect.right - rect.left;

! *height_return = rect.bottom - rect.top;

!     } else {

! panic("XGetGeometry: invalid window");

!     }

      return 1;

  }


PatchFiles:

win/tkWinPixmap.c




patch applied for 8.3.0. 
-- 02/01/2000 hobbs