some fixes on carets

svn path=/trunk/; revision=7134
This commit is contained in:
Thomas Bluemel 2003-12-20 15:42:47 +00:00
parent 705104e713
commit 9efeb21225
6 changed files with 76 additions and 60 deletions

View file

@ -1,11 +1,10 @@
#ifndef _WIN32K_CARET_H #ifndef _WIN32K_CARET_H
#define _WIN32K_CARET_H #define _WIN32K_CARET_H
#include <ddk/ntddk.h> #include <windows.h>
#include <napi/win32.h> #include <internal/ps.h>
#define IDCARETTIMER (0xffff) #define IDCARETTIMER (0xffff)
#define ThrdCaretInfo(x) (PTHRDCARETINFO)((PW32THREAD)(x + 1))
/* a copy of this structure is in lib/user32/include/user32.h */ /* a copy of this structure is in lib/user32/include/user32.h */
typedef struct _THRDCARETINFO typedef struct _THRDCARETINFO

View file

@ -3,6 +3,7 @@
#include <internal/ex.h> #include <internal/ex.h>
#include <windows.h> #include <windows.h>
#include "caret.h"
#include "hook.h" #include "hook.h"
typedef struct _USER_MESSAGE typedef struct _USER_MESSAGE
@ -74,6 +75,9 @@ typedef struct _USER_MESSAGE_QUEUE
HWND MenuOwner; HWND MenuOwner;
/* Identifes the menu state */ /* Identifes the menu state */
BYTE MenuState; BYTE MenuState;
/* Caret information for this queue */
PTHRDCARETINFO CaretInfo;
/* Window hooks */ /* Window hooks */
PHOOKTABLE Hooks; PHOOKTABLE Hooks;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: dllmain.c,v 1.62 2003/12/13 22:38:29 weiden Exp $ /* $Id: dllmain.c,v 1.63 2003/12/20 15:42:47 weiden Exp $
* *
* Entry Point for win32k.sys * Entry Point for win32k.sys
*/ */
@ -216,7 +216,7 @@ DllMain (
Win32kThreadCallback, Win32kThreadCallback,
0, 0,
0, 0,
sizeof(W32THREAD) + sizeof(THRDCARETINFO), sizeof(W32THREAD),
sizeof(W32PROCESS)); sizeof(W32PROCESS));
WinPosSetupInternalPos(); WinPosSetupInternalPos();

View file

