summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-11-01 14:37:09 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-11-30 14:26:30 +0000
commitfdf89414606254ca5fd0df640a277f5e6caa9565 (patch)
treecde96864f6713846a903340bcc91c93e63c535f6
parentb0255ec4a0ff509326d528c4370ab8960715bfb2 (diff)
Add layered windows opacity and fix mouse button numbers
Also, some warning fixes
-rw-r--r--TODO28
-rw-r--r--configure.ac2
-rw-r--r--src/Makefile.am7
-rw-r--r--src/debug.h1
-rw-r--r--src/main.c9
-rw-r--r--src/winkeybd.c29
-rw-r--r--src/winkeybd.h323
-rw-r--r--src/winvkmap.h303
-rw-r--r--src/wndproc.c (renamed from src/win.c)70
-rw-r--r--src/wndproc.h28
10 files changed, 446 insertions, 354 deletions
diff --git a/TODO b/TODO
index aa90a01..827fe3a 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,20 @@
TODO for XtoW
=============
+goals:
+
+* use xcb
+* not built into server
+* use native composting
+
new features
* we always have access to full contents of window (when mapped), so previewing, thumbnailing, etc. works correctly
* we have access to a window pixmap with alpha channel, so windows are composed into native desktop
+* interleaving of native and X windows in Z-order should work correctly
+* update WM without restarting X applications or server (for faster development :-))
+* fixes punch-through?
+* separate window message pump thread, so we can update window during modal loops (e.g. resizing)
features missing compared to XWin's integrated WM
@@ -24,11 +34,14 @@ getting the ones that the windows shell isn't using (e.g. Windows key, Menu key,
* Set the X keyboard configuration to match the native one
* Synchronize the X server modifier key state with the native one at startup, and whenever an X window gains focus (as modifiers might have been latched or unlatched without us noticing)
* Faster way of getting the bits onto the screen than GDI BitBlt() (e.g. DirectDraw)
+* -hostintitle option to add WM_CLIENT_MACHINE to window title, if not localhost
other stuff:
-* lcwm doesn't adopt any existing windows when it starts
-* lcwm doesn't understand about InputOnly windows (probably should just ignore them)
+* libxcwm doesn't adopt any existing windows when it starts
+* libxcwm doesn't understand about InputOnly windows (probably should just ignore them)
+* libxcwm doesn't looks at _MOTIF_WM_HINTS (maybe only hints we get from old motif applications?)
+* libxcwm assumes window properties are constant while mapped; this isn't true; for every property it looks at, it should also listen for changes to that property
* support the _NET_WM_WINDOW_OPACITY property using layered windows on XP, even if we can't use alpha
* Libraryize the code which is currently copied out of the Xserver
@@ -36,3 +49,14 @@ other stuff:
- XWin on MinGW is going to be around for a while, and I don't need the maintainance headache
* Implement -version command line option
+
+* xcwm doesn't really take advantage of xcb async in all places
+
+native compostion notes (08/11/11):
+
+- DwmEnableBlurBehindWindows()
+- UdpateLayeredWindow() - compose in a src bitmap with alpha channel; use for window position/size change as well for maximum rendering performance
+- SetLayeredWindowAttributes() - sets an alpha value for whole windows
+
+* XtoW needs to use libxcwm style conversion
+* Need to use RENDER rather than XCopyArea() to access image to ensure we get alpha???
diff --git a/configure.ac b/configure.ac
index 3cb8e91..0d0cb4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -14,6 +14,8 @@ m4_ifndef([XORG_MACROS_VERSION],
XORG_MACROS_VERSION(1.16)
XORG_DEFAULT_OPTIONS
+CFLAGS="-std=c99 -Wall -Wextra -Wmissing-prototypes $CFLAGS"
+
# check for programs
AC_PROG_CC
AC_PROG_INSTALL
diff --git a/src/Makefile.am b/src/Makefile.am
index 25f8a28..c2d539d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,11 +4,14 @@ bin_PROGRAMS = xtow
xtow_SOURCES = \
main.c \
- win.c \
+ wndproc.c \
+ wndproc.h \
+ winmessages.h \
debug.c \
debug.h \
winkeybd.c \
- winmessages.h \
+ winkeybd.h \
+ winvkmap.h \
scancodes.h
xtow_LDADD = $(XCWM_LIBS) -lgdi32
diff --git a/src/debug.h b/src/debug.h
index d446b77..16f3604 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -18,6 +18,7 @@
//
#if 1
+int debug(const char *format, ...);
#define DEBUG debug
#else
#define DEBUG(Args...)
diff --git a/src/main.c b/src/main.c
index 60ca79f..23cb99a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,6 +25,7 @@
#include "debug.h"
#include "global.h"
+#include "wndproc.h"
#define WM_XCWM_CREATE WM_USER
#define WM_XCWM_DESTROY (WM_USER+1)
@@ -32,7 +33,7 @@
xcwm_context_t *context;
DWORD msgPumpThread;
-void
+static void
eventHandler(const xcwm_event_t *event)
{
xcwm_window_t *window = xcwm_event_get_window(event);
@@ -71,7 +72,7 @@ eventHandler(const xcwm_event_t *event)
break;
}
- free(event);
+ free((void *)event);
}
static void
@@ -133,9 +134,9 @@ int main(int argc, char **argv)
while (GetMessage(&msg, NULL, 0, 0) > 0)
{
if (msg.message == WM_XCWM_CREATE)
- winCreateWindowsWindow(msg.lParam);
+ winCreateWindowsWindow((xcwm_window_t *)msg.lParam);
else if (msg.message == WM_XCWM_DESTROY)
- winDestroyWindowsWindow(msg.lParam);
+ winDestroyWindowsWindow((xcwm_window_t *)msg.lParam);
else
DispatchMessage(&msg);
}
diff --git a/src/winkeybd.c b/src/winkeybd.c
index 6444785..2401e1f 100644
--- a/src/winkeybd.c
+++ b/src/winkeybd.c
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012 Jon TURNEY
- *
+/*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
@@ -26,6 +25,7 @@
#include "debug.h"
#include "global.h"
+#include "winvkmap.h"
#include "winkeybd.h"
static bool g_winKeyState[NUM_KEYCODES];
@@ -39,13 +39,14 @@ static bool g_winKeyState[NUM_KEYCODES];
* like AltGr on European keyboards.
*/
-void
-winTranslateKey(WPARAM wParam, LPARAM lParam, int *piScanCode)
+int
+winTranslateKey(WPARAM wParam, LPARAM lParam)
{
int iKeyFixup = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 1];
int iKeyFixupEx = g_iKeyMap[wParam * WIN_KEYMAP_COLS + 2];
int iParam = HIWORD(lParam);
int iParamScanCode = LOBYTE(iParam);
+ int iScanCode;
DEBUG("winTranslateKey: wParam %08x lParam %08x\n", wParam, lParam);
@@ -70,23 +71,25 @@ winTranslateKey(WPARAM wParam, LPARAM lParam, int *piScanCode)
/* Branch on special extended, special non-extended, or normal key */
if ((iParam & KF_EXTENDED) && iKeyFixupEx)
- *piScanCode = iKeyFixupEx;
+ iScanCode = iKeyFixupEx;
else if (iKeyFixup)
- *piScanCode = iKeyFixup;
+ iScanCode = iKeyFixup;
else if (wParam == 0 && iParamScanCode == 0x70)
- *piScanCode = KEY_HKTG;
+ iScanCode = KEY_HKTG;
else
switch (iParamScanCode) {
case 0x70:
- *piScanCode = KEY_HKTG;
+ iScanCode = KEY_HKTG;
break;
case 0x73:
- *piScanCode = KEY_BSlash2;
+ iScanCode = KEY_BSlash2;
break;
default:
- *piScanCode = iParamScanCode;
+ iScanCode = iParamScanCode;
break;
}
+
+ return iScanCode;
}
/*
@@ -177,7 +180,7 @@ winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam)
/* Is next press an Alt_R with the same timestamp? */
if (fReturn && msgNext.wParam == VK_MENU
- && msgNext.time == lTime
+ && msgNext.time == (DWORD)lTime
&& (HIWORD(msgNext.lParam) & KF_EXTENDED)) {
/*
* Next key press is Alt_R with same timestamp as current
@@ -232,7 +235,7 @@ winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam)
if (fReturn
&& (msgNext.message == WM_KEYUP || msgNext.message == WM_SYSKEYUP)
&& msgNext.wParam == VK_MENU
- && msgNext.time == lTime
+ && msgNext.time == (DWORD)lTime
&& (HIWORD(msgNext.lParam) & KF_EXTENDED)) {
/*
* Next key release is Alt_R with same timestamp as current
@@ -252,7 +255,7 @@ winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
-BOOL
+bool
winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
{
switch (wParam) {
diff --git a/src/winkeybd.h b/src/winkeybd.h
index 287fbe8..b20376b 100644
--- a/src/winkeybd.h
+++ b/src/winkeybd.h
@@ -1,303 +1,30 @@
-/*
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
+//
+// Copyright © Jon TURNEY 2012
+//
+// This file is part of XtoW.
+//
+// XtoW is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// XtoW is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with XtoW. If not, see <http://www.gnu.org/licenses/>.
+//
#ifndef WINKEYBD_H
#define WINKEYBD_H
-/*
- * We need symbols for the scan codes of keys.
- */
-#include "scancodes.h"
+void winKeybdReleaseKeys(void);
+void winSendKeyEvent(DWORD dwKey, bool fDown);
+bool winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam);
+bool winCheckKeyPressed(WPARAM wParam, LPARAM lParam);
+int winTranslateKey(WPARAM wParam, LPARAM lParam);
+void winFixShiftKeys(int iScanCode);
-#define NUM_KEYCODES 248
-#define MIN_KEYCODE 8
-#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
-
-#define VK_FN 0xFF
-
-#define WIN_KEYMAP_COLS 3
-
-/* Rows 160 through 165 correspond to software-generated codes, which
- * may not be associated with the appropriate scan code.
- */
-const int
- g_iKeyMap[] = {
- /* count Windows VK, ASCII, ASCII when extended VK */
- /* 0 */ 0, 0, 0,
- /* 1 */ 0, 0, 0,
- /* 2 */ 0, 0, 0,
- /* 3 */ VK_CANCEL, 0, KEY_Break,
- /* 4 */ 0, 0, 0,
- /* 5 */ 0, 0, 0,
- /* 6 */ 0, 0, 0,
- /* 7 */ 0, 0, 0,
- /* 8 */ 0, 0, 0,
- /* 9 */ 0, 0, 0,
- /* 10 */ 0, 0, 0,
- /* 11 */ 0, 0, 0,
- /* 12 */ 0, 0, 0,
- /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
- /* 14 */ 0, 0, 0,
- /* 15 */ 0, 0, 0,
- /* 16 */ VK_SHIFT, 0, 0,
- /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
- /* 18 */ VK_MENU, 0, KEY_AltLang,
- /* 19 */ VK_PAUSE, KEY_Pause, 0,
- /* 20 */ 0, 0, 0,
- /* 21 */ 0, 0, 0,
- /* 22 */ 0, 0, 0,
- /* 23 */ 0, 0, 0,
- /* 24 */ 0, 0, 0,
- /* 25 */ 0, 0, 0,
- /* 26 */ 0, 0, 0,
- /* 27 */ 0, 0, 0,
- /* 28 */ 0, 0, 0,
- /* 29 */ 0, 0, 0,
- /* 30 */ 0, 0, 0,
- /* 31 */ 0, 0, 0,
- /* 32 */ 0, 0, 0,
- /* 33 */ VK_PRIOR, 0, KEY_PgUp,
- /* 34 */ VK_NEXT, 0, KEY_PgDown,
- /* 35 */ VK_END, 0, KEY_End,
- /* 36 */ VK_HOME, 0, KEY_Home,
- /* 37 */ VK_LEFT, 0, KEY_Left,
- /* 38 */ VK_UP, 0, KEY_Up,
- /* 39 */ VK_RIGHT, 0, KEY_Right,
- /* 40 */ VK_DOWN, 0, KEY_Down,
- /* 41 */ 0, 0, 0,
- /* 42 */ 0, 0, 0,
- /* 43 */ 0, 0, 0,
- /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
- /* 45 */ VK_INSERT, 0, KEY_Insert,
- /* 46 */ VK_DELETE, 0, KEY_Delete,
- /* 47 */ 0, 0, 0,
- /* 48 */ 0, 0, 0,
- /* 49 */ 0, 0, 0,
- /* 50 */ 0, 0, 0,
- /* 51 */ 0, 0, 0,
- /* 52 */ 0, 0, 0,
- /* 53 */ 0, 0, 0,
- /* 54 */ 0, 0, 0,
- /* 55 */ 0, 0, 0,
- /* 56 */ 0, 0, 0,
- /* 57 */ 0, 0, 0,
- /* 58 */ 0, 0, 0,
- /* 59 */ 0, 0, 0,
- /* 60 */ 0, 0, 0,
- /* 61 */ 0, 0, 0,
- /* 62 */ 0, 0, 0,
- /* 63 */ 0, 0, 0,
- /* 64 */ 0, 0, 0,
- /* 65 */ 0, 0, 0,
- /* 66 */ 0, 0, 0,
- /* 67 */ 0, 0, 0,
- /* 68 */ 0, 0, 0,
- /* 69 */ 0, 0, 0,
- /* 70 */ 0, 0, 0,
- /* 71 */ 0, 0, 0,
- /* 72 */ 0, 0, 0,
- /* 73 */ 0, 0, 0,
- /* 74 */ 0, 0, 0,
- /* 75 */ 0, 0, 0,
- /* 76 */ 0, 0, 0,
- /* 77 */ 0, 0, 0,
- /* 78 */ 0, 0, 0,
- /* 79 */ 0, 0, 0,
- /* 80 */ 0, 0, 0,
- /* 81 */ 0, 0, 0,
- /* 82 */ 0, 0, 0,
- /* 83 */ 0, 0, 0,
- /* 84 */ 0, 0, 0,
- /* 85 */ 0, 0, 0,
- /* 86 */ 0, 0, 0,
- /* 87 */ 0, 0, 0,
- /* 88 */ 0, 0, 0,
- /* 89 */ 0, 0, 0,
- /* 90 */ 0, 0, 0,
- /* 91 */ VK_LWIN, KEY_LMeta, 0,
- /* 92 */ VK_RWIN, KEY_RMeta, 0,
- /* 93 */ VK_APPS, KEY_Menu, 0,
- /* 94 */ 0, 0, 0,
- /* 95 */ 0, 0, 0,
- /* 96 */ 0, 0, 0,
- /* 97 */ 0, 0, 0,
- /* 98 */ 0, 0, 0,
- /* 99 */ 0, 0, 0,
- /* 100 */ 0, 0, 0,
- /* 101 */ 0, 0, 0,
- /* 102 */ 0, 0, 0,
- /* 103 */ 0, 0, 0,
- /* 104 */ 0, 0, 0,
- /* 105 */ 0, 0, 0,
- /* 106 */ 0, 0, 0,
- /* 107 */ 0, 0, 0,
- /* 108 */ 0, 0, 0,
- /* 109 */ 0, 0, 0,
- /* 110 */ 0, 0, 0,
- /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
- /* 112 */ 0, 0, 0,
- /* 113 */ 0, 0, 0,
- /* 114 */ 0, 0, 0,
- /* 115 */ 0, 0, 0,
- /* 116 */ 0, 0, 0,
- /* 117 */ 0, 0, 0,
- /* 118 */ 0, 0, 0,
- /* 119 */ 0, 0, 0,
- /* 120 */ 0, 0, 0,
- /* 121 */ 0, 0, 0,
- /* 122 */ 0, 0, 0,
- /* 123 */ 0, 0, 0,
- /* 124 */ 0, 0, 0,
- /* 125 */ 0, 0, 0,
- /* 126 */ 0, 0, 0,
- /* 127 */ 0, 0, 0,
- /* 128 */ 0, 0, 0,
- /* 129 */ 0, 0, 0,
- /* 130 */ 0, 0, 0,
- /* 131 */ 0, 0, 0,
- /* 132 */ 0, 0, 0,
- /* 133 */ 0, 0, 0,
- /* 134 */ 0, 0, 0,
- /* 135 */ 0, 0, 0,
- /* 136 */ 0, 0, 0,
- /* 137 */ 0, 0, 0,
- /* 138 */ 0, 0, 0,
- /* 139 */ 0, 0, 0,
- /* 140 */ 0, 0, 0,
- /* 141 */ 0, 0, 0,
- /* 142 */ 0, 0, 0,
- /* 143 */ 0, 0, 0,
- /* 144 */ 0, 0, 0,
- /* 145 */ 0, 0, 0,
- /* 146 */ 0, 0, 0,
- /* 147 */ 0, 0, 0,
- /* 148 */ 0, 0, 0,
- /* 149 */ 0, 0, 0,
- /* 150 */ 0, 0, 0,
- /* 151 */ 0, 0, 0,
- /* 152 */ 0, 0, 0,
- /* 153 */ 0, 0, 0,
- /* 154 */ 0, 0, 0,
- /* 155 */ 0, 0, 0,
- /* 156 */ 0, 0, 0,
- /* 157 */ 0, 0, 0,
- /* 158 */ 0, 0, 0,
- /* 159 */ 0, 0, 0,
- /* 160 */ VK_LSHIFT, KEY_ShiftL, 0,
- /* 161 */ VK_RSHIFT, KEY_ShiftR, 0,
- /* 162 */ VK_LCONTROL, KEY_LCtrl, 0,
- /* 163 */ VK_RCONTROL, KEY_RCtrl, 0,
- /* 164 */ VK_LMENU, KEY_Alt, 0,
- /* 165 */ VK_RMENU, KEY_AltLang, 0,
- /* 166 */ 0, 0, 0,
- /* 167 */ 0, 0, 0,
- /* 168 */ 0, 0, 0,
- /* 169 */ 0, 0, 0,
- /* 170 */ 0, 0, 0,
- /* 171 */ 0, 0, 0,
- /* 172 */ 0, 0, 0,
- /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
- /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
- /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
- /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
- /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
- /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
- /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
- /* 180 */ 0, 0, 0,
- /* 181 */ 0, 0, 0,
- /* 182 */ 0, 0, 0,
- /* 183 */ 0, 0, 0,
- /* 184 */ 0, 0, 0,
- /* 185 */ 0, 0, 0,
- /* 186 */ 0, 0, 0,
- /* 187 */ 0, 0, 0,
- /* 188 */ 0, 0, 0,
- /* 189 */ 0, 0, 0,
- /* 190 */ 0, 0, 0,
- /* 191 */ 0, 0, 0,
- /* 192 */ 0, 0, 0,
- /* 193 */ 0, 0, 0,
- /* 194 */ 0, 0, 0,
- /* 195 */ 0, 0, 0,
- /* 196 */ 0, 0, 0,
- /* 197 */ 0, 0, 0,
- /* 198 */ 0, 0, 0,
- /* 199 */ 0, 0, 0,
- /* 200 */ 0, 0, 0,
- /* 201 */ 0, 0, 0,
- /* 202 */ 0, 0, 0,
- /* 203 */ 0, 0, 0,
- /* 204 */ 0, 0, 0,
- /* 205 */ 0, 0, 0,
- /* 206 */ 0, 0, 0,
- /* 207 */ 0, 0, 0,
- /* 208 */ 0, 0, 0,
- /* 209 */ 0, 0, 0,
- /* 210 */ 0, 0, 0,
- /* 211 */ 0, 0, 0,
- /* 212 */ 0, 0, 0,
- /* 213 */ 0, 0, 0,
- /* 214 */ 0, 0, 0,
- /* 215 */ 0, 0, 0,
- /* 216 */ 0, 0, 0,
- /* 217 */ 0, 0, 0,
- /* 218 */ 0, 0, 0,
- /* 219 */ 0, 0, 0,
- /* 220 */ 0, 0, 0,
- /* 221 */ 0, 0, 0,
- /* 222 */ 0, 0, 0,
- /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Canadian Multilingual Standard layout */
- /* 224 */ 0, 0, 0,
- /* 225 */ 0, 0, 0,
- /* 226 */ 0, 0, 0,
- /* 227 */ 0, 0, 0,
- /* 228 */ 0, 0, 0,
- /* 229 */ 0, 0, 0,
- /* 230 */ 0, 0, 0,
- /* 231 */ 0, 0, 0,
- /* 232 */ 0, 0, 0,
- /* 233 */ 0, 0, 0,
- /* 234 */ 0, 0, 0,
- /* 235 */ 0, 0, 0,
- /* 236 */ 0, 0, 0,
- /* 237 */ 0, 0, 0,
- /* 238 */ 0, 0, 0,
- /* 239 */ 0, 0, 0,
- /* 240 */ 0, 0, 0,
- /* 241 */ 0, 0, 0,
- /* 242 */ 0, 0, 0,
- /* 243 */ 0, 0, 0,
- /* 244 */ 0, 0, 0,
- /* 245 */ 0, 0, 0,
- /* 246 */ 0, 0, 0,
- /* 247 */ 0, 0, 0,
- /* 248 */ 0, 0, 0,
- /* 249 */ 0, 0, 0,
- /* 250 */ 0, 0, 0,
- /* 251 */ 0, 0, 0,
- /* 252 */ 0, 0, 0,
- /* 253 */ 0, 0, 0,
- /* 254 */ 0, 0, 0,
- /* 255 */ VK_FN, 0, KEY_Fn /* Most keyboards don't generate a scancode for Fn, but a few do... */
-};
-
-#endif /* WINKEYBD_H */
+#endif /* WINKEYBD_H */
diff --git a/src/winvkmap.h b/src/winvkmap.h
new file mode 100644
index 0000000..017acab
--- /dev/null
+++ b/src/winvkmap.h
@@ -0,0 +1,303 @@
+/*
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WINVKMAP_H
+#define WINVKMAP_H
+
+/*
+ * We need symbols for the scan codes of keys.
+ */
+#include "scancodes.h"
+
+#define NUM_KEYCODES 248
+#define MIN_KEYCODE 8
+#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1)
+
+#define VK_FN 0xFF
+
+#define WIN_KEYMAP_COLS 3
+
+/* Rows 160 through 165 correspond to software-generated codes, which
+ * may not be associated with the appropriate scan code.
+ */
+const int
+ g_iKeyMap[] = {
+ /* count Windows VK, ASCII, ASCII when extended VK */
+ /* 0 */ 0, 0, 0,
+ /* 1 */ 0, 0, 0,
+ /* 2 */ 0, 0, 0,
+ /* 3 */ VK_CANCEL, 0, KEY_Break,
+ /* 4 */ 0, 0, 0,
+ /* 5 */ 0, 0, 0,
+ /* 6 */ 0, 0, 0,
+ /* 7 */ 0, 0, 0,
+ /* 8 */ 0, 0, 0,
+ /* 9 */ 0, 0, 0,
+ /* 10 */ 0, 0, 0,
+ /* 11 */ 0, 0, 0,
+ /* 12 */ 0, 0, 0,
+ /* 13 */ VK_RETURN, 0, KEY_KP_Enter,
+ /* 14 */ 0, 0, 0,
+ /* 15 */ 0, 0, 0,
+ /* 16 */ VK_SHIFT, 0, 0,
+ /* 17 */ VK_CONTROL, 0, KEY_RCtrl,
+ /* 18 */ VK_MENU, 0, KEY_AltLang,
+ /* 19 */ VK_PAUSE, KEY_Pause, 0,
+ /* 20 */ 0, 0, 0,
+ /* 21 */ 0, 0, 0,
+ /* 22 */ 0, 0, 0,
+ /* 23 */ 0, 0, 0,
+ /* 24 */ 0, 0, 0,
+ /* 25 */ 0, 0, 0,
+ /* 26 */ 0, 0, 0,
+ /* 27 */ 0, 0, 0,
+ /* 28 */ 0, 0, 0,
+ /* 29 */ 0, 0, 0,
+ /* 30 */ 0, 0, 0,
+ /* 31 */ 0, 0, 0,
+ /* 32 */ 0, 0, 0,
+ /* 33 */ VK_PRIOR, 0, KEY_PgUp,
+ /* 34 */ VK_NEXT, 0, KEY_PgDown,
+ /* 35 */ VK_END, 0, KEY_End,
+ /* 36 */ VK_HOME, 0, KEY_Home,
+ /* 37 */ VK_LEFT, 0, KEY_Left,
+ /* 38 */ VK_UP, 0, KEY_Up,
+ /* 39 */ VK_RIGHT, 0, KEY_Right,
+ /* 40 */ VK_DOWN, 0, KEY_Down,
+ /* 41 */ 0, 0, 0,
+ /* 42 */ 0, 0, 0,
+ /* 43 */ 0, 0, 0,
+ /* 44 */ VK_SNAPSHOT, 0, KEY_Print,
+ /* 45 */ VK_INSERT, 0, KEY_Insert,
+ /* 46 */ VK_DELETE, 0, KEY_Delete,
+ /* 47 */ 0, 0, 0,
+ /* 48 */ 0, 0, 0,
+ /* 49 */ 0, 0, 0,
+ /* 50 */ 0, 0, 0,
+ /* 51 */ 0, 0, 0,
+ /* 52 */ 0, 0, 0,
+ /* 53 */ 0, 0, 0,
+ /* 54 */ 0, 0, 0,
+ /* 55 */ 0, 0, 0,
+ /* 56 */ 0, 0, 0,
+ /* 57 */ 0, 0, 0,
+ /* 58 */ 0, 0, 0,
+ /* 59 */ 0, 0, 0,
+ /* 60 */ 0, 0, 0,
+ /* 61 */ 0, 0, 0,
+ /* 62 */ 0, 0, 0,
+ /* 63 */ 0, 0, 0,
+ /* 64 */ 0, 0, 0,
+ /* 65 */ 0, 0, 0,
+ /* 66 */ 0, 0, 0,
+ /* 67 */ 0, 0, 0,
+ /* 68 */ 0, 0, 0,
+ /* 69 */ 0, 0, 0,
+ /* 70 */ 0, 0, 0,
+ /* 71 */ 0, 0, 0,
+ /* 72 */ 0, 0, 0,
+ /* 73 */ 0, 0, 0,
+ /* 74 */ 0, 0, 0,
+ /* 75 */ 0, 0, 0,
+ /* 76 */ 0, 0, 0,
+ /* 77 */ 0, 0, 0,
+ /* 78 */ 0, 0, 0,
+ /* 79 */ 0, 0, 0,
+ /* 80 */ 0, 0, 0,
+ /* 81 */ 0, 0, 0,
+ /* 82 */ 0, 0, 0,
+ /* 83 */ 0, 0, 0,
+ /* 84 */ 0, 0, 0,
+ /* 85 */ 0, 0, 0,
+ /* 86 */ 0, 0, 0,
+ /* 87 */ 0, 0, 0,
+ /* 88 */ 0, 0, 0,
+ /* 89 */ 0, 0, 0,
+ /* 90 */ 0, 0, 0,
+ /* 91 */ VK_LWIN, KEY_LMeta, 0,
+ /* 92 */ VK_RWIN, KEY_RMeta, 0,
+ /* 93 */ VK_APPS, KEY_Menu, 0,
+ /* 94 */ 0, 0, 0,
+ /* 95 */ 0, 0, 0,
+ /* 96 */ 0, 0, 0,
+ /* 97 */ 0, 0, 0,
+ /* 98 */ 0, 0, 0,
+ /* 99 */ 0, 0, 0,
+ /* 100 */ 0, 0, 0,
+ /* 101 */ 0, 0, 0,
+ /* 102 */ 0, 0, 0,
+ /* 103 */ 0, 0, 0,
+ /* 104 */ 0, 0, 0,
+ /* 105 */ 0, 0, 0,
+ /* 106 */ 0, 0, 0,
+ /* 107 */ 0, 0, 0,
+ /* 108 */ 0, 0, 0,
+ /* 109 */ 0, 0, 0,
+ /* 110 */ 0, 0, 0,
+ /* 111 */ VK_DIVIDE, 0, KEY_KP_Divide,
+ /* 112 */ 0, 0, 0,
+ /* 113 */ 0, 0, 0,
+ /* 114 */ 0, 0, 0,
+ /* 115 */ 0, 0, 0,
+ /* 116 */ 0, 0, 0,
+ /* 117 */ 0, 0, 0,
+ /* 118 */ 0, 0, 0,
+ /* 119 */ 0, 0, 0,
+ /* 120 */ 0, 0, 0,
+ /* 121 */ 0, 0, 0,
+ /* 122 */ 0, 0, 0,
+ /* 123 */ 0, 0, 0,
+ /* 124 */ 0, 0, 0,
+ /* 125 */ 0, 0, 0,
+ /* 126 */ 0, 0, 0,
+ /* 127 */ 0, 0, 0,
+ /* 128 */ 0, 0, 0,
+ /* 129 */ 0, 0, 0,
+ /* 130 */ 0, 0, 0,
+ /* 131 */ 0, 0, 0,
+ /* 132 */ 0, 0, 0,
+ /* 133 */ 0, 0, 0,
+ /* 134 */ 0, 0, 0,
+ /* 135 */ 0, 0, 0,
+ /* 136 */ 0, 0, 0,
+ /* 137 */ 0, 0, 0,
+ /* 138 */ 0, 0, 0,
+ /* 139 */ 0, 0, 0,
+ /* 140 */ 0, 0, 0,
+ /* 141 */ 0, 0, 0,
+ /* 142 */ 0, 0, 0,
+ /* 143 */ 0, 0, 0,
+ /* 144 */ 0, 0, 0,
+ /* 145 */ 0, 0, 0,
+ /* 146 */ 0, 0, 0,
+ /* 147 */ 0, 0, 0,
+ /* 148 */ 0, 0, 0,
+ /* 149 */ 0, 0, 0,
+ /* 150 */ 0, 0, 0,
+ /* 151 */ 0, 0, 0,
+ /* 152 */ 0, 0, 0,
+ /* 153 */ 0, 0, 0,
+ /* 154 */ 0, 0, 0,
+ /* 155 */ 0, 0, 0,
+ /* 156 */ 0, 0, 0,
+ /* 157 */ 0, 0, 0,
+ /* 158 */ 0, 0, 0,
+ /* 159 */ 0, 0, 0,
+ /* 160 */ VK_LSHIFT, KEY_ShiftL, 0,
+ /* 161 */ VK_RSHIFT, KEY_ShiftR, 0,
+ /* 162 */ VK_LCONTROL, KEY_LCtrl, 0,
+ /* 163 */ VK_RCONTROL, KEY_RCtrl, 0,
+ /* 164 */ VK_LMENU, KEY_Alt, 0,
+ /* 165 */ VK_RMENU, KEY_AltLang, 0,
+ /* 166 */ 0, 0, 0,
+ /* 167 */ 0, 0, 0,
+ /* 168 */ 0, 0, 0,
+ /* 169 */ 0, 0, 0,
+ /* 170 */ 0, 0, 0,
+ /* 171 */ 0, 0, 0,
+ /* 172 */ 0, 0, 0,
+ /* 173 */ VK_VOLUME_MUTE, 0, KEY_Mute,
+ /* 174 */ VK_VOLUME_DOWN, 0, KEY_AudioLower,
+ /* 175 */ VK_VOLUME_UP, 0, KEY_AudioRaise,
+ /* 176 */ VK_MEDIA_NEXT_TRACK, 0, KEY_NEXTSONG,
+ /* 177 */ VK_MEDIA_PREV_TRACK, 0, KEY_PREVIOUSSONG,
+ /* 178 */ VK_MEDIA_STOP, 0, KEY_STOPCD,
+ /* 179 */ VK_MEDIA_PLAY_PAUSE, 0, KEY_PLAYPAUSE,
+ /* 180 */ 0, 0, 0,
+ /* 181 */ 0, 0, 0,
+ /* 182 */ 0, 0, 0,
+ /* 183 */ 0, 0, 0,
+ /* 184 */ 0, 0, 0,
+ /* 185 */ 0, 0, 0,
+ /* 186 */ 0, 0, 0,
+ /* 187 */ 0, 0, 0,
+ /* 188 */ 0, 0, 0,
+ /* 189 */ 0, 0, 0,
+ /* 190 */ 0, 0, 0,
+ /* 191 */ 0, 0, 0,
+ /* 192 */ 0, 0, 0,
+ /* 193 */ 0, 0, 0,
+ /* 194 */ 0, 0, 0,
+ /* 195 */ 0, 0, 0,
+ /* 196 */ 0, 0, 0,
+ /* 197 */ 0, 0, 0,
+ /* 198 */ 0, 0, 0,
+ /* 199 */ 0, 0, 0,
+ /* 200 */ 0, 0, 0,
+ /* 201 */ 0, 0, 0,
+ /* 202 */ 0, 0, 0,
+ /* 203 */ 0, 0, 0,
+ /* 204 */ 0, 0, 0,
+ /* 205 */ 0, 0, 0,
+ /* 206 */ 0, 0, 0,
+ /* 207 */ 0, 0, 0,
+ /* 208 */ 0, 0, 0,
+ /* 209 */ 0, 0, 0,
+ /* 210 */ 0, 0, 0,
+ /* 211 */ 0, 0, 0,
+ /* 212 */ 0, 0, 0,
+ /* 213 */ 0, 0, 0,
+ /* 214 */ 0, 0, 0,
+ /* 215 */ 0, 0, 0,
+ /* 216 */ 0, 0, 0,
+ /* 217 */ 0, 0, 0,
+ /* 218 */ 0, 0, 0,
+ /* 219 */ 0, 0, 0,
+ /* 220 */ 0, 0, 0,
+ /* 221 */ 0, 0, 0,
+ /* 222 */ 0, 0, 0,
+ /* 223 */ VK_OEM_8, 0, KEY_RCtrl, /* at least on Canadian Multilingual Standard layout */
+ /* 224 */ 0, 0, 0,
+ /* 225 */ 0, 0, 0,
+ /* 226 */ 0, 0, 0,
+ /* 227 */ 0, 0, 0,
+ /* 228 */ 0, 0, 0,
+ /* 229 */ 0, 0, 0,
+ /* 230 */ 0, 0, 0,
+ /* 231 */ 0, 0, 0,
+ /* 232 */ 0, 0, 0,
+ /* 233 */ 0, 0, 0,
+ /* 234 */ 0, 0, 0,
+ /* 235 */ 0, 0, 0,
+ /* 236 */ 0, 0, 0,
+ /* 237 */ 0, 0, 0,
+ /* 238 */ 0, 0, 0,
+ /* 239 */ 0, 0, 0,
+ /* 240 */ 0, 0, 0,
+ /* 241 */ 0, 0, 0,
+ /* 242 */ 0, 0, 0,
+ /* 243 */ 0, 0, 0,
+ /* 244 */ 0, 0, 0,
+ /* 245 */ 0, 0, 0,
+ /* 246 */ 0, 0, 0,
+ /* 247 */ 0, 0, 0,
+ /* 248 */ 0, 0, 0,
+ /* 249 */ 0, 0, 0,
+ /* 250 */ 0, 0, 0,
+ /* 251 */ 0, 0, 0,
+ /* 252 */ 0, 0, 0,
+ /* 253 */ 0, 0, 0,
+ /* 254 */ 0, 0, 0,
+ /* 255 */ VK_FN, 0, KEY_Fn /* Most keyboards don't generate a scancode for Fn, but a few do... */
+};
+
+#endif /* WINVKMAP_H */
diff --git a/src/win.c b/src/wndproc.c
index fba4ae0..fbd06f0 100644
--- a/src/win.c
+++ b/src/wndproc.c
@@ -31,6 +31,8 @@
#include "debug.h"
#include "winmessages.h"
+#include "winkeybd.h"
+#include "wndproc.h"
#define WINDOW_CLASS_X "xtow"
#define WINDOW_TITLE_X "X"
@@ -126,7 +128,7 @@ ClientToXCoord(HWND hWnd, POINT *pt)
* The functionality is the inverse of winPositionWindowMultiWindow, which
* adjusts Windows window with respect to X window.
*/
-int
+static int
winAdjustXWindow (xcwm_window_t *window, HWND hWnd)
{
RECT rcWin;
@@ -213,8 +215,7 @@ UpdateImage(xcwm_window_t *window)
damage.bottom = dmgRect->y + dmgRect->height;
DEBUG("UpdateImage: invalidating %dx%d @ %d,%d on HWND 0x08%x\n", dmgRect->width, dmgRect->height, damage.left, damage.top, hWnd);
- // InvalidateRect(hWnd, &damage, TRUE);
- InvalidateRect(hWnd, NULL, TRUE); // invalidate whole window for a test
+ InvalidateRect(hWnd, &damage, FALSE);
}
#if 0
@@ -481,7 +482,7 @@ UpdateStyle(struct client *pWin)
#endif
/* Don't allow window decoration to disappear off to top-left */
-void
+static void
BumpWindowPosition(HWND hWnd)
{
WINDOWINFO wi;
@@ -530,12 +531,13 @@ winStartMousePolling(void)
static bool g_fButton[3] = { FALSE, FALSE, FALSE };
-int
+static int
winMouseButtonsHandle(xcwm_window_t *window, bool press, int iButton, HWND hWnd, LPARAM lParam)
{
/* 3 button emulation code would go here, if we thought anyone actually needed it anymore... */
- g_fButton[iButton] = press;
+ g_fButton[iButton-1] = press;
+
if (press)
{
SetCapture(hWnd);
@@ -593,7 +595,7 @@ winDebugWin32Message(const char* function, HWND hWnd, UINT message, WPARAM wPara
* winTopLevelWindowProc - Window procedure for all top-level Windows windows.
*/
-LRESULT CALLBACK
+static LRESULT CALLBACK
winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bool hasEnteredSizeMove = FALSE;
@@ -663,6 +665,8 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CLOSE:
xcwm_window_request_close(window);
+ // XXX: RACE!!! window will become invalid when we get XCB_DESTROY_NOTIFY back from server
+ // but this wndproc may continue to touch it until we get WM_DESTROY..
return 0;
case WM_DESTROY:
@@ -813,23 +817,22 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
image = xcwm_image_copy_damaged(window);
if (image)
{
- xcwm_rect_t *winRect = xcwm_window_get_full_rect(window);
+ // xcwm_rect_t *winRect = xcwm_window_get_full_rect(window);
xcwm_rect_t *dmgRect = xcwm_window_get_damaged_rect(window);
- DEBUG("full_rect is %ldx%ld @ (%ld, %ld)\n", winRect->width, winRect->height, winRect->x, winRect->y);
- DEBUG("damaged rect is %ldx%ld @ (%ld, %ld)\n", dmgRect->width, dmgRect->height, dmgRect->x, dmgRect->y);
- DEBUG("invalidated rect is %ldx%ld @ (%ld, %ld)\n", ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, ps.rcPaint.left, ps.rcPaint.top);
+ // DEBUG("full_rect is %ldx%ld @ (%ld, %ld)\n", winRect->width, winRect->height, winRect->x, winRect->y);
+ // DEBUG("damaged rect is %ldx%ld @ (%ld, %ld)\n", dmgRect->width, dmgRect->height, dmgRect->x, dmgRect->y);
+ // DEBUG("invalidated rect is %ldx%ld @ (%ld, %ld)\n", ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, ps.rcPaint.left, ps.rcPaint.top);
assert(image->image->scanline_pad = 32); // DIBs are always 32 bit aligned
assert(((int)image->image->data % 4) == 0); // ?
- // XXX: probably should use BITMAPV5HEADER ?
// describe the bitmap format we are given
BITMAPINFO diBmi;
memset(&diBmi, 0, sizeof(diBmi));
diBmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
diBmi.bmiHeader.biWidth = image->width;
- diBmi.bmiHeader.biHeight = -image->height;
+ diBmi.bmiHeader.biHeight = -image->height; // top-down bitmap
diBmi.bmiHeader.biPlanes = 1;
diBmi.bmiHeader.biBitCount = image->image->bpp;
diBmi.bmiHeader.biCompression = BI_RGB;
@@ -838,19 +841,13 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
diBmi.bmiHeader.biClrImportant = 0;
// diBmi.bmiColors unused unless biBitCount is 8 or less, or biCompression is BI_BITFIELDS, or biClrUsed is non-zero...
-#if 0
- int lines = SetDIBitsToDevice(hdcUpdate, dmgRect->x, dmgRect->y, dmgRect->width, dmgRect->height,
- 0, 0, 0, image->height, image->image->data, &diBmi, DIB_RGB_COLORS);
-#endif
-
int lines = StretchDIBits(hdcUpdate,
dmgRect->x, dmgRect->y, dmgRect->width, dmgRect->height,
0, 0, image->width, image->height,
image->image->data, &diBmi, DIB_RGB_COLORS, SRCCOPY);
- DEBUG("returned %d\n", lines);
- if (lines == 0)
- fprintf(stderr, "failed: 0x%08x\n", GetLastError());
+ if (lines <= 0)
+ fprintf(stderr, "StretchDIBits: returned %d, failed: 0x%08lx\n", lines, GetLastError());
#if 0
// create compatible DC, create a device compatible bitmap from the image, and select it into the DC
@@ -861,7 +858,7 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
// transfer the bits from our compatible DC to the display
if (!BitBlt(hdcUpdate, dmgRect->x, dmgRect->y, dmgRect->width, dmgRect->height, hdcMem, 0, 0, SRCCOPY))
{
- fprintf(stderr, "winTopLevelWindowProc: BitBlt failed: 0x%08x\n", GetLastError());
+ fprintf(stderr, "winTopLevelWindowProc: BitBlt failed: 0x%08lx\n", GetLastError());
}
SelectObject(hdcMem, hStockBitmap);
@@ -917,8 +914,7 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
/* Translate Windows key code to X scan code */
- int iScanCode;
- winTranslateKey(wParam, lParam, &iScanCode);
+ int iScanCode = winTranslateKey(wParam, lParam);
/* Ignore press repeats for CapsLock */
if (press && (wParam == VK_CAPITAL))
@@ -927,7 +923,7 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/* Send the key event(s) */
int i;
for (i = 0; i < LOWORD(lParam); ++i)
- winSendKeyEvent(iScanCode, TRUE);
+ winSendKeyEvent(iScanCode, press);
/* Release all pressed shift keys */
if (!press && (wParam == VK_SHIFT))
@@ -987,24 +983,24 @@ winTopLevelWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- return winMouseButtonsHandle(window, TRUE, 0, hWnd, lParam);
+ return winMouseButtonsHandle(window, TRUE, 1, hWnd, lParam);
case WM_LBUTTONUP:
- return winMouseButtonsHandle(window, FALSE, 0, hWnd, lParam);
+ return winMouseButtonsHandle(window, FALSE, 1, hWnd, lParam);
case WM_MBUTTONDBLCLK:
case WM_MBUTTONDOWN:
- return winMouseButtonsHandle(window, TRUE, 1, hWnd, lParam);
+ return winMouseButtonsHandle(window, TRUE, 2, hWnd, lParam);
case WM_MBUTTONUP:
- return winMouseButtonsHandle(window, FALSE, 1, hWnd, lParam);
+ return winMouseButtonsHandle(window, FALSE, 2, hWnd, lParam);
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
- return winMouseButtonsHandle(window, TRUE, 2, hWnd, lParam);
+ return winMouseButtonsHandle(window, TRUE, 3, hWnd, lParam);
case WM_RBUTTONUP:
- return winMouseButtonsHandle(window, FALSE, 2, hWnd, lParam);
+ return winMouseButtonsHandle(window, FALSE, 3, hWnd, lParam);
case WM_XBUTTONDBLCLK:
case WM_XBUTTONDOWN:
@@ -1117,7 +1113,7 @@ winCreateWindowsWindow(xcwm_window_t *window)
/* Make it WS_OVERLAPPED in create call since WS_POPUP doesn't support */
/* CW_USEDEFAULT, change back to popup after creation */
dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
- dwExStyle = WS_EX_TOOLWINDOW;
+ dwExStyle = WS_EX_TOOLWINDOW | WS_EX_LAYERED;
/*
Calculate the window coordinates containing the requested client area,
@@ -1196,8 +1192,8 @@ winCreateWindowsWindow(xcwm_window_t *window)
}
/* XXX: set reasonable style, for now */
- SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW);
- SetWindowLongPtr(hWnd, GWL_STYLE, GetWindowLongPtr(hWnd, GWL_STYLE) | WS_SYSMENU | WS_BORDER | WS_CAPTION);
+ SetWindowLongPtr(hWnd, GWL_EXSTYLE, (GetWindowLongPtr(hWnd, GWL_STYLE) & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW);
+ SetWindowLongPtr(hWnd, GWL_STYLE, GetWindowLongPtr(hWnd, GWL_STYLE) | WS_SYSMENU | WS_BORDER | WS_CAPTION | WS_SIZEBOX);
/* Apply all properties which effect the window appearance or behaviour */
UpdateName(window);
@@ -1213,7 +1209,11 @@ winCreateWindowsWindow(xcwm_window_t *window)
/* Display the window without activating it */
if (attr->_class != XCB_WINDOW_CLASS_INPUT_ONLY)
#endif
- ShowWindow (hWnd, SW_SHOWNOACTIVATE);
+ {
+ BYTE bAlpha = xcwm_window_get_opacity(window) >> 24;
+ SetLayeredWindowAttributes(hWnd, RGB(0,0,0), bAlpha, LWA_ALPHA);
+ ShowWindow(hWnd, SW_SHOWNOACTIVATE);
+ }
}
void
diff --git a/src/wndproc.h b/src/wndproc.h
new file mode 100644
index 0000000..ef58de7
--- /dev/null
+++ b/src/wndproc.h
@@ -0,0 +1,28 @@
+//
+// Copyright © Jon TURNEY 2012
+//
+// This file is part of XtoW.
+//
+// XtoW is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// XtoW is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with XtoW. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#ifndef WNDPROC_H
+#define WNDPROC_H
+
+void UpdateName(xcwm_window_t *window);
+void UpdateImage(xcwm_window_t *window);
+void winCreateWindowsWindow(xcwm_window_t *window);
+void winDestroyWindowsWindow(xcwm_window_t *window);
+
+#endif /* WNDPROC_H */