| 138 | } |
| 139 | |
| 140 | void WindowPicker::mouseMoveEvent(QMouseEvent *event) |
| 141 | { |
| 142 | QString windowName; |
| 143 | |
| 144 | #if defined(Q_OS_WIN) |
| 145 | POINT mousePos; |
| 146 | mousePos.x = event->globalX(); |
| 147 | mousePos.y = event->globalY(); |
| 148 | |
| 149 | HWND cWindow = GetAncestor(WindowFromPoint(mousePos), GA_ROOT); |
| 150 | |
| 151 | mCurrentWindow = (WId) cWindow; |
| 152 | |
| 153 | if (mCurrentWindow == winId()) { |
| 154 | mWindowIcon->setPixmap(QPixmap()); |
| 155 | mWindowLabel->setText(""); |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | // Text |
| 160 | WCHAR str[60]; |
| 161 | HICON icon; |
| 162 | |
| 163 | ::GetWindowText((HWND)mCurrentWindow, str, 60); |
| 164 | windowName = QString::fromWCharArray(str); |
| 165 | /// |
| 166 | |
| 167 | // Retrieving the application icon |
| 168 | icon = (HICON)::GetClassLong((HWND)mCurrentWindow, GCL_HICON); |
| 169 | |
| 170 | if (icon != NULL) { |
| 171 | mWindowIcon->setPixmap(QtWin::fromHICON(icon)); |
| 172 | } else { |
| 173 | mWindowIcon->setPixmap(QPixmap()); |
| 174 | } |
| 175 | #elif defined(Q_OS_LINUX) |
| 176 | Window cWindow = os::windowUnderCursor(false); |
| 177 | |
| 178 | if (cWindow == mCurrentWindow) { |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | mCurrentWindow = cWindow; |
| 183 | |
| 184 | if (mCurrentWindow == winId()) { |
| 185 | mWindowIcon->setPixmap(QPixmap()); |
| 186 | mWindowLabel->setText(""); |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | // Getting the window name property. |
| 191 | XTextProperty tp; |
| 192 | char **text; |
| 193 | int count; |
| 194 | |
| 195 | if (XGetTextProperty(QX11Info::display(), cWindow, &tp, XA_WM_NAME) != 0 && tp.value != NULL) { |
| 196 | if (tp.encoding == XA_STRING) { |
| 197 | windowName = QString::fromLocal8Bit((const char *) tp.value); |