Merge pull request #943 from ermshiperete/bug-novell-325669
authorMiguel de Icaza <miguel@gnome.org>
Fri, 16 May 2014 14:54:22 +0000 (10:54 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Fri, 16 May 2014 14:54:22 +0000 (10:54 -0400)
[MWF] Implement multi-display support on Linux (Fixes #325669)

1  2 
configure.in
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources

diff --combined configure.in
index 104908f858e6f3dc4aa2734e3b14085cddcdfcc2,a5b478fb98cb81c4d6144931f29f0205d86eba5b..93f228973c29898a64ce243d880a69d7be36b968
@@@ -1,7 -1,7 +1,7 @@@
  # Process this file with autoconf to produce a configure script.
  #AC_PREREQ([2.62])
  
 -AC_INIT(mono, [3.4.0],
 +AC_INIT(mono, [3.4.1],
          [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
  
  AC_CONFIG_SRCDIR([README.md])
@@@ -237,12 -237,6 +237,12 @@@ case "$host" i
                        # available during cross-compilation
                        mono_cv_uscore=no
                  fi
 +              case "$host" in
 +              aarch64-*)
 +                      support_boehm=no
 +                      with_gc=sgen
 +                      ;;
 +              esac
                ;;
        *-*-nacl*)
                host_win32=no
@@@ -522,9 -516,6 +522,9 @@@ if test x"$GCC" = xyes; the
                # The runtime code does not respect ANSI C strict aliasing rules
                CFLAGS="$CFLAGS -fno-strict-aliasing"
  
 +              # We rely on signed overflow to behave
 +              CFLAGS="$CFLAGS -fwrapv"
 +
                ORIG_CFLAGS=$CFLAGS
                CFLAGS="$CFLAGS -Wdeclaration-after-statement"
                AC_MSG_CHECKING(for -Wdeclaration-after-statement option to gcc)
                if test "x$mono_cv_clang" = "xyes"; then
                   # https://bugzilla.samba.org/show_bug.cgi?id=8118
                   WARN="$WARN -Qunused-arguments"
 -                 WARN="$WARN -Wno-unused-function -Wno-tautological-compare"
 +                 WARN="$WARN -Wno-unused-function -Wno-tautological-compare -Wno-parentheses-equality -Wno-self-assign"
                fi
  else
        # The Sun Forte compiler complains about inline functions that access static variables
@@@ -1588,7 -1579,7 +1588,7 @@@ if test x$target_win32 = xno; the
        AC_CHECK_HEADERS(pthread.h)
        AC_CHECK_HEADERS(pthread_np.h)
        AC_CHECK_FUNCS(pthread_mutex_timedlock)
 -      AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np)
 +      AC_CHECK_FUNCS(pthread_getattr_np pthread_attr_get_np pthread_setname_np)
        AC_CHECK_FUNCS(pthread_kill)
        AC_MSG_CHECKING(for PTHREAD_MUTEX_RECURSIVE)
        AC_TRY_COMPILE([ #include <pthread.h>], [
        dnl * back 
        dnl **************************************
        if test "x$havekqueue" = "xyes" -a "x$ac_cv_header_sys_event_h" = "xyes"; then
 -              if x$platform_darwin = xno; then
 +              if test "x$platform_darwin" = "xno"; then
                        AC_DEFINE(USE_KQUEUE_FOR_THREADPOOL, 1, [Use kqueue for the threadpool])
                fi
        fi
@@@ -2442,15 -2433,13 +2442,15 @@@ if test "x$enable_llvm" = "xyes"; the
     # from LLVM classes.
     LLVM_CXXFLAGS="`$LLVM_CONFIG --cxxflags` -fno-rtti"
     LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
 +   # This might include empty lines
 +   LLVM_SYSTEM_LIBS=`$LLVM_CONFIG --system-libs 2>/dev/null | grep -- -`
     if test "x$host" != "x$target"; then
        # No need for jit libs
        LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter`
     else
        LLVM_LIBS=`$LLVM_CONFIG --libs core bitwriter jit mcjit $llvm_codegen`
     fi
 -   LLVM_LIBS="$LLVM_LIBS $LLVM_LDFLAGS -lstdc++"
 +   LLVM_LIBS="$LLVM_LIBS $LLVM_LDFLAGS $LLVM_SYSTEM_LIBS -lstdc++"
  
     expected_llvm_version="3.4svn-mono-mono/e656cac"
  
     llvm_version=`$LLVM_CONFIG --version`
     major_version=`echo $llvm_version | cut -c 1`
     minor_version=`echo $llvm_version | cut -c 3`
 +   llvm_api_version=`$LLVM_CONFIG --mono-api-version 2>/dev/null`
     AC_MSG_CHECKING(LLVM version)
     AC_MSG_RESULT($llvm_version)
     if echo $llvm_version | grep -q 'mono'; then
 -        AC_DEFINE(LLVM_MONO_BRANCH, 1, [Whenever we are using the mono branch of LLVM])
 -        LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_MONO_BRANCH"       
          if test "x$enable_llvm_version_check" == "xyes"; then
                 if test "$llvm_version" != "$expected_llvm_version"; then
                        AC_MSG_ERROR([Expected llvm version $expected_llvm_version, but llvm-config --version returned $llvm_version"])
                 fi
          fi
 +        if test "x$llvm_api_version" = "x"; then
 +              LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_API_VERSION=0"
 +        else
 +              LLVM_CXXFLAGS="$LLVM_CXXFLAGS -DLLVM_API_VERSION=$llvm_api_version"
 +        fi
     else
          AC_MSG_ERROR([Compiling with stock LLVM is not supported, please use the Mono LLVM repo at https://github.com/mono/llvm, with the GIT branch which matches this version of mono, i.e. 'mono-2-10' for Mono 2.10.])
     fi
@@@ -2507,13 -2492,13 +2507,14 @@@ INTL="libc.so.6
  SQLITE="libsqlite.so.0"
  SQLITE3="libsqlite3.so.0"
  X11="libX11.so"
+ XINERAMA="libXinerama.so"
  
  sizeof_register="SIZEOF_VOID_P"
  
  jit_wanted=true
  interp_wanted=false
  sgen_supported=false
 +boehm_supported=true
  case "$host" in
        mips*)
                TARGET=MIPS;
  #             sgen_supported=true
  #             AOT_SUPPORTED="no"
  #             ;;
 +      aarch64-*)
 +              # https://lkml.org/lkml/2012/7/15/133
 +              TARGET=ARM64
 +              arch_target=arm64
 +              JIT_SUPPORTED=yes
 +              sgen_supported=true
 +              boehm_supported=false
 +              ;;
        s390x-*-linux*)
                TARGET=S390X;
                arch_target=s390x;
@@@ -2784,7 -2761,6 +2785,7 @@@ if test "x$host" != "x$target"; the
                TARGET=ARM;
                arch_target=arm;
                AC_DEFINE(TARGET_ARM, 1, [...])
 +              AC_DEFINE(TARGET_ANDROID, 1, [...])
                ACCESS_UNALIGNED="no"
                JIT_SUPPORTED=yes
                CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
                        CPPFLAGS="$CPPFLAGS"
                        ;;
                armv5-*-linux-androideabi*)
 -                      AC_DEFINE(TARGET_ANDROID, 1, [...])
                        CPPFLAGS="$CPPFLAGS"
                        ;;
                esac
                ;;
 +      aarch64-*)
 +              TARGET=ARM64
 +              JIT_SUPPORTED=yes
 +              jit_wanted=true
 +              ;;
        *)
                AC_MSG_ERROR([Cross compiling is not supported for target $target])
        esac
@@@ -2823,9 -2795,6 +2824,9 @@@ AMD64
  ARM)
        AC_DEFINE(TARGET_ARM, 1, [...])
        ;;
 +ARM64)
 +      AC_DEFINE(TARGET_ARM64, 1, [...])
 +      ;;
  POWERPC)
        AC_DEFINE(TARGET_POWERPC, 1, [...])
        ;;
  dnl Use GCC atomic ops if they work on the target.
  if test x$GCC = "xyes"; then
        case $TARGET in
 -      X86 | AMD64 | ARM | POWERPC | POWERPC64 | MIPS | S390X | SPARC | SPARC64)
 +      X86 | AMD64 | ARM | ARM64 | POWERPC | POWERPC64 | MIPS | S390X | SPARC | SPARC64)
                AC_DEFINE(USE_GCC_ATOMIC_OPS, 1, [...])
                ;;
        esac
  fi
  
  if test "x$target_mach" = "xyes"; then
 -   if test "x$TARGET" = "xARM"; then
 +   if test "x$TARGET" = "xARM" -o "x$TARGET" = "xARM64"; then
          AC_DEFINE(TARGET_IOS,1,[The JIT/AOT targets iOS])
          CPPFLAGS_FOR_LIBGC="$CPPFLAGS_FOR_LIBGC -DTARGET_IOS"
          CFLAGS_FOR_LIBGC="$CFLAGS_FOR_LIBGC -DTARGET_IOS"
@@@ -2995,6 -2964,18 +2996,18 @@@ case "$host" i
                AC_MSG_WARN([Could not find X development libs. Do you have the -devel package installed? Assuming libX11.so.6...]);
                X11=libX11.so.6
        fi
+       AC_MSG_CHECKING(for the soname of libXinerama.so)
+       for i in $x_libraries $dlsearch_path; do
+               for r in 1 2 3; do
+                       if test -f $i/libXinerama.so.$r; then
+                               XINERAMA=libXinerama.so.$r
+                               AC_MSG_RESULT($XINERAMA)
+                       fi
+               done
+       done
+       if test "x$XINERAMA" = "xlibXinerama.so"; then
+               AC_MSG_WARN([Could not find Xinerama development libs. Support for multiple monitors might not work...]);
+       fi
        ;;
  esac
  
@@@ -3327,12 -3308,10 +3340,12 @@@ AM_CONDITIONAL(MIPS, test x$TARGET = xM
  AM_CONDITIONAL(POWERPC, test x$TARGET = xPOWERPC)
  AM_CONDITIONAL(POWERPC64, test x$TARGET = xPOWERPC64)
  AM_CONDITIONAL(ARM, test x$TARGET = xARM)
 +AM_CONDITIONAL(ARM64, test x$TARGET = xARM64)
  AM_CONDITIONAL(S390X, test x$TARGET = xS390X)
  AM_CONDITIONAL(HOST_X86, test x$HOST = xX86)
  AM_CONDITIONAL(HOST_AMD64, test x$HOST = xAMD64)
  AM_CONDITIONAL(HOST_ARM, test x$HOST = xARM)
 +AM_CONDITIONAL(HOST_ARM64, test x$HOST = xARM64)
  AM_CONDITIONAL(CROSS_COMPILE, test "x$host" != "x$target")
  
  AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
@@@ -3344,6 -3323,7 +3357,7 @@@ AC_SUBST(INTL
  AC_SUBST(SQLITE)
  AC_SUBST(SQLITE3)
  AC_SUBST(X11)
+ AC_SUBST(XINERAMA)
  AC_DEFINE_UNQUOTED(ARCHITECTURE,"$arch_target",[The architecture this is running on])
  AC_SUBST(arch_target)
  AC_SUBST(CFLAGS)
@@@ -3551,7 -3531,6 +3565,7 @@@ mono/arch/ppc/Makefil
  mono/arch/sparc/Makefile
  mono/arch/s390x/Makefile
  mono/arch/arm/Makefile
 +mono/arch/arm64/Makefile
  mono/arch/ia64/Makefile
  mono/arch/mips/Makefile
  mono/interpreter/Makefile
@@@ -3565,7 -3544,6 +3579,7 @@@ mono/tests/cas/inheritance/Makefil
  mono/tests/cas/linkdemand/Makefile
  mono/tests/cas/threads/Makefile
  mono/tests/gc-descriptors/Makefile
 +mono/unit-tests/Makefile
  mono/benchmark/Makefile
  mono/monograph/Makefile
  mono/io-layer/Makefile
@@@ -3592,6 -3570,7 +3606,6 @@@ data/mono-nunit.p
  data/mono-options.pc
  data/mono-lineeditor.pc
  data/monodoc.pc
 -data/mono.web.pc
  data/dotnet.pc
  data/dotnet35.pc
  data/wcf.pc
index 14345a6a491f8feb2916a136d7de9ee7dd285108,07bf3e56fb33e7343d9322d603f28da49c4dede5..fad6981b745964226a9ff363374068cfde4946ef
@@@ -2315,16 -2315,7 +2315,16 @@@ namespace System.Windows.Form
                                        return owner.Focused;
                                }
                        }
 -                      
 +                      protected override void Dispose(bool disposing)
 +                      {
 +                              if (disposing ) {
 +                                      // Prevents corruption of combobox text by disposed object
 +                                      owner.EnabledChanged -= OwnerEnabledChangedHandler;
 +                                      owner.LostFocus -= OwnerLostFocusHandler;
 +                              }
 +                              base.Dispose(disposing);
 +                      }
 +
                        internal override bool ActivateOnShow { get { return false; } }
                }
  
                                                vscrollbar_ctrl.Value = hli;
                                        }
                                }
 -                              
 -                              Size = new Size (width, height);
 -                              textarea_drawable = ClientRectangle;
 -                              textarea_drawable.Width = width;
 -                              textarea_drawable.Height = height;
 -                              
 +
 +                              var borderWidth = Hwnd.GetBorderWidth (CreateParams);
 +                              var borderAdjustment = dropdown_style == ComboBoxStyle.Simple ? new Size (0, 0) :
 +                                      new Size (borderWidth.top + borderWidth.bottom, borderWidth.left + borderWidth.right);
 +                              Size = new Size (width, height + borderAdjustment.Height);
 +                              textarea_drawable = new Rectangle (ClientRectangle.Location,
 +                                      new Size (width - borderAdjustment.Width, height));
 +
                                if (vscrollbar_ctrl != null && show_scrollbar)
                                        textarea_drawable.Width -= vscrollbar_ctrl.Width;
  
                                HighlightedIndex = owner.SelectedIndex;
  
                                CalcListBoxArea ();
+                               // If the listbox would extend below the screen, move it above the textbox.
+                               Rectangle scrn_rect = Screen.FromControl (owner).Bounds;
+                               if (this.Location.Y + this.Height >= scrn_rect.Bottom)
+                                       this.Location = new Point (this.Location.X, this.Location.Y - (this.Height + owner.TextArea.Height));
                                Show ();
  
                                Refresh ();
index 2f3b9d85461287a98718c52431037c72e7d6c0f0,3500501dbe62e1de6e54b42334abcb73d416ee7b..c25124033921bcc71ee367c0f780916bdca36f83
@@@ -2594,6 -2594,28 +2594,28 @@@ namespace System.Windows.Forms 
                        }
                }
  
+               internal override Screen[] AllScreens {
+                       get {
+                               if (!XineramaIsActive (DisplayHandle))
+                                       return null;
+                               int nScreens;
+                               IntPtr xineramaScreens = XineramaQueryScreens (DisplayHandle, out nScreens);
+                               var screens = new Screen [nScreens];
+                               IntPtr current = xineramaScreens;
+                               for (int i = 0; i < nScreens; i++) {
+                                       var screen = (XineramaScreenInfo)Marshal.PtrToStructure (current,
+                                               typeof (XineramaScreenInfo));
+                                       var screenRect = new Rectangle (screen.x_org, screen.y_org, screen.width,
+                                               screen.height);
+                                       var name = string.Format ("Display {0}", screen.screen_number);
+                                       screens [i] = new Screen (i == 0, name, screenRect, screenRect);
+                                       current = (IntPtr)( (ulong)current + (ulong)Marshal.SizeOf(typeof (XineramaScreenInfo)));
+                               }
+                               XFree (xineramaScreens);
+                               return screens;
+                       }
+               }
                internal override bool ThemesEnabled {
                        get {
                                return XplatUIX11.themes_enabled;
                        while (f != null) {
                                XConvertSelection(DisplayHandle, CLIPBOARD, (IntPtr)f.Id, (IntPtr)f.Id, FosterParent, IntPtr.Zero);
  
 +                              var timeToWaitForSelectionFormats = TimeSpan.FromSeconds(4);
 +                              var startTime = DateTime.Now;
                                Clipboard.Enumerating = true;
                                while (Clipboard.Enumerating) {
                                        UpdateMessageQueue(null, false);
 +
 +                                      if (DateTime.Now - startTime > timeToWaitForSelectionFormats)
 +                                              break;
                                }
                                f = f.Next;
                        }
                }
  #endregion
  
+ #region Xinerama imports
+               [DllImport ("libXinerama", EntryPoint="XineramaQueryScreens")]
+               extern static IntPtr _XineramaQueryScreens (IntPtr display, out int number);
+               internal static IntPtr XineramaQueryScreens (IntPtr display, out int number)
+               {
+                       DebugHelper.TraceWriteLine ("XineramaQueryScreens");
+                       return _XineramaQueryScreens (display, out number);
+               }
+               [DllImport ("libXinerama", EntryPoint="XineramaIsActive")]
+               extern static bool _XineramaIsActive (IntPtr display);
+               static bool XineramaNotInstalled;
+               internal static bool XineramaIsActive (IntPtr display)
+               {
+                       DebugHelper.TraceWriteLine ("XineramaIsActive");
+                       if (XineramaNotInstalled)
+                               return false;
+                       try {
+                               return _XineramaIsActive (display);
+                       } catch (DllNotFoundException) {
+                               // Xinerama isn't installed
+                               XineramaNotInstalled = true;
+                               return false;
+                       }
+               }
+ #endregion
  
  #else //no TRACE defined
  
                internal extern static void gtk_clipboard_set_text (IntPtr clipboard, string text, int len);
  #endregion
  
+ #region Xinerama imports
+               [DllImport ("libXinerama")]
+               internal extern static IntPtr XineramaQueryScreens (IntPtr display, out int number);
+               [DllImport ("libXinerama", EntryPoint = "XineramaIsActive")]
+               extern static bool _XineramaIsActive (IntPtr display);
+               static bool XineramaNotInstalled;
+               internal static bool XineramaIsActive (IntPtr display)
+               {
+                       if (XineramaNotInstalled)
+                               return false;
+                       try {
+                               return _XineramaIsActive (display);
+                       } catch (DllNotFoundException) {
+                               // Xinerama isn't installed
+                               XineramaNotInstalled = true;
+                               return false;
+                       }
+               }
+ #endregion
  #endif
        }
  }
index e14341db1a9f62588375b5e9dcbf84466e5f7dca,fa52a1873eb4b00f19f171ebeb89186efe5884c6..e9a833018a6d5e4e82a0718a12ab7cd4e9cc9bf4
@@@ -63,7 -63,6 +63,7 @@@ System.Windows.Forms/DataGridViewLinkCe
  System.Windows.Forms/DataGridViewImageCellTest.cs
  System.Windows.Forms/DataGridViewRowCollectionTest.cs
  System.Windows.Forms/DataGridViewRowHeaderTest.cs
 +System.Windows.Forms/DataGridViewRowHeightInfoNeededEventArgsTests.cs
  System.Windows.Forms/DataGridViewRowTest.cs
  System.Windows.Forms/DataGridViewTest.cs
  System.Windows.Forms/DataGridViewTextBoxCellTest.cs
@@@ -131,6 -130,7 +131,7 @@@ System.Windows.Forms/RichTextBoxTest.c
  System.Windows.Forms/SaveFileDialogTest.cs
  System.Windows.Forms/ScrollableControlTest.cs
  System.Windows.Forms/ScrollBarTest.cs
+ System.Windows.Forms/ScreenTest.cs
  System.Windows.Forms/SelectionRangeTest.cs
  System.Windows.Forms/SendKeysTest.cs
  System.Windows.Forms/SplitterTest.cs