mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
parent
96bbec5fa4
commit
c5d9fd14b7
1 changed files with 31 additions and 35 deletions
|
@ -1401,31 +1401,41 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
|||
if (w == 0 || h == 0)
|
||||
return QPixmap();
|
||||
|
||||
Window unusedroot;
|
||||
int unusedx;
|
||||
int unusedy;
|
||||
uint width;
|
||||
uint height;
|
||||
uint unusedborderwidth;
|
||||
uint depth;
|
||||
XGetGeometry(
|
||||
qt_x11Data->display,
|
||||
window,
|
||||
&unusedroot, &unusedx, &unusedy,
|
||||
&width, &height,
|
||||
&unusedborderwidth,
|
||||
&depth
|
||||
);
|
||||
XWindowAttributes window_attr;
|
||||
if (!XGetWindowAttributes(qt_x11Data->display, window, &window_attr))
|
||||
return QPixmap();
|
||||
|
||||
if (w < 0)
|
||||
w = width - x;
|
||||
w = window_attr.width - x;
|
||||
if (h < 0)
|
||||
h = height - y;
|
||||
h = window_attr.height - y;
|
||||
|
||||
return QPixmap::fromX11Pixmap(window).copy(x, y, w, h);
|
||||
}
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
/*!
|
||||
\since 4.5
|
||||
|
||||
Creates a QPixmap from the native X11 Pixmap handle \a pixmap.
|
||||
|
||||
\warning This function is X11 specific; using it is non-portable.
|
||||
*/
|
||||
QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap)
|
||||
{
|
||||
Window root;
|
||||
int x;
|
||||
int y;
|
||||
uint width;
|
||||
uint height;
|
||||
uint border_width;
|
||||
uint depth;
|
||||
XGetGeometry(qt_x11Data->display, pixmap, &root, &x, &y, &width, &height, &border_width, &depth);
|
||||
|
||||
XImage *ximage = XGetImage(
|
||||
qt_x11Data->display, window,
|
||||
x, y,
|
||||
w, h,
|
||||
qt_x11Data->display, pixmap,
|
||||
0, 0, // x and y
|
||||
width, height,
|
||||
AllPlanes, (depth == 1) ? XYPixmap : ZPixmap
|
||||
);
|
||||
if (Q_UNLIKELY(!ximage)) {
|
||||
|
@ -1441,7 +1451,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
|||
} else if (depth == 32 && qt_x11Data->use_xrender) {
|
||||
format = QImage::Format_ARGB32_Premultiplied;
|
||||
}
|
||||
QImage image(w, h, format);
|
||||
QImage image(width, height, format);
|
||||
if (image.depth() == 1) {
|
||||
image.setColorTable(monoColorTable());
|
||||
}
|
||||
|
@ -1450,20 +1460,6 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
|||
return QPixmap::fromImage(image);
|
||||
}
|
||||
|
||||
#if defined(Q_WS_X11)
|
||||
/*!
|
||||
\since 4.5
|
||||
|
||||
Creates a QPixmap from the native X11 Pixmap handle \a pixmap.
|
||||
|
||||
\warning This function is X11 specific; using it is non-portable.
|
||||
*/
|
||||
QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap)
|
||||
{
|
||||
// to X Pixmap and Window are just "Drawable"
|
||||
return QPixmap::grabWindow(pixmap);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.12
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue