Fix what I broke in revision r58447, namely at which process the terminal window belongs to.

svn path=/branches/ros-csrss/; revision=58557
This commit is contained in:
Hermès Bélusca-Maïto 2013-03-20 00:41:47 +00:00
parent 4bae574ebe
commit fe98b9ea97
4 changed files with 45 additions and 24 deletions

View file

@ -106,6 +106,7 @@ typedef struct _TERMINAL_VTBL
DWORD ShiftState, DWORD ShiftState,
UINT VirtualKeyCode, UINT VirtualKeyCode,
BOOL Down); BOOL Down);
VOID (WINAPI *RefreshInternalInfo)(struct _CONSOLE* Console);
/* /*
* External interface (functions corresponding to the Console API) * External interface (functions corresponding to the Console API)
@ -132,6 +133,10 @@ typedef struct _TERMINAL_VTBL
#define ConioResizeBuffer(Console, Buff, Size) (Console)->TermIFace.Vtbl->ResizeBuffer((Console), (Buff), (Size)) #define ConioResizeBuffer(Console, Buff, Size) (Console)->TermIFace.Vtbl->ResizeBuffer((Console), (Buff), (Size))
#define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) \ #define ConioProcessKeyCallback(Console, Msg, KeyStateMenu, ShiftState, VirtualKeyCode, Down) \
(Console)->TermIFace.Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down)) (Console)->TermIFace.Vtbl->ProcessKeyCallback((Console), (Msg), (KeyStateMenu), (ShiftState), (VirtualKeyCode), (Down))
#define ConioGetConsoleWindowHandle(Console) \
(Console)->TermIFace.Vtbl->GetConsoleWindowHandle((Console))
#define ConioRefreshInternalInfo(Console) \
(Console)->TermIFace.Vtbl->RefreshInternalInfo((Console))
typedef struct _TERMINAL_IFACE typedef struct _TERMINAL_IFACE
{ {
@ -195,25 +200,6 @@ typedef struct _CONSOLE
} CONSOLE, *PCONSOLE; } CONSOLE, *PCONSOLE;
/**************************************************************\
\** Define the Console Leader Process for the console window **/
#define GWLP_CONSOLEWND_ALLOC (2 * sizeof(LONG_PTR))
#define GWLP_CONSOLE_LEADER_PID 0
#define GWLP_CONSOLE_LEADER_TID 4
#define SetConsoleWndConsoleLeaderCID(GuiData) \
do { \
PCONSOLE_PROCESS_DATA ProcessData; \
CLIENT_ID ConsoleLeaderCID; \
ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \
CONSOLE_PROCESS_DATA, \
ConsoleLink); \
ConsoleLeaderCID = ProcessData->Process->ClientId; \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \
} while(0)
/**************************************************************/
/* CONSOLE_SELECTION_INFO dwFlags values */ /* CONSOLE_SELECTION_INFO dwFlags values */
#define CONSOLE_NO_SELECTION 0x0 #define CONSOLE_NO_SELECTION 0x0
#define CONSOLE_SELECTION_IN_PROGRESS 0x1 #define CONSOLE_SELECTION_IN_PROGRESS 0x1

View file

@ -1034,7 +1034,7 @@ CSR_API(SrvGetConsoleWindow)
Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE); Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console, TRUE);
if (!NT_SUCCESS(Status)) return Status; if (!NT_SUCCESS(Status)) return Status;
GetWindowRequest->WindowHandle = Console->TermIFace.Vtbl->GetConsoleWindowHandle(Console); GetWindowRequest->WindowHandle = ConioGetConsoleWindowHandle(Console);
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);
return STATUS_SUCCESS; return STATUS_SUCCESS;

View file

