Commit c57e98ea authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

riched20: Handle sending EN_MSGFILTER notifications in the host.

parent 1cf8fea7
......@@ -2384,28 +2384,6 @@ static BOOL copy_or_cut( ME_TextEditor *editor, BOOL cut )
return SUCCEEDED( hr );
}
/* helper to send a msg filter notification */
static BOOL
ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM* wParam, LPARAM* lParam)
{
MSGFILTER msgf;
if (!editor->hWnd || !editor->hwndParent) return FALSE;
msgf.nmhdr.hwndFrom = editor->hWnd;
msgf.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
msgf.nmhdr.code = EN_MSGFILTER;
msgf.msg = msg;
msgf.wParam = *wParam;
msgf.lParam = *lParam;
if (SendMessageW(editor->hwndParent, WM_NOTIFY, msgf.nmhdr.idFrom, (LPARAM)&msgf))
return FALSE;
*wParam = msgf.wParam;
*lParam = msgf.lParam;
msgf.wParam = *wParam;
return TRUE;
}
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
{
ME_Paragraph *start_para, *end_para;
......@@ -4132,9 +4110,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case WM_LBUTTONDOWN:
{
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
ITextHost_TxSetFocus(editor->texthost);
ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
ME_CalculateClickCount(editor, msg, wParam, lParam));
......@@ -4145,9 +4120,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
break;
}
case WM_MOUSEMOVE:
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
if (editor->bMouseCaptured)
ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
else
......@@ -4163,9 +4135,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
if (editor->nSelectionType == stDocument)
editor->nSelectionType = stPosition;
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
else
{
ME_SetCursor(editor);
......@@ -4176,9 +4145,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
ME_LinkNotify(editor, msg, wParam, lParam);
goto do_default;
case WM_CONTEXTMENU:
......@@ -4206,22 +4172,11 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case WM_COMMAND:
TRACE("editor wnd command = %d\n", LOWORD(wParam));
return 0;
case WM_KEYUP:
if ((editor->nEventMask & ENM_KEYEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
goto do_default;
case WM_KEYDOWN:
if ((editor->nEventMask & ENM_KEYEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
if (ME_KeyDown(editor, LOWORD(wParam)))
return 0;
goto do_default;
case WM_CHAR:
if ((editor->nEventMask & ENM_KEYEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
return handle_wm_char( editor, wParam, lParam );
case WM_UNICHAR:
if (unicode)
......@@ -4328,16 +4283,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
case WM_MOUSEWHEEL:
{
int delta;
BOOL ctrl_is_down;
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
delta = GET_WHEEL_DELTA_WPARAM(wParam);
int delta = GET_WHEEL_DELTA_WPARAM( wParam );
BOOL ctrl_is_down = GetKeyState( VK_CONTROL ) & 0x8000;
/* if scrolling changes direction, ignore left overs */
if ((delta < 0 && editor->wheel_remain < 0) ||
......
......@@ -38,10 +38,10 @@ struct host
LONG ref;
ITextServices *text_srv;
ME_TextEditor *editor; /* to be removed */
HWND window;
HWND window, parent;
BOOL emulate_10;
PARAFORMAT2 para_fmt;
DWORD props, scrollbars;
DWORD props, scrollbars, event_mask;
};
static const ITextHostVtbl textHostVtbl;
......@@ -82,6 +82,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
texthost->ref = 1;
texthost->window = hwnd;
texthost->parent = cs->hwndParent;
texthost->emulate_10 = emulate_10;
memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
......@@ -93,6 +94,7 @@ struct host *host_create( HWND hwnd, CREATESTRUCTW *cs, BOOL emulate_10 )
texthost->para_fmt.wAlignment = PFA_CENTER;
texthost->editor = NULL;
host_init_props( texthost );
texthost->event_mask = 0;
return texthost;
}
......@@ -842,6 +844,26 @@ static HRESULT set_options( struct host *host, DWORD op, DWORD value, LRESULT *r
return hr;
}
static LRESULT send_msg_filter( struct host *host, UINT msg, WPARAM *wparam, LPARAM *lparam )
{
MSGFILTER msgf;
LRESULT res;
if (!host->parent) return 0;
msgf.nmhdr.hwndFrom = host->window;
msgf.nmhdr.idFrom = GetWindowLongW( host->window, GWLP_ID );
msgf.nmhdr.code = EN_MSGFILTER;
msgf.msg = msg;
msgf.wParam = *wparam;
msgf.lParam = *lparam;
if ((res = SendMessageW( host->parent, WM_NOTIFY, msgf.nmhdr.idFrom, (LPARAM)&msgf )))
return res;
*wparam = msgf.wParam;
*lparam = msgf.lParam;
return 0;
}
static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam, BOOL unicode )
{
......@@ -866,6 +888,15 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
else return DefWindowProcW( hwnd, msg, wparam, lparam );
}
if ((((host->event_mask & ENM_KEYEVENTS) && msg >= WM_KEYFIRST && msg <= WM_KEYLAST) ||
((host->event_mask & ENM_MOUSEEVENTS) && msg >= WM_MOUSEFIRST && msg <= WM_MOUSELAST)) &&
send_msg_filter( host, msg, &wparam, &lparam ))
{
TRACE( "exit (filtered) hwnd %p msg %04x (%s) %lx %lx -> %lu\n",
hwnd, msg, get_msg_name(msg), wparam, lparam, res );
return res;
}
editor = host->editor;
switch (msg)
{
......@@ -1042,6 +1073,11 @@ static LRESULT RichEditWndProc_common( HWND hwnd, UINT msg, WPARAM wparam,
res = len;
break;
}
case EM_SETEVENTMASK:
host->event_mask = lparam;
hr = ITextServices_TxSendMessage( host->text_srv, msg, wparam, lparam, &res );
break;
case EM_SETOPTIONS:
hr = set_options( host, wparam, lparam, &res );
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment