blob: 6ca8c3530fea4fd09fa83bf3fbee28a04a3a21a3 [file] [log] [blame]
Constantin Kaplinsky729598c2006-05-25 05:12:25 +00001/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19// -=- WMCopyRect.cxx
20
21#include <rfb_win32/WMWindowCopyRect.h>
22#include <rfb/LogWriter.h>
23#include <windows.h>
24
25using namespace rfb;
26using namespace rfb::win32;
27
28static LogWriter vlog("WMCopyRect");
29
30// -=- WMHooks class
31
32rfb::win32::WMCopyRect::WMCopyRect() : ut(0), fg_window(0) {
33}
34
35bool
36rfb::win32::WMCopyRect::processEvent() {
37 // See if the foreground window has moved
38 HWND window = GetForegroundWindow();
39 if (window) {
40 RECT wrect;
41 if (IsWindow(window) && IsWindowVisible(window) && GetWindowRect(window, &wrect)) {
42 Rect winrect(wrect.left, wrect.top, wrect.right, wrect.bottom);
43 if (fg_window == window) {
44 if (!fg_window_rect.tl.equals(winrect.tl) && ut) {
Pierre Ossmancf647a32017-11-24 12:34:28 +010045 // Window has moved - mark both the previous and new position as changed
46 // (we can't use add_copied() here because we aren't that properly synced
47 // with the actual state of the framebuffer)
48 ut->add_changed(Region(winrect));
49 ut->add_changed(Region(fg_window_rect));
Constantin Kaplinsky729598c2006-05-25 05:12:25 +000050 }
51 }
52 fg_window = window;
53 fg_window_rect = winrect;
54 } else {
55 fg_window = 0;
56 }
57 } else {
58 fg_window = 0;
59 }
60 return false;
61}
62
63bool
64rfb::win32::WMCopyRect::setUpdateTracker(UpdateTracker* ut_) {
65 ut = ut_;
66 return true;
67}