imp. remove mouseover32

This commit is contained in:
xiaoyifang 2022-01-29 14:54:33 +08:00
parent b71925787c
commit c96a83f5d2
5 changed files with 5 additions and 172 deletions

View file

@ -482,15 +482,13 @@ SOURCES += folding.cc \
win32 {
FORMS += texttospeechsource.ui
SOURCES += mouseover_win32/ThTypes.c \
wordbyauto.cc \
SOURCES += wordbyauto.cc \
guids.c \
x64.cc \
speechclient_win.cc \
texttospeechsource.cc \
speechhlp.cc
HEADERS += mouseover_win32/ThTypes.h \
wordbyauto.hh \
HEADERS += wordbyauto.hh \
uiauto.hh \
x64.hh \
texttospeechsource.hh \

View file

@ -57,7 +57,6 @@
#ifdef Q_OS_WIN32
#include <windows.h>
#include "mouseover_win32/GDDataTranfer.h"
#include "wstring.hh"
#include "wstring_qt.hh"
@ -884,10 +883,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
#ifdef Q_OS_MAC
LionSupport::addFullscreen(this);
#endif
#ifdef Q_OS_WIN32
gdAskMessage = RegisterWindowMessage( GD_MESSAGE_NAME );
( static_cast< QHotkeyApplication * >( qApp ) )->setMainWindow( this );
#endif
ui.centralWidget->grabGesture( Gestures::GDPinchGestureType );
ui.centralWidget->grabGesture( Gestures::GDSwipeGestureType );
@ -4831,14 +4826,6 @@ bool MainWindow::handleGDMessage( MSG * message, long * result )
if( !view )
return true;
LPGDDataStruct lpdata = ( LPGDDataStruct ) message->lParam;
QString str = view->wordAtPoint( lpdata->Pt.x, lpdata->Pt.y );
memset( lpdata->cwData, 0, lpdata->dwMaxLength * sizeof( WCHAR ) );
str.truncate( lpdata->dwMaxLength - 1 );
str.toWCharArray( lpdata->cwData );
*result = 1;
return true;
}

View file

