История изменений
Исправление Obey-Kun, (текущая версия) :
Там так (src/core/core.cpp):
#ifdef Q_WS_X11
void Core::getActiveWind_X11()
{
netwm::init();
Window *wnd = reinterpret_cast<ulong *>(netwm::property(QX11Info::appRootWindow(), NET_ACTIVE_WINDOW, XA_WINDOW));
if(!wnd)
{
*pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId());
exit(1);
}
// no dectortions option is select
if (conf->getNoDecorX11() == true)
{
*pixelMap = QPixmap::grabWindow(*wnd);
return;
}
unsigned int d;
int status;
int stat;
// if (status != 0) {
Window rt, *children, parent;
// Find window manager frame
while (true)
{
status = XQueryTree(QX11Info::display(), *wnd, &rt, &parent, &children, &d);
if (status && (children != None))
{
XFree((char *) children);
}
if (!status || (parent == None) || (parent == rt))
{
break;
}
*wnd = parent;
}
XWindowAttributes attr; // window attributes
stat = XGetWindowAttributes(QX11Info::display(), *wnd, &attr);
if ((stat == False) || (attr.map_state != IsViewable))
{
CmdLine::print("Not window attributes.");
}
// get wnd size
int rx = 0, ry = 0, rw = 0, rh = 0;
rw = attr.width;
rh = attr.height;
rx = attr.x;
ry = attr.y;
*pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId(), rx, ry, rw, rh);
XFree(wnd);
}
#endif
#ifdef Q_WS_WIN
void Core::getActiveWind_Win32()
{
HWND findWindow = GetForegroundWindow();
if (findWindow == NULL)
{
return;
}
if (findWindow == GetDesktopWindow())
{
return;
}
ShowWindow(findWindow, SW_SHOW);
SetForegroundWindow(findWindow);
HDC hdcScreen = GetDC(NULL);
RECT rcWindow;
GetWindowRect(findWindow, &rcWindow);
if (IsZoomed(findWindow))
{
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
{
rcWindow.right -= 8;
rcWindow.left += 8;
rcWindow.top += 8;
rcWindow.bottom -= 8;
}
else
{
rcWindow.right += 4;
rcWindow.left -= 4;
rcWindow.top += 4;
rcWindow.bottom -= 4;
}
}
HDC hdcMem = CreateCompatibleDC(hdcScreen);
HBITMAP hbmCapture = CreateCompatibleBitmap(hdcScreen, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
SelectObject(hdcMem, hbmCapture);
BitBlt(hdcMem, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, hdcScreen, rcWindow.left, rcWindow.top, SRCCOPY);
ReleaseDC(findWindow, hdcMem);
DeleteDC(hdcMem);
*pixelMap = QPixmap::fromWinHBITMAP(hbmCapture);
DeleteObject(hbmCapture);
}
#endif
Только не делай такой странный подход — вместо двух функций с разными названиями сделай одну, в которую уже засунь ос-зависимые ifdef'ы.
Исходная версия Obey-Kun, :
Там так:
#ifdef Q_WS_X11
void Core::getActiveWind_X11()
{
netwm::init();
Window *wnd = reinterpret_cast<ulong *>(netwm::property(QX11Info::appRootWindow(), NET_ACTIVE_WINDOW, XA_WINDOW));
if(!wnd)
{
*pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId());
exit(1);
}
// no dectortions option is select
if (conf->getNoDecorX11() == true)
{
*pixelMap = QPixmap::grabWindow(*wnd);
return;
}
unsigned int d;
int status;
int stat;
// if (status != 0) {
Window rt, *children, parent;
// Find window manager frame
while (true)
{
status = XQueryTree(QX11Info::display(), *wnd, &rt, &parent, &children, &d);
if (status && (children != None))
{
XFree((char *) children);
}
if (!status || (parent == None) || (parent == rt))
{
break;
}
*wnd = parent;
}
XWindowAttributes attr; // window attributes
stat = XGetWindowAttributes(QX11Info::display(), *wnd, &attr);
if ((stat == False) || (attr.map_state != IsViewable))
{
CmdLine::print("Not window attributes.");
}
// get wnd size
int rx = 0, ry = 0, rw = 0, rh = 0;
rw = attr.width;
rh = attr.height;
rx = attr.x;
ry = attr.y;
*pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId(), rx, ry, rw, rh);
XFree(wnd);
}
#endif
#ifdef Q_WS_WIN
void Core::getActiveWind_Win32()
{
HWND findWindow = GetForegroundWindow();
if (findWindow == NULL)
{
return;
}
if (findWindow == GetDesktopWindow())
{
return;
}
ShowWindow(findWindow, SW_SHOW);
SetForegroundWindow(findWindow);
HDC hdcScreen = GetDC(NULL);
RECT rcWindow;
GetWindowRect(findWindow, &rcWindow);
if (IsZoomed(findWindow))
{
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
{
rcWindow.right -= 8;
rcWindow.left += 8;
rcWindow.top += 8;
rcWindow.bottom -= 8;
}
else
{
rcWindow.right += 4;
rcWindow.left -= 4;
rcWindow.top += 4;
rcWindow.bottom -= 4;
}
}
HDC hdcMem = CreateCompatibleDC(hdcScreen);
HBITMAP hbmCapture = CreateCompatibleBitmap(hdcScreen, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top);
SelectObject(hdcMem, hbmCapture);
BitBlt(hdcMem, 0, 0, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, hdcScreen, rcWindow.left, rcWindow.top, SRCCOPY);
ReleaseDC(findWindow, hdcMem);
DeleteDC(hdcMem);
*pixelMap = QPixmap::fromWinHBITMAP(hbmCapture);
DeleteObject(hbmCapture);
}
#endif
Только не делай такой странный подход — вместо двух функций с разными названиями сделай одну, в которую уже засунь ос-зависимые ifdef'ы.