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)
|
if (w == 0 || h == 0)
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
|
|
||||||
Window unusedroot;
|
XWindowAttributes window_attr;
|
||||||
int unusedx;
|
if (!XGetWindowAttributes(qt_x11Data->display, window, &window_attr))
|
||||||
int unusedy;
|
return QPixmap();
|
||||||
uint width;
|
|
||||||
uint height;
|
|
||||||
uint unusedborderwidth;
|
|
||||||
uint depth;
|
|
||||||
XGetGeometry(
|
|
||||||
qt_x11Data->display,
|
|
||||||
window,
|
|
||||||
&unusedroot, &unusedx, &unusedy,
|
|
||||||
&width, &height,
|
|
||||||
&unusedborderwidth,
|
|
||||||
&depth
|
|
||||||
);
|
|
||||||
|
|
||||||
if (w < 0)
|
if (w < 0)
|
||||||
w = width - x;
|
w = window_attr.width - x;
|
||||||
if (h < 0)
|
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(
|
XImage *ximage = XGetImage(
|
||||||
qt_x11Data->display, window,
|
qt_x11Data->display, pixmap,
|
||||||
x, y,
|
0, 0, // x and y
|
||||||
w, h,
|
width, height,
|
||||||
AllPlanes, (depth == 1) ? XYPixmap : ZPixmap
|
AllPlanes, (depth == 1) ? XYPixmap : ZPixmap
|
||||||
);
|
);
|
||||||
if (Q_UNLIKELY(!ximage)) {
|
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) {
|
} else if (depth == 32 && qt_x11Data->use_xrender) {
|
||||||
format = QImage::Format_ARGB32_Premultiplied;
|
format = QImage::Format_ARGB32_Premultiplied;
|
||||||
}
|
}
|
||||||
QImage image(w, h, format);
|
QImage image(width, height, format);
|
||||||
if (image.depth() == 1) {
|
if (image.depth() == 1) {
|
||||||
image.setColorTable(monoColorTable());
|
image.setColorTable(monoColorTable());
|
||||||
}
|
}
|
||||||
|
@ -1450,20 +1460,6 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
|
||||||
return QPixmap::fromImage(image);
|
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
|
\since 4.12
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue