summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt
diff options
context:
space:
mode:
authorSteve Northover <steve>2007-05-24 20:12:47 +0000
committerSteve Northover <steve>2007-05-24 20:12:47 +0000
commit59c7194abace25530f6cc464daa22f94507e57c5 (patch)
tree6ea8c426c844ae52741da6d6b64b989bbd04abf5 /bundles/org.eclipse.swt
parent771246814116ab7a06d741bac1b7a6515066ce29 (diff)
downloadeclipse.platform.swt-59c7194abace25530f6cc464daa22f94507e57c5.tar.gz
eclipse.platform.swt-59c7194abace25530f6cc464daa22f94507e57c5.tar.xz
eclipse.platform.swt-59c7194abace25530f6cc464daa22f94507e57c5.zip
181410 - [Browser] browser steal focus on IE7
Diffstat (limited to 'bundles/org.eclipse.swt')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java37
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java5
4 files changed, 58 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
index c1e8294917..1a23c0079a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
@@ -58,6 +58,9 @@ public class OleControlSite extends OleClientSite
private int[] sitePropertyIds = new int[0];
private Variant[] sitePropertyValues = new Variant[0];
+ // work around for IE destroying the caret
+ static int SWT_RESTORECARET;
+
/**
* Create an OleControlSite child widget using style bits
* to select a particular look or set of properties.
@@ -583,7 +586,41 @@ void onFocusIn(Event e) {
}
void onFocusOut(Event e) {
if (objIOleInPlaceObject != null) {
+ /*
+ * Bug in Windows. When IE7 loses focus and UIDeactivate()
+ * is called, IE destroys the caret even though it is
+ * no longer owned by IE. If focus has moved to a control
+ * that shows a caret then the caret disappears. The fix
+ * is to detect this case and restore the caret.
+ */
+ int threadId = OS.GetCurrentThreadId();
+ GUITHREADINFO lpgui1 = new GUITHREADINFO();
+ lpgui1.cbSize = GUITHREADINFO.sizeof;
+ OS.GetGUIThreadInfo(threadId, lpgui1);
objIOleInPlaceObject.UIDeactivate();
+ if (lpgui1.hwndCaret != 0) {
+ GUITHREADINFO lpgui2 = new GUITHREADINFO();
+ lpgui2.cbSize = GUITHREADINFO.sizeof;
+ OS.GetGUIThreadInfo(threadId, lpgui2);
+ if (lpgui2.hwndCaret == 0 && lpgui1.hwndCaret == OS.GetFocus()) {
+ if (SWT_RESTORECARET == 0) {
+ SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
+ }
+ /*
+ * If the caret was not restored by SWT, put it back using
+ * the information from GUITHREADINFO. Note that this will
+ * not be correct when the caret has a bitmap. There is no
+ * API to query the bitmap that the caret is using.
+ */
+ if (OS.SendMessage (lpgui1.hwndCaret, SWT_RESTORECARET, 0, 0) == 0) {
+ int width = lpgui1.right - lpgui1.left;
+ int height = lpgui1.bottom - lpgui1.top;
+ OS.CreateCaret (lpgui1.hwndCaret, 0, width, height);
+ OS.SetCaretPos (lpgui1.left, lpgui1.top);
+ OS.ShowCaret (lpgui1.hwndCaret);
+ }
+ }
+ }
}
}
private int OnFocus(int fGotFocus) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index 7c4cec6076..f47068e225 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -278,6 +278,19 @@ public void setFont (Font font) {
super.setFont (font);
}
+int windowProc (int hwnd, int msg, int wParam, int lParam) {
+ if (msg == Display.SWT_RESTORECARET) {
+ if ((state & CANVAS) != 0) {
+ if (caret != null) {
+ caret.killFocus ();
+ caret.setFocus ();
+ return 1;
+ }
+ }
+ }
+ return super.windowProc (hwnd, msg, wParam, lParam);
+}
+
LRESULT WM_IME_COMPOSITION (int wParam, int lParam) {
LRESULT result = super.WM_IME_COMPOSITION (wParam, lParam);
/*
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
index 6269bf4ebb..b27979c232 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -354,6 +354,7 @@ public class Display extends Device {
static final int SWT_TRAYICONMSG = OS.WM_APP + 4;
static final int SWT_NULL = OS.WM_APP + 5;
static int SWT_TASKBARCREATED;
+ static int SWT_RESTORECARET;
/* Workaround for Adobe Reader 7.0 */
int hitCount;
@@ -2473,8 +2474,9 @@ protected void init () {
idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, foregroundIdleProc, 0, threadId);
}
- /* Register the task bar created message */
+ /* Register custom messages message */
SWT_TASKBARCREATED = OS.RegisterWindowMessage (new TCHAR (0, "TaskbarCreated", true));
+ SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
/* Initialize OLE */
if (!OS.IsWinCE) OS.OleInitialize (0);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
index 90f8cf7bd4..8cf1ac4b5f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -2005,6 +2005,11 @@ int windowProc (int hwnd, int msg, int wParam, int lParam) {
return callWindowProc (hwnd, OS.EM_UNDO, wParam, lParam);
}
}
+ if (msg == Display.SWT_RESTORECARET) {
+ callWindowProc (hwnd, OS.WM_KILLFOCUS, 0, 0);
+ callWindowProc (hwnd, OS.WM_SETFOCUS, 0, 0);
+ return 1;
+ }
return super.windowProc (hwnd, msg, wParam, lParam);
}