source: trunk/src/user32/oslibmsg.cpp@ 1067

Last change on this file since 1067 was 1067, checked in by sandervl, 26 years ago

Keyboard msg fixes

File size: 4.1 KB
Line 
1/* $Id: oslibmsg.cpp,v 1.3 1999-09-26 22:24:28 sandervl Exp $ */
2/*
3 * Window message translation functions for OS/2
4 *
5 *
6 * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 * TODO: Simply copy for now. Need to make a real translation
12 *
13 */
14#define INCL_WIN
15#define INCL_PM
16#define INCL_DOSPROCESS
17#include <os2.h>
18#include <os2wrap.h>
19#include <string.h>
20#include <misc.h>
21#include "oslibmsg.h"
22#include <win32wnd.h>
23#include "oslibutil.h"
24#include "timer.h"
25#include <thread.h>
26#include <wprocess.h>
27
28QMSG *MsgThreadPtr = 0;
29
30//******************************************************************************
31//******************************************************************************
32BOOL OSLibInitMsgQueue()
33{
34 if(DosAllocThreadLocalMemory(sizeof(QMSG)/sizeof(ULONG), (PULONG *)&MsgThreadPtr) != 0)
35 {
36 dprintf(("OSLibInitMsgQueue: local thread memory alloc failed!!"));
37 DebugInt3();
38 return FALSE;
39 }
40 return TRUE;
41}
42//******************************************************************************
43//******************************************************************************
44void WinToOS2MsgTranslate(MSG *winMsg, QMSG *os2Msg, BOOL isUnicode)
45{
46 memcpy(os2Msg, winMsg, sizeof(MSG));
47 os2Msg->reserved = 0;
48}
49//******************************************************************************
50//******************************************************************************
51void OS2ToWinMsgTranslate(QMSG *os2Msg, MSG *winMsg, BOOL isUnicode)
52{
53 memcpy(winMsg, os2Msg, sizeof(MSG));
54 winMsg->hwnd = Win32Window::OS2ToWin32Handle(os2Msg->hwnd);
55}
56//******************************************************************************
57//TODO!!!
58//Signal that the incoming messages in pmwindow need to be translated
59//(i.e. PM WM_CHAR when translated generates WM_CHAR messages, otherwise
60// WM_KEYUP/DOWN (etc))
61//******************************************************************************
62ULONG TranslateWinMsg(ULONG msg)
63{
64 THDB *thdb;
65
66 thdb = GetThreadTHDB();
67 if(thdb) {
68 thdb->fMsgTranslated = TRUE;
69 }
70
71 return 0;
72}
73//******************************************************************************
74//******************************************************************************
75void OSLibWinPostQuitMessage(ULONG nExitCode)
76{
77 WinPostQueueMsg(NULLHANDLE, WM_QUIT, (MPARAM)nExitCode, 0);
78}
79//******************************************************************************
80//******************************************************************************
81LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
82{
83//TODO: What to do if app changed msg? (translate)
84// WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
85
86 return (LONG)WinDispatchMsg(GetThreadHAB(), MsgThreadPtr);
87}
88//******************************************************************************
89//******************************************************************************
90BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
91 BOOL isUnicode)
92{
93 BOOL rc, eaten;
94
95 do {
96 eaten = FALSE;
97 rc = WinGetMsg(GetThreadHAB(), MsgThreadPtr, TranslateWinMsg(uMsgFilterMin), TranslateWinMsg(uMsgFilterMax), 0);
98 if (MsgThreadPtr->msg == WM_TIMER)
99 eaten = TIMER_HandleTimer (MsgThreadPtr);
100 } while (eaten);
101
102 OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
103 return rc;
104}
105//******************************************************************************
106//******************************************************************************
107BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, UINT uMsgFilterMax,
108 BOOL fRemove, BOOL isUnicode)
109{
110 BOOL rc;
111
112 rc = WinPeekMsg(GetThreadHAB(), MsgThreadPtr, hwnd, TranslateWinMsg(uMsgFilterMin),
113 TranslateWinMsg(uMsgFilterMax), (fRemove == MSG_REMOVE) ? PM_REMOVE : PM_NOREMOVE);
114 OS2ToWinMsgTranslate(MsgThreadPtr, pMsg, isUnicode);
115 return rc;
116}
117//******************************************************************************
118//******************************************************************************
Note: See TracBrowser for help on using the repository browser.