@ -1,4 +1,4 @@
/* $Id: caret.c,v 1.8 2003/11/23 11:39:48 navaraf Exp $ /* $Id: caret.c,v 1.9 2003/12/20 15:42:47 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -43,9 +43,18 @@ IntHideCaret(PTHRDCARETINFO CaretInfo)
BOOL FASTCALL BOOL FASTCALL
IntDestroyCaret(PW32THREAD Win32Thread) IntDestroyCaret(PW32THREAD Win32Thread)
{ {
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(Win32Thread); PUSER_MESSAGE_QUEUE ThreadQueue;
IntHideCaret(CaretInfo); ThreadQueue = (PUSER_MESSAGE_QUEUE)Win32Thread->MessageQueue;
RtlZeroMemory(CaretInfo, sizeof(THRDCARETINFO));
if(!ThreadQueue || !ThreadQueue->CaretInfo)
return FALSE;
IntHideCaret(ThreadQueue->CaretInfo);
ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
ThreadQueue->CaretInfo->hWnd = (HWND)0;
ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
ThreadQueue->CaretInfo->Showing = 0;
ThreadQueue->CaretInfo->Visible = 0;
return TRUE; return TRUE;
} }
@ -80,7 +89,6 @@ IntSetCaretBlinkTime(UINT uMSeconds)
return TRUE; return TRUE;
} }
#define CARET_VALUE_BUFFER_SIZE 32
UINT FASTCALL UINT FASTCALL
IntQueryCaretBlinkRate(VOID) IntQueryCaretBlinkRate(VOID)
{ {
@ -185,18 +193,19 @@ IntGetCaretBlinkTime(VOID)
BOOL FASTCALL BOOL FASTCALL
IntSetCaretPos(int X, int Y) IntSetCaretPos(int X, int Y)
{ {
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(CaretInfo->hWnd) if(ThreadQueue->CaretInfo->hWnd)
{ {
if(CaretInfo->Pos.x != X || CaretInfo->Pos.y != Y) if(ThreadQueue->CaretInfo->Pos.x != X || ThreadQueue->CaretInfo->Pos.y != Y)
{ {
IntHideCaret(CaretInfo); IntHideCaret(ThreadQueue->CaretInfo);
CaretInfo->Showing = 0; ThreadQueue->CaretInfo->Showing = 0;
CaretInfo->Pos.x = X; ThreadQueue->CaretInfo->Pos.x = X;
CaretInfo->Pos.y = Y; ThreadQueue->CaretInfo->Pos.y = Y;
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); IntCallWindowProc(NULL, ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
IntSetTimer(CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); IntSetTimer(ThreadQueue->CaretInfo->hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
} }
return TRUE; return TRUE;
} }
@ -207,12 +216,13 @@ IntSetCaretPos(int X, int Y)
BOOL FASTCALL BOOL FASTCALL
IntSwitchCaretShowing(PVOID Info) IntSwitchCaretShowing(PVOID Info)
{ {
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(CaretInfo->hWnd) if(ThreadQueue->CaretInfo->hWnd)
{ {
CaretInfo->Showing = (CaretInfo->Showing ? 0 : 1); ThreadQueue->CaretInfo->Showing = (ThreadQueue->CaretInfo->Showing ? 0 : 1);
MmCopyToCaller(Info, CaretInfo, sizeof(THRDCARETINFO)); MmCopyToCaller(Info, ThreadQueue->CaretInfo, sizeof(THRDCARETINFO));
return TRUE; return TRUE;
} }
@ -222,12 +232,14 @@ IntSwitchCaretShowing(PVOID Info)
VOID FASTCALL VOID FASTCALL
IntDrawCaret(HWND hWnd) IntDrawCaret(HWND hWnd)
{ {
PTHRDCARETINFO CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); PUSER_MESSAGE_QUEUE ThreadQueue;
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(CaretInfo->hWnd && CaretInfo->Visible && CaretInfo->Showing) if(ThreadQueue->CaretInfo->hWnd && ThreadQueue->CaretInfo->Visible &&
ThreadQueue->CaretInfo->Showing)
{ {
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); IntCallWindowProc(NULL, ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
CaretInfo->Showing = 1; ThreadQueue->CaretInfo->Showing = 1;
} }
} }
@ -242,7 +254,7 @@ NtUserCreateCaret(
int nHeight) int nHeight)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT WindowObject;
PTHRDCARETINFO CaretInfo; PUSER_MESSAGE_QUEUE ThreadQueue;
WindowObject = IntGetWindowObject(hWnd); WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject) if(!WindowObject)
@ -260,25 +272,24 @@ NtUserCreateCaret(
IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE); IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
CaretInfo = ThrdCaretInfo(WindowObject->OwnerThread->Win32Thread); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
IntHideCaret(CaretInfo); IntHideCaret(ThreadQueue->CaretInfo);
CaretInfo->hWnd = hWnd; ThreadQueue->CaretInfo->hWnd = hWnd;
if(hBitmap) if(hBitmap)
{ {
CaretInfo->Bitmap = hBitmap; ThreadQueue->CaretInfo->Bitmap = hBitmap;
CaretInfo->Size.cx = CaretInfo->Size.cy = 0; ThreadQueue->CaretInfo->Size.cx = ThreadQueue->CaretInfo->Size.cy = 0;
} }
else else
{ {
CaretInfo->Bitmap = (HBITMAP)0; ThreadQueue->CaretInfo->Bitmap = (HBITMAP)0;
CaretInfo->Size.cx = nWidth; ThreadQueue->CaretInfo->Size.cx = nWidth;
CaretInfo->Size.cy = nHeight; ThreadQueue->CaretInfo->Size.cy = nHeight;
} }
CaretInfo->Pos.x = CaretInfo->Pos.y = 0; ThreadQueue->CaretInfo->Visible = 0;
CaretInfo->Visible = 0; ThreadQueue->CaretInfo->Showing = 0;
CaretInfo->Showing = 0;
IntReleaseWindowObject(WindowObject); IntReleaseWindowObject(WindowObject);
return TRUE; return TRUE;
@ -296,12 +307,12 @@ STDCALL
NtUserGetCaretPos( NtUserGetCaretPos(
LPPOINT lpPoint) LPPOINT lpPoint)
{ {
PTHRDCARETINFO CaretInfo; PUSER_MESSAGE_QUEUE ThreadQueue;
NTSTATUS Status; NTSTATUS Status;
CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
Status = MmCopyToCaller(lpPoint, &(CaretInfo->Pos), sizeof(POINT)); Status = MmCopyToCaller(lpPoint, &(ThreadQueue->CaretInfo->Pos), sizeof(POINT));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastNtError(Status); SetLastNtError(Status);
@ -317,7 +328,7 @@ NtUserHideCaret(
HWND hWnd) HWND hWnd)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT WindowObject;
PTHRDCARETINFO CaretInfo; PUSER_MESSAGE_QUEUE ThreadQueue;
WindowObject = IntGetWindowObject(hWnd); WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject) if(!WindowObject)
@ -333,22 +344,22 @@ NtUserHideCaret(
return FALSE; return FALSE;
} }
CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(CaretInfo->hWnd != hWnd) if(ThreadQueue->CaretInfo->hWnd != hWnd)
{ {
IntReleaseWindowObject(WindowObject); IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
} }
if(CaretInfo->Visible) if(ThreadQueue->CaretInfo->Visible)
{ {
IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE); IntRemoveTimer(hWnd, IDCARETTIMER, PsGetCurrentThreadId(), TRUE);
IntHideCaret(CaretInfo); IntHideCaret(ThreadQueue->CaretInfo);
CaretInfo->Visible = 0; ThreadQueue->CaretInfo->Visible = 0;
CaretInfo->Showing = 0; ThreadQueue->CaretInfo->Showing = 0;
} }
IntReleaseWindowObject(WindowObject); IntReleaseWindowObject(WindowObject);
@ -361,7 +372,7 @@ NtUserShowCaret(
HWND hWnd) HWND hWnd)
{ {
PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT WindowObject;
PTHRDCARETINFO CaretInfo; PUSER_MESSAGE_QUEUE ThreadQueue;
WindowObject = IntGetWindowObject(hWnd); WindowObject = IntGetWindowObject(hWnd);
if(!WindowObject) if(!WindowObject)
@ -377,21 +388,21 @@ NtUserShowCaret(
return FALSE; return FALSE;
} }
CaretInfo = ThrdCaretInfo(PsGetCurrentThread()->Win32Thread); ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if(CaretInfo->hWnd != hWnd) if(ThreadQueue->CaretInfo->hWnd != hWnd)
{ {
IntReleaseWindowObject(WindowObject); IntReleaseWindowObject(WindowObject);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
} }
if(!CaretInfo->Visible) if(!ThreadQueue->CaretInfo->Visible)
{ {
CaretInfo->Visible = 1; ThreadQueue->CaretInfo->Visible = 1;
if(!CaretInfo->Showing) if(!ThreadQueue->CaretInfo->Showing)
{ {
IntCallWindowProc(NULL, CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0); IntCallWindowProc(NULL, ThreadQueue->CaretInfo->hWnd, WM_SYSTIMER, IDCARETTIMER, 0);
} }
IntSetTimer(hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE); IntSetTimer(hWnd, IDCARETTIMER, IntGetCaretBlinkTime(), NULL, TRUE);
} }

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.35 2003/12/19 19:30:05 weiden Exp $ /* $Id: misc.c,v 1.36 2003/12/20 15:42:47 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -588,8 +588,8 @@ NtUserGetGUIThreadInfo(
return FALSE; return FALSE;
} }
CaretInfo = ThrdCaretInfo(Thread->Win32Thread);
MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue; MsgQueue = (PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue;
CaretInfo = MsgQueue->CaretInfo;
SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0); SafeGui.flags = (CaretInfo->Visible ? GUI_CARETBLINKING : 0);
if(MsgQueue->MenuOwner) if(MsgQueue->MenuOwner)

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: msgqueue.c,v 1.51 2003/12/19 19:30:05 weiden Exp $ /* $Id: msgqueue.c,v 1.52 2003/12/20 15:42:47 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -42,6 +42,7 @@
#include <include/input.h> #include <include/input.h>
#include <include/cursoricon.h> #include <include/cursoricon.h>
#include <include/focus.h> #include <include/focus.h>
#include <include/caret.h>
#define NDEBUG #define NDEBUG
#include <win32k/debug1.h> #include <win32k/debug1.h>
@ -810,6 +811,7 @@ VOID FASTCALL
MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue) MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue)
{ {
MessageQueue->Thread = Thread; MessageQueue->Thread = Thread;
MessageQueue->CaretInfo = (PTHRDCARETINFO)(MessageQueue + 1);
InitializeListHead(&MessageQueue->PostedMessagesListHead); InitializeListHead(&MessageQueue->PostedMessagesListHead);
InitializeListHead(&MessageQueue->SentMessagesListHead); InitializeListHead(&MessageQueue->SentMessagesListHead);
InitializeListHead(&MessageQueue->HardwareMessagesListHead); InitializeListHead(&MessageQueue->HardwareMessagesListHead);
@ -846,7 +848,7 @@ MsqCreateMessageQueue(struct _ETHREAD *Thread)
PUSER_MESSAGE_QUEUE MessageQueue; PUSER_MESSAGE_QUEUE MessageQueue;
MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePool(PagedPool, MessageQueue = (PUSER_MESSAGE_QUEUE)ExAllocatePool(PagedPool,
sizeof(USER_MESSAGE_QUEUE)); sizeof(USER_MESSAGE_QUEUE) + sizeof(THRDCARETINFO));
if (!MessageQueue) if (!MessageQueue)
{ {
return NULL; return NULL;