Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-08-03 08:03:07 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-08-04 02:02:59 +0400
commit37c15556d9ef42f1eb3863d1111b85f6721a5f74 (patch)
treea6f878354773a2efc0151a20fa5d665aa54dfe61 /main/src/addins/WindowsPlatform
parent728e8b31b8cdda54598cabe8a605f93c5ed88da5 (diff)
[Windows] Improve the Winforms and MD message queues collaboration.
Let any MD's pending event run when getting idle and form resize/relocation events. Also, don't use the WinFormRoot class when using custom file dialogs, as they are already handling these events.
Diffstat (limited to 'main/src/addins/WindowsPlatform')
-rw-r--r--main/src/addins/WindowsPlatform/Dialogs/AddFileDialogHandler.cs12
-rw-r--r--main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogEx.cs8
-rw-r--r--main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogHandler.cs3
-rw-r--r--main/src/addins/WindowsPlatform/Dialogs/WinFormsRoot.cs59
4 files changed, 62 insertions, 20 deletions
diff --git a/main/src/addins/WindowsPlatform/Dialogs/AddFileDialogHandler.cs b/main/src/addins/WindowsPlatform/Dialogs/AddFileDialogHandler.cs
index 70b2c3345f..306362a821 100644
--- a/main/src/addins/WindowsPlatform/Dialogs/AddFileDialogHandler.cs
+++ b/main/src/addins/WindowsPlatform/Dialogs/AddFileDialogHandler.cs
@@ -18,22 +18,13 @@ namespace MonoDevelop.Platform
CustomAddFilesDialog adlg = new CustomAddFilesDialog();
adlg.StartLocation = AddonWindowLocation.Bottom;
adlg.BuildActions = data.BuildActions;
- WinFormsRunner runner = new WinFormsRunner();
bool result = false;
SelectFileDialogHandler.SetCommonFormProperties (data, adlg.FileDialog);
- Timer t = new Timer();
- t.Interval = 20;
try
{
- t.Tick += delegate
- {
-// MonoDevelop.Core.Gui.DispatchService.RunPendingEvents();
- };
- //t.Enabled = true;
- WinFormsRoot root = new WinFormsRoot();
- if (adlg.ShowDialog(root) == DialogResult.Cancel)
+ if (adlg.ShowDialog () == DialogResult.Cancel)
result = false;
else
{
@@ -47,7 +38,6 @@ namespace MonoDevelop.Platform
}
finally
{
- t.Enabled = false;
adlg.Dispose();
}
diff --git a/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogEx.cs b/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogEx.cs
index 76ee436043..73f0560ff0 100644
--- a/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogEx.cs
+++ b/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogEx.cs
@@ -437,6 +437,11 @@ namespace CustomControls.Controls
}
}
break;
+ // Make the Winforms message queue and the MD one collaborate
+ case (int) Msg.WM_WINDOWPOSCHANGED:
+ case (int) Msg.WM_ENTERIDLE:
+ MonoDevelop.Ide.DispatchService.RunPendingEvents ();
+ break;
case (int) Msg.WM_IME_NOTIFY:
if (m.WParam == (IntPtr) ImeNotify.IMN_CLOSESTATUSWINDOW)
{
@@ -557,9 +562,6 @@ namespace CustomControls.Controls
protected override void WndProc(ref Message m)
{
- if (m.Msg == (int) Msg.WM_ENTERIDLE)
- MonoDevelop.Ide.DispatchService.RunPendingEvents();
-
if (mWatchForActivate && m.Msg == (int) Msg.WM_ACTIVATE)
{
mWatchForActivate = false;
diff --git a/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogHandler.cs b/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogHandler.cs
index 3a5acb31f8..58ab0730b4 100644
--- a/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogHandler.cs
+++ b/main/src/addins/WindowsPlatform/Dialogs/OpenFileDialogHandler.cs
@@ -49,8 +49,7 @@ namespace MonoDevelop.Platform
SelectFileDialogHandler.SetCommonFormProperties (data, dlg.FileDialog);
using (dlg) {
- WinFormsRoot root = new WinFormsRoot ();
- if (dlg.ShowDialog (root) == DialogResult.Cancel) {
+ if (dlg.ShowDialog () == DialogResult.Cancel) {
parentWindow.Present ();
return false;
}
diff --git a/main/src/addins/WindowsPlatform/Dialogs/WinFormsRoot.cs b/main/src/addins/WindowsPlatform/Dialogs/WinFormsRoot.cs
index 43110cd41e..555a5ef732 100644
--- a/main/src/addins/WindowsPlatform/Dialogs/WinFormsRoot.cs
+++ b/main/src/addins/WindowsPlatform/Dialogs/WinFormsRoot.cs
@@ -1,4 +1,5 @@
using System;
+using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
@@ -9,6 +10,17 @@ namespace MonoDevelop.Platform
{
class WinFormsRoot : Form
{
+ // From OpenFileDialogEx.cs
+ private SetWindowPosFlags UFLAGSHIDE =
+ SetWindowPosFlags.SWP_NOACTIVATE |
+ SetWindowPosFlags.SWP_NOOWNERZORDER |
+ SetWindowPosFlags.SWP_NOMOVE |
+ SetWindowPosFlags.SWP_NOSIZE |
+ SetWindowPosFlags.SWP_HIDEWINDOW;
+
+ IDisposable nativeDialogWindow;
+ bool watchForActivate;
+
public WinFormsRoot()
{
this.Text = "";
@@ -16,16 +28,55 @@ namespace MonoDevelop.Platform
this.Location = new Point(-32000, -32000);
this.ShowInTaskbar = false;
Show();
- // Win32.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, OpenFileDialogEx.UFLAGSHIDE);
+ Win32.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, UFLAGSHIDE);
+ watchForActivate = true;
}
+
+ protected override void OnClosing (CancelEventArgs args)
+ {
+ base.OnClosing (args);
+ if (nativeDialogWindow != null)
+ nativeDialogWindow.Dispose ();
+ }
protected override void WndProc(ref Message m)
- {
- if (m.Msg == (int)Msg.WM_ENTERIDLE)
- MonoDevelop.Ide.DispatchService.RunPendingEvents();
+ {
+ if (m.Msg == (int)Msg.WM_ACTIVATE && watchForActivate) {
+ watchForActivate = false;
+ nativeDialogWindow = new NativeDialogWindow (m.LParam);
+ }
base.WndProc(ref m);
}
+
+ // The CommonDialog's Form Handle
+ class NativeDialogWindow : NativeWindow, IDisposable
+ {
+ IntPtr handle;
+
+ public NativeDialogWindow (IntPtr handle)
+ {
+ this.handle = handle;
+ AssignHandle (handle);
+ }
+
+ public void Dispose ()
+ {
+ ReleaseHandle ();
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ switch (m.Msg) {
+ case (int) Msg.WM_ENTERIDLE:
+ case (int) Msg.WM_WINDOWPOSCHANGED:
+ MonoDevelop.Ide.DispatchService.RunPendingEvents ();
+ break;
+ }
+
+ base.WndProc (ref m);
+ }
+ }
}
class WinFormsRunner