summaryrefslogtreecommitdiff
path: root/tk/win/tkWinPixmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'tk/win/tkWinPixmap.c')
-rw-r--r--tk/win/tkWinPixmap.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/tk/win/tkWinPixmap.c b/tk/win/tkWinPixmap.c
index 7dae990623a..62b90180aee 100644
--- a/tk/win/tkWinPixmap.c
+++ b/tk/win/tkWinPixmap.c
@@ -138,7 +138,7 @@ TkSetPixmapColormap(pixmap, colormap)
*
* Retrieve the geometry of the given drawable. Note that
* this is a degenerate implementation that only returns the
- * size of a pixmap.
+ * size of a pixmap or window.
*
* Results:
* Returns 0.
@@ -163,22 +163,37 @@ XGetGeometry(display, d, root_return, x_return, y_return, width_return,
unsigned int* depth_return;
{
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);
+ if (twdPtr->type == TWD_BITMAP) {
+ HDC dc;
+ BITMAPINFO info;
+
+ 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) {
+ RECT rect;
- *width_return = info.bmiHeader.biWidth;
- *height_return = info.bmiHeader.biHeight;
+ 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;
}
+