@ -65,6 +65,27 @@ typedef struct _GUI_CONSOLE_DATA
GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */ GUI_CONSOLE_INFO GuiInfo; /* GUI terminal settings */
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA; } GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
/**************************************************************\
\** Define the Console Leader Process for the console window **/
#define GWLP_CONSOLEWND_ALLOC (2 * sizeof(LONG_PTR))
#define GWLP_CONSOLE_LEADER_PID 0
#define GWLP_CONSOLE_LEADER_TID 4
#define SetConsoleWndConsoleLeaderCID(GuiData) \
do { \
PCONSOLE_PROCESS_DATA ProcessData; \
CLIENT_ID ConsoleLeaderCID; \
ProcessData = CONTAINING_RECORD((GuiData)->Console->ProcessList.Blink, \
CONSOLE_PROCESS_DATA, \
ConsoleLink); \
ConsoleLeaderCID = ProcessData->Process->ClientId; \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_PID, (LONG_PTR)(ConsoleLeaderCID.UniqueProcess)); \
SetWindowLongPtrW((GuiData)->hWindow, GWLP_CONSOLE_LEADER_TID, (LONG_PTR)(ConsoleLeaderCID.UniqueThread )); \
} while(0)
/**************************************************************/
static BOOL ConsInitialized = FALSE; static BOOL ConsInitialized = FALSE;
static HICON ghDefaultIcon = NULL; static HICON ghDefaultIcon = NULL;
static HICON ghDefaultIconSm = NULL; static HICON ghDefaultIconSm = NULL;
@ -1619,8 +1640,6 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
WindowCount++; WindowCount++;
SetWindowLongW(hWnd, GWL_USERDATA, WindowCount); SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
// SetConsoleWndConsoleLeaderCID(Console);
DPRINT1("Set icons via PM_CREATE_CONSOLE\n"); DPRINT1("Set icons via PM_CREATE_CONSOLE\n");
if (GuiData->hIcon == NULL) if (GuiData->hIcon == NULL)
{ {
@ -2065,6 +2084,15 @@ GuiProcessKeyCallback(PCONSOLE Console, MSG* msg, BYTE KeyStateMenu, DWORD Shift
return FALSE; return FALSE;
} }
static VOID WINAPI
GuiRefreshInternalInfo(PCONSOLE Console)
{
PGUI_CONSOLE_DATA GuiData = Console->TermIFace.Data;
/* Update the console leader information held by the window */
SetConsoleWndConsoleLeaderCID(GuiData);
}
static VOID WINAPI static VOID WINAPI
GuiChangeTitle(PCONSOLE Console) GuiChangeTitle(PCONSOLE Console)
{ {
@ -2133,6 +2161,7 @@ static TERMINAL_VTBL GuiVtbl =
GuiUpdateScreenInfo, GuiUpdateScreenInfo,
GuiResizeBuffer, GuiResizeBuffer,
GuiProcessKeyCallback, GuiProcessKeyCallback,
GuiRefreshInternalInfo,
GuiChangeTitle, GuiChangeTitle,
GuiChangeIcon, GuiChangeIcon,
GuiGetConsoleWindowHandle GuiGetConsoleWindowHandle

View file

@ -449,6 +449,9 @@ ConSrvAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData,
/* Add a reference count because the process is tied to the console */ /* Add a reference count because the process is tied to the console */
_InterlockedIncrement(&ProcessData->Console->ReferenceCount); _InterlockedIncrement(&ProcessData->Console->ReferenceCount);
/* Update the internal info of the terminal */
ConioRefreshInternalInfo(ProcessData->Console);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -501,6 +504,9 @@ ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData,
/* Add a reference count because the process is tied to the console */ /* Add a reference count because the process is tied to the console */
_InterlockedIncrement(&ProcessData->Console->ReferenceCount); _InterlockedIncrement(&ProcessData->Console->ReferenceCount);
/* Update the internal info of the terminal */
ConioRefreshInternalInfo(ProcessData->Console);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -528,8 +534,8 @@ ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
/* Remove ourselves from the console's list of processes */ /* Remove ourselves from the console's list of processes */
RemoveEntryList(&ProcessData->ConsoleLink); RemoveEntryList(&ProcessData->ConsoleLink);
/* Update the console leader process */ /* Update the internal info of the terminal */
// SetConsoleWndConsoleLeaderCID(Console); ConioRefreshInternalInfo(Console);
/* Release the console */ /* Release the console */
ConSrvReleaseConsole(Console, TRUE); ConSrvReleaseConsole(Console, TRUE);