@ -10,7 +10,6 @@
#include <sddl.h>
#include <accctrl.h>
#include <aclapi.h>
#include "mouseover_win32/ThTypes.h"
#include "wordbyauto.hh"
#include "x64.hh"
#endif
@ -93,78 +92,7 @@ static void SetLowLabelToGDSynchroObjects()
MouseOver::MouseOver() :
pPref(NULL)
{
#ifdef Q_OS_WIN32
HMODULE hm;
ChangeWindowMessageFilterFunc changeWindowMessageFilterFunc = NULL;
ChangeWindowMessageFilterExFunc changeWindowMessageFilterExFunc = NULL;
mouseOverEnabled = false;
ThTypes_Init();
memset( GlobalData, 0, sizeof( TGlobalDLLData ) );
#ifdef Q_OS_WIN64
memset( GlobalData32, 0, sizeof( TGlobalDLLData32 ) );
#endif
// strcpy( GlobalData->LibName,
// QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() ).filePath( "GdTextOutHook.dll" ) ).toLocal8Bit().data() );
#ifdef Q_OS_WIN64
QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() ).filePath( "GdTextOutHook64.dll" ) ).toWCharArray( GlobalData->LibName );
QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() + "/x86" ).filePath( "GdTextOutHook.dll" ) ).toWCharArray( GlobalData32->LibName );
#else
QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() ).filePath( "GdTextOutHook.dll" ) ).toWCharArray( GlobalData->LibName );
#endif
// Create the window to receive spying results to
WNDCLASSEX wcex;
wcex.cbSize = sizeof( WNDCLASSEX );
wcex.style = 0;
wcex.lpfnWndProc = ( WNDPROC ) eventHandler;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = GetModuleHandle( 0 );
wcex.hIcon = NULL;
wcex.hCursor = NULL,
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = className;
wcex.hIconSm = NULL;
RegisterClassEx( &wcex );
GlobalData->ServerWND = CreateWindow( className, L"", 0, 0, 0, 0, 0, GetDesktopWindow(), NULL, GetModuleHandle( 0 ), 0 );
#ifdef Q_OS_WIN64
GlobalData32->ServerWND = HandleToLong( GlobalData->ServerWND );
#endif
#ifdef Q_OS_WIN64
spyDll = LoadLibrary( QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() ).filePath( "GdTextOutSpy64.dll" ) ).toStdWString().c_str() );
#else
spyDll = LoadLibrary( QDir::toNativeSeparators( QDir( QCoreApplication::applicationDirPath() ).filePath( "GdTextOutSpy.dll" ) ).toStdWString().c_str() );
#endif
if ( spyDll )
activateSpyFn = ( ActivateSpyFn ) GetProcAddress( spyDll, "ActivateTextOutSpying" );
// Allow messages from low intehrity process - for Vista and Win7
hm = GetModuleHandle( __TEXT("user32.dll"));
if ( hm != NULL ) {
changeWindowMessageFilterExFunc = (ChangeWindowMessageFilterExFunc)GetProcAddress( hm, "ChangeWindowMessageFilterEx" );
if( changeWindowMessageFilterExFunc ) {
CHANGEFILTERSTRUCT cfs = { sizeof( CHANGEFILTERSTRUCT ), 0 };
changeWindowMessageFilterExFunc( GlobalData->ServerWND, WM_MY_SHOW_TRANSLATION, 1 /* MSGFLT_ALLOW */, &cfs );
} else {
changeWindowMessageFilterFunc = (ChangeWindowMessageFilterFunc)GetProcAddress( hm, "ChangeWindowMessageFilter" );
if( changeWindowMessageFilterFunc )
changeWindowMessageFilterFunc( WM_MY_SHOW_TRANSLATION, 1 /* MSGFLT_ADD */ );
}
}
//Allow object access from low intehrity process - for Vista and Win7
SetLowLabelToGDSynchroObjects();
#endif
}
void MouseOver::enableMouseOver()
@ -198,24 +126,10 @@ LRESULT MouseOver::makeScanBitMask()
LRESULT res = 0;
if( pPref == NULL )
return 0;
if( !pPref->enableScanPopupModifiers || checkModifiersPressed( pPref->scanPopupModifiers ) ) {
res = GD_FLAG_METHOD_STANDARD;
if( pPref->scanPopupUseUIAutomation !=0 )
res |= GD_FLAG_METHOD_UI_AUTOMATION;
if( pPref->scanPopupUseIAccessibleEx !=0 )
res |= GD_FLAG_METHOD_IACCESSIBLEEX;
if( pPref->scanPopupUseGDMessage !=0 )
res |= GD_FLAG_METHOD_GD_MESSAGE;
}
return res;
}
#ifdef Q_OS_WIN64
#define Global_Data GlobalData32
#else
#define Global_Data GlobalData
#endif
LRESULT CALLBACK MouseOver::eventHandler( HWND hwnd_, UINT msg,
WPARAM wparam, LPARAM lparam )
{
@ -232,58 +146,6 @@ LRESULT CALLBACK MouseOver::eventHandler( HWND hwnd_, UINT msg,
int wordSeqPos = 0;
QString wordSeq;
#ifdef Q_OS_WIN64
HWND hwnd = ( HWND )LongToHandle( Global_Data->LastWND );
#else
HWND hwnd = Global_Data->LastWND;
#endif
if( Global_Data->CurMod.WordLen == 0)
{
if( ( res & GD_FLAG_METHOD_UI_AUTOMATION ) == 0 )
return 0;
POINT pt = Global_Data->LastPt;
WCHAR *pwstr = gdGetWordAtPointByAutomation( pt );
if( pwstr == NULL ) return 0;
wordSeq = QString::fromWCharArray( pwstr );
}
else
{
// Is the string in utf8 or in locale encoding?
gd::wchar testBuf[ 256 ];
long result = Utf8::decode( Global_Data->CurMod.MatchedWord,
strlen( Global_Data->CurMod.MatchedWord ),
testBuf );
if ( result >= 0 )
{
// It seems to be
QString begin = QString::fromUtf8( Global_Data->CurMod.MatchedWord,
Global_Data->CurMod.BeginPos ).normalized( QString::NormalizationForm_C );
QString end = QString::fromUtf8( Global_Data->CurMod.MatchedWord +
Global_Data->CurMod.BeginPos ).normalized( QString::NormalizationForm_C );
wordSeq = begin + end;
wordSeqPos = begin.size();
}
else
{
// It's not, so interpret it as in local encoding
QString begin = QString::fromLocal8Bit( Global_Data->CurMod.MatchedWord,
Global_Data->CurMod.BeginPos ).normalized( QString::NormalizationForm_C );
QString end = QString::fromLocal8Bit( Global_Data->CurMod.MatchedWord +
Global_Data->CurMod.BeginPos ).normalized( QString::NormalizationForm_C );
wordSeq = begin + end;
wordSeqPos = begin.size();
}
}
// Now locate the word inside the sequence
QString word;
@ -358,7 +220,6 @@ LRESULT CALLBACK MouseOver::eventHandler( HWND hwnd_, UINT msg,
}
bool forcePopup = false;
forcePopup = emit instance().isGoldenDictWindow( hwnd );
emit instance().hovered( word, forcePopup );
return 0;
}
@ -372,15 +233,6 @@ MouseOver::~MouseOver()
{
#ifdef Q_OS_WIN32
disableMouseOver();
FreeLibrary( spyDll );
DestroyWindow( GlobalData->ServerWND );
UnregisterClass( className, GetModuleHandle( 0 ) );
ThTypes_End();
#endif
}

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>636</width>
<height>431</height>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
@ -24,7 +24,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>6</number>
</property>
<property name="iconSize">
<size>

View file

@ -282,10 +282,6 @@ ScanPopup::ScanPopup( QWidget * parent,
connect( &MouseOver::instance(), SIGNAL( hovered( QString const &, bool ) ),
this, SLOT( mouseHovered( QString const &, bool ) ) );
#ifdef Q_OS_WIN32
connect( &MouseOver::instance(), SIGNAL( isGoldenDictWindow( HWND ) ),
this, SIGNAL( isGoldenDictWindow( HWND ) ) );
#endif
hideTimer.setSingleShot( true );
hideTimer.setInterval( 400 );