mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-23 03:39:43 -10:00
2007-03-05 Chris Toshok <[email protected]> [merge -r72718:73765 from mwf-handle-branch] 2007-03-05 Chris Toshok <[email protected]> * ControlHandleTest.cs: make this build on both 1.1 and 2.0 profiles. 2007-02-28 Chris Toshok <[email protected]> * ControlTest.cs: Flesh out ControlInvokeTest to make sure that the Control thread dies (that Application.Run returns, basically). This works in isolation, but for some reason it isn't exiting when run in concert with other tests (this test is the cause of the hangs running the unit tests.) Marking NotWorking for the time being. This needs to be fixed before merging back to the mainline, imo. In System.Windows.Forms: 2007-03-07 Chris Toshok <[email protected]> [merge -r72718:73765 from mwf-handle-branch, and include 2 changes to make the rest of the world happy] * Control.cs (CreateHandle): there's no need to call XplatUI.SetVisible here, it's effectively done by XplatUI.CreateWindow on X now, and always was on windows. * XplatUIX11.cs (WaitForHwndMessage): only use the PostQuitState shortcircuit out of the loop if we have a message loop running on this thread. [Changelog from merge] 2007-03-05 Chris Toshok <[email protected]> * Control.cs (AccessibilityNotifyClients): turns out in 1.1 this causes handle creation. 2007-02-28 Chris Toshok <[email protected]> * ApplicationContext.cs: Add a flag to make sure we only raise the ThreadExit event once (ExitThreadCore can be indirectly called from a few places.) I don't like the additional flag, but it makes the event ordering/count correct. * Application.cs (MWFThread.LoopCount): don't use an enumerator without locking the collection. An enumerator doesn't give us any protection from modification anyway. Lock the thread hash and replace the complicated enumerator loop with a foreach. (Application.CloseForms): make internal so it can be called from ApplicationContext. This should probably be moved to MWFThread. (Application.ExitThread): don't call MWFThread.Current.Exit() here. just call XplatUI.PostQuitMessage. We'll exit the thread when the runloop exits (in response to WM_QUIT.) (Application.RunLoop): add a comment (and check) for context.MainForm being null after setting context.MainForm.Visible = true. This is because you're perfectly free to dispose of a form in VisibilityChanged. Chalk this up to another case where we need to synchronously generate WM_ACTIVATE from Control.Show. Also, add handling for WM_QUIT here so we'll exit the loop. * XplatUIX11.cs: clean up MapWindow and UnmapWindow a bit. The fact that we don't wait if we're only unmapping the whole_window makes me a bit nervous, but it doesn't seem to cause any problems yet. also, add a comment about the stupid, broken and wrong resetting of PostQuitState to false in GetMessage(). In PostQuitMessage, we need to add a WM_QUIT message to the thread's queue. We use the FosterParent to get the right handle/hwnd/queue. Lastly, in SetVisible, we need to unmap both windows, since the waiting only happens when we're unmapping the client window. So now, the *only* time we unmap just the whole_window is in the hack for resizing a control to 0,0. 2007-02-21 Chris Toshok <[email protected]> * Application.cs (CloseForms): rewrite this so that we don't modify the list while we're traversing it. 2007-02-20 Chris Toshok <[email protected]> * ListBox.cs (.ctor): move the Control.AddImplicits here instead of OnHandleCreated. (HorizontalScrollEvent): only call XplatUI.ScrollWindow if the handle is created. otherwise we'll create it here. (VerticalScrollEvent): same here. * Application.cs (CloseForms): call Form.Dispose, don't post WM_CLOSE_INTERNAL. * Form.cs (WndProc): we don't need to use CLOSE_INTERNAL here. Application should Dispose() of the Form's. * XplatUIX11.cs (WaitForHwndMessage): break out of the loop on WM_DESTROY as well. (MapWindow,UnmapWindow): only actually do the waiting for SHOWWINDOW if the control we're dealing with is a Form. (CreateWindow): if the control isn't a form, SendMessage WM_SHOWWINDOW here (if the WS_VISIBLE style is set). * Control.cs (SetVisibleCore): always use is_visible here, not value. If we use value, we can end up re-setting something visible if, for instance, you do Control.Hide() in a delegate attached to VisibleChanged as we do in FormTest.ShowDialogTest. 2007-02-20 Chris Toshok <[email protected]> * XplatUIX11.cs (WaitForHwndMessage): we need to loop until we get the message we need. PeekMessage returning false should not be a condition under which we exit the loop. 2007-02-15 Chris Toshok <[email protected]> * Control.cs (Refresh): only refresh if we've got a handle and are visible. (CreateAccessibilityInstance): CreateControl() here. (UpdateChildrenZOrder): complicate the code loop even more by taking into account controls that haven't had their handle created, and those that aren't visible. But on the flip side, simplify the code by splitting it into two loops. one which builds up the list of child controls we're interested in, and the other that sets the z order of those children. 2007-02-14 Chris Toshok <[email protected]> * Control.cs: Control.AccessibilityObject causes the control to be created, not just the handle. 2007-02-14 Chris Toshok <[email protected]> * Control.cs: rework UpdateChildrenZOrder to correctly handle the problem on X where a window might have its handle created (and be visible) while the window is unmapped. calling XConfigureWindow on an unmapped window is bad, and generates X errors. 2007-02-13 Chris Toshok <[email protected]> * Control.cs (CreateHandle): don't loop over our children setting their parent here. do it when in WndProc when we're shown. (UpdateChildrenZOrder): make this internal so we can call it from ScrollableControl. (WndProc): for WM_SHOWWINDOW, reparent the child control after creating its handle. Also, remove the calls to PerformLayout from here. they're done in ScrollableControl.OnVisibleChanged. Also, OnVisibleChanged only seems to be called directly here for the toplevel control. It's propagated down the window hierarchy by calls to child.OnParentVisibleChanged. (OnVisibleChanged): don't do layout here - it's done (oddly enough, according to a glance at stack traces on ms.net..) in ScrollableControl. * ScrollableControl.cs (OnVisibleChanged): make sure we update the z order of our children before calling PerformLayout. 2007-02-12 Chris Toshok <[email protected]> [big change, fixes #80020] * AccessibleObject.cs: we need to make owner internal again to fix some of ControlAccessibleObject. * Control.cs: lots of changes here. add support for WM_CREATE, for which we generate OnHandleCreated. Remove the OnHandleCreated call from CreateHandle. Also add support for WM_SHOWWINDOW where we create child controls. leave the MonoTODO's for the accessibility calls, but fix the exceptions so the tests pass. Add the InvalidOperationExceptions to Invoke methods, and remove a couple of InvokeInternal methods we aren't using. Also, add a couple of CreateHandle calls in places where we know the handles are being created but our code doesn't reference .Handle. Make SetVisibleCore call OnVisibleChange if the handle isn't created. If the handle is created, we rely on XplatUI.SetVisible generating the event synchronously. Lastly, make sure we don't use this.Handle inside CreateHandle, because we can call back into client (and that code can dispose of the control). * XplatUIStructs.cs: misc/cleanup. * XplatUIX11.cs: Map/Unmap X events correspond to WM_SHOWWINDOW, although we don't populate the wParam properly. (CreateWindow): generate WM_CREATE. (MapWindow,UnmapWindow): make these calls synchronous, at great performance expense (particularly in the unmap case), to match win32 behavior. * Form.cs (.ctor): remove the call to UpdateBounds. we don't need to call it. (set_MdiParent): don't recreate the handle unless it's been created already. * MdiClient.cs (OnResize): don't InvalidateNC Parent.Handle unless it's created. * NativeWindow.cs: this is probably the weirdest part of the patch. We need a way to link up the window being created to the WM_CREATE message. Since we can only be creating one window at a time on a given thread, we keep track of a per-thread reference so we can dispatch it properly. We also need to keep track of the Hwnd currently being created so that the win32 backend doesn't have problems. * XplatUIWin32.cs: a similar change to the one we made in NativeWindow.cs. svn path=/trunk/mcs/; revision=73907
127 lines
3.2 KiB
C#
127 lines
3.2 KiB
C#
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
//
|
|
// Copyright (c) 2004 Novell, Inc.
|
|
//
|
|
// Authors:
|
|
// Peter Bartok [email protected]
|
|
//
|
|
|
|
using System.ComponentModel;
|
|
|
|
namespace System.Windows.Forms {
|
|
public class ApplicationContext
|
|
#if NET_2_0
|
|
: IDisposable
|
|
#endif
|
|
{
|
|
#region Local Variables
|
|
Form main_form;
|
|
#if NET_2_0
|
|
object tag;
|
|
#endif
|
|
bool thread_exit_raised;
|
|
|
|
#endregion // Local Variables
|
|
|
|
#region Public Constructors & Destructors
|
|
public ApplicationContext() : this(null) {
|
|
}
|
|
|
|
public ApplicationContext(Form mainForm) {
|
|
MainForm = mainForm; // Use property to get event handling setup
|
|
}
|
|
|
|
~ApplicationContext() {
|
|
this.Dispose(false);
|
|
}
|
|
#endregion // Public Constructors & Destructors
|
|
|
|
#region Public Instance Properties
|
|
public Form MainForm {
|
|
get {
|
|
return main_form;
|
|
}
|
|
|
|
set {
|
|
if (main_form != value) {
|
|
// Catch when the form is destroyed so we can fire OnMainFormClosed
|
|
|
|
if (main_form != null) {
|
|
main_form.HandleDestroyed -= new EventHandler(OnMainFormClosed);
|
|
}
|
|
main_form = value;
|
|
if (main_form != null) {
|
|
main_form.HandleDestroyed += new EventHandler(OnMainFormClosed);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#if NET_2_0
|
|
[BindableAttribute (true)]
|
|
[DefaultValue (null)]
|
|
[LocalizableAttribute (false)]
|
|
[TypeConverterAttribute (typeof(StringConverter))]
|
|
public Object Tag {
|
|
get { return tag; }
|
|
set { tag = value; }
|
|
}
|
|
#endif
|
|
#endregion // Public Instance Properties
|
|
|
|
#region Public Instance Methods
|
|
public void Dispose() {
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
public void ExitThread() {
|
|
ExitThreadCore();
|
|
}
|
|
#endregion // Public Instance Methods
|
|
|
|
#region Protected Instance Methods
|
|
protected virtual void Dispose(bool disposing) {
|
|
main_form = null;
|
|
#if NET_2_0
|
|
tag = null;
|
|
#endif
|
|
}
|
|
|
|
protected virtual void ExitThreadCore() {
|
|
XplatUI.PostQuitMessage(0);
|
|
if (!thread_exit_raised && ThreadExit != null) {
|
|
thread_exit_raised = true;
|
|
ThreadExit(this, EventArgs.Empty);
|
|
}
|
|
}
|
|
|
|
protected virtual void OnMainFormClosed(object sender, EventArgs e) {
|
|
if (!MainForm.RecreatingHandle)
|
|
ExitThreadCore();
|
|
}
|
|
#endregion // Public Instance Methods
|
|
|
|
#region Events
|
|
public event EventHandler ThreadExit;
|
|
#endregion // Events
|
|
}
|
|
}
|