Added:
trunk/moon/m4/pal.m4
trunk/moon/src/pal/
trunk/moon/src/pal/gtk/
trunk/moon/src/pal/gtk/clipboard-gtk.cpp
trunk/moon/src/pal/gtk/clipboard-gtk.h
trunk/moon/src/pal/gtk/im-gtk.cpp
trunk/moon/src/pal/gtk/im-gtk.h
trunk/moon/src/pal/gtk/pal-gtk.cpp
trunk/moon/src/pal/gtk/pal-gtk.h
trunk/moon/src/pal/gtk/pixbuf-gtk.cpp
trunk/moon/src/pal/gtk/pixbuf-gtk.h
trunk/moon/src/pal/gtk/window-gtk.cpp
trunk/moon/src/pal/gtk/window-gtk.h
trunk/moon/src/pal/gtk/windowless-gtk.cpp
trunk/moon/src/pal/gtk/windowless-gtk.h
trunk/moon/src/pal/pal.h
trunk/moon/src/pal/window.h
Removed:
trunk/moon/plugin/windowless.cpp
trunk/moon/plugin/windowless.h
trunk/moon/src/messagebox.cpp
trunk/moon/src/messagebox.h
trunk/moon/src/window-gtk.cpp
trunk/moon/src/window-gtk.h
trunk/moon/src/window.h
Modified:
trunk/moon/class/System.Windows/Mono/GeneratedPInvokes.cs
trunk/moon/class/System.Windows/System.Windows.Controls/OpenFileDialog.cs
trunk/moon/class/System.Windows/System.Windows.Controls/SaveFileDialog.cs
trunk/moon/class/System.Windows/System.Windows/Events.g.cs
trunk/moon/class/System.Windows/System.Windows/MessageBox.cs
trunk/moon/class/tuning/SecurityAttributes/automatic/System.Windows.auto.sc
trunk/moon/configure.ac
trunk/moon/gtk/Moonlight.Gtk/MoonlightHost.cs
trunk/moon/perf/perf-suite-tool/perf-suite-tool.cpp
trunk/moon/plugin/Makefile.am
trunk/moon/plugin/cbinding.h
trunk/moon/plugin/firefox/ff2/Makefile.am
trunk/moon/plugin/firefox/ff3/Makefile.am
trunk/moon/plugin/moonlight.h
trunk/moon/plugin/plugin-class.cpp
trunk/moon/plugin/plugin-debug.cpp
trunk/moon/plugin/plugin.cpp
trunk/moon/src/Makefile.am
trunk/moon/src/bitmapimage.cpp
trunk/moon/src/bitmapimage.h
trunk/moon/src/canvas.cpp
trunk/moon/src/cbinding.cpp
trunk/moon/src/cbinding.h
trunk/moon/src/deepzoomimagetilesource.cpp
trunk/moon/src/dependencyproperty.cpp
trunk/moon/src/dirty.cpp
trunk/moon/src/downloader.cpp
trunk/moon/src/enums.h
trunk/moon/src/eventargs.cpp
trunk/moon/src/eventargs.h
trunk/moon/src/glyphs.cpp
trunk/moon/src/keyboard.cpp
trunk/moon/src/keyboard.h
trunk/moon/src/media.h
trunk/moon/src/mediaelement.h
trunk/moon/src/openfile.cpp
trunk/moon/src/openfile.h
trunk/moon/src/pipeline-nocodec-ui.cpp
trunk/moon/src/pipeline-ui.cpp
trunk/moon/src/popup.cpp
trunk/moon/src/resources.cpp
trunk/moon/src/runtime.cpp
trunk/moon/src/runtime.h
trunk/moon/src/stylus.h
trunk/moon/src/textbox.cpp
trunk/moon/src/textbox.h
trunk/moon/src/type-generated.cpp
trunk/moon/src/uielement.cpp
trunk/moon/src/uielement.h
trunk/moon/test/parsertest/Makefile.am
trunk/moon/test/sizes/Makefile.am
trunk/moon/tools/generators/Generator.cs
trunk/moon/tools/generators/MemberInfo.cs
Log:
merge PAL branch onto trunk
Modified: trunk/moon/class/System.Windows/Mono/GeneratedPInvokes.cs
===================================================================
--- trunk/moon/class/System.Windows/Mono/GeneratedPInvokes.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/System.Windows/Mono/GeneratedPInvokes.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1396,6 +1396,10 @@
public extern static IntPtr media_frame_new (IntPtr stream, IntPtr buffer, uint buflen, ulong pts, [MarshalAs (UnmanagedType.U1)] bool keyframe);
[DllImport ("moon")]
+ // gpointer moon_window_get_platform_window (MoonWindow *instance);
+ public extern static IntPtr moon_window_get_platform_window (IntPtr instance);
+
+ [DllImport ("moon")]
[return: MarshalAs (UnmanagedType.U1)]
// bool moon_window_get_transparent (MoonWindow *instance);
public extern static bool moon_window_get_transparent (IntPtr instance);
@@ -1405,14 +1409,32 @@
public extern static void moon_window_set_transparent (IntPtr instance, [MarshalAs (UnmanagedType.U1)] bool flag);
[DllImport ("moon")]
- // void *moon_window_gtk_get_native_widget (MoonWindowGtk *instance);
- public extern static IntPtr moon_window_gtk_get_native_widget (IntPtr instance);
+ // MoonWindow *moon_windowing_system_create_window (MoonWindowingSystem *instance, bool fullscreen, int width, int height, MoonWindow *parentWindow, Surface *surface);
+ public extern static IntPtr moon_windowing_system_create_window (IntPtr instance, [MarshalAs (UnmanagedType.U1)] bool fullscreen, int width, int height, IntPtr parentWindow, IntPtr surface);
[DllImport ("moon")]
- // MoonWindowGtk *moon_window_gtk_new (bool fullscreen, int w, int h, MoonWindow *parent, Surface *surface);
- public extern static IntPtr moon_window_gtk_new ([MarshalAs (UnmanagedType.U1)] bool fullscreen, int w, int h, IntPtr parent, IntPtr surface);
+ // int moon_windowing_system_show_message_box (MoonWindowingSystem *instance, const char *caption, const char *text, int buttons);
+ public extern static int moon_windowing_system_show_message_box (IntPtr instance, string caption, string text, int buttons);
[DllImport ("moon")]
+ // gchar* *moon_windowing_system_show_open_file_dialog (MoonWindowingSystem *instance, const char *title, bool multsel, const char *filter, int idx);
+ public extern static IntPtr moon_windowing_system_show_open_file_dialog (IntPtr instance, string title, [MarshalAs (UnmanagedType.U1)] bool multsel, string filter, int idx);
+
+ [DllImport ("moon", EntryPoint="moon_windowing_system_show_save_file_dialog")]
+ // char *moon_windowing_system_show_save_file_dialog (MoonWindowingSystem *instance, const char *title, const char *filter, int idx);
+ private extern static IntPtr moon_windowing_system_show_save_file_dialog_ (IntPtr instance, string title, string filter, int idx);
+ public static string moon_windowing_system_show_save_file_dialog (IntPtr instance, string title, string filter, int idx)
+ {
+ IntPtr result;
+ result = moon_windowing_system_show_save_file_dialog_ (instance, title, filter, idx);
+ if (result == IntPtr.Zero)
+ return null;
+ string s = Marshal.PtrToStringAnsi (result); // *copy* unmanaged string
+ Marshal.FreeHGlobal (result); // g_free the unmanaged string
+ return s;
+ }
+
+ [DllImport ("moon")]
// MouseButtonEventArgs *mouse_button_event_args_new ();
public extern static IntPtr mouse_button_event_args_new ();
@@ -2472,26 +2494,16 @@
}
[DllImport ("moon")]
- // int message_box_show (const char *caption, const char *text, int buttons);
- public extern static int message_box_show (string caption, string text, int buttons);
+ // int local_message_receiver_create_listening_point (const char *domain, const char *receiverName);
+ public extern static int local_message_receiver_create_listening_point (string domain, string receiverName);
[DllImport ("moon")]
- // char* *open_file_dialog_show (const char *title, bool multsel, const char *filter, int idx);
- public extern static IntPtr open_file_dialog_show (string title, [MarshalAs (UnmanagedType.U1)] bool multsel, string filter, int idx);
+ // int local_message_receiver_destroy_listening_point (const char *domain, const char *receiverName);
+ public extern static int local_message_receiver_destroy_listening_point (string domain, string receiverName);
- [DllImport ("moon", EntryPoint="save_file_dialog_show")]
- // char *save_file_dialog_show (const char *title, const char *filter, int idx);
- private extern static IntPtr save_file_dialog_show_ (string title, string filter, int idx);
- public static string save_file_dialog_show (string title, string filter, int idx)
- {
- IntPtr result;
- result = save_file_dialog_show_ (title, filter, idx);
- if (result == IntPtr.Zero)
- return null;
- string s = Marshal.PtrToStringAnsi (result); // *copy* unmanaged string
- Marshal.FreeHGlobal (result); // g_free the unmanaged string
- return s;
- }
+ [DllImport ("moon")]
+ // int local_message_sender_send_message_async (const char *receiverName, const char *receiverDomain, const char *message);
+ public extern static int local_message_sender_send_message_async (string receiverName, string receiverDomain, string message);
[DllImport ("moon")]
// void runtime_init_desktop ();
@@ -2503,6 +2515,10 @@
public extern static bool runtime_is_running_out_of_browser ();
[DllImport ("moon")]
+ // MoonWindowingSystem *runtime_get_windowing_system ();
+ public extern static IntPtr runtime_get_windowing_system ();
+
+ [DllImport ("moon")]
// void size_changed_event_args_get_prev_size (SizeChangedEventArgs *args, Size *prev_size);
public extern static void size_changed_event_args_get_prev_size (IntPtr args, ref Size prev_size);
Modified: trunk/moon/class/System.Windows/System.Windows/Events.g.cs
===================================================================
--- trunk/moon/class/System.Windows/System.Windows/Events.g.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/System.Windows/System.Windows/Events.g.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -94,7 +94,9 @@
public const int Surface_ResizeEvent = 4;
public const int Surface_SourceDownloadCompleteEvent = 5;
public const int Surface_SourceDownloadProgressChangedEvent = 6;
- public const int Surface_ZoomedEvent = 7;
+ public const int Surface_WindowAvailableEvent = 7;
+ public const int Surface_WindowUnavailableEvent = 8;
+ public const int Surface_ZoomedEvent = 9;
public const int TextBox_SelectionChangedEvent = 22;
public const int TextBox_TextChangedEvent = 23;
public const int TextBoxBase_CursorPositionChangedEvent = 20;
Modified: trunk/moon/class/System.Windows/System.Windows/MessageBox.cs
===================================================================
--- trunk/moon/class/System.Windows/System.Windows/MessageBox.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/System.Windows/System.Windows/MessageBox.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -29,7 +29,8 @@
if ((button < MessageBoxButton.OK) || (button > MessageBoxButton.OKCancel))
throw new ArgumentException ("button");
- return (MessageBoxResult) NativeMethods.message_box_show (caption, messageBoxText, (int) button);
+ IntPtr windowing_system = NativeMethods.runtime_get_windowing_system ();
+ return (MessageBoxResult) NativeMethods.moon_windowing_system_show_message_box (windowing_system, caption, messageBoxText, (int) button);
}
public static MessageBoxResult Show (string messageBoxText)
Modified: trunk/moon/class/System.Windows/System.Windows.Controls/OpenFileDialog.cs
===================================================================
--- trunk/moon/class/System.Windows/System.Windows.Controls/OpenFileDialog.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/System.Windows/System.Windows.Controls/OpenFileDialog.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -51,7 +51,9 @@
// it's not clear from doc or tests when this can return null
public bool? ShowDialog ()
{
- IntPtr result = NativeMethods.open_file_dialog_show ("Open",
+ IntPtr windowing_system = NativeMethods.runtime_get_windowing_system ();
+ IntPtr result = NativeMethods.moon_windowing_system_show_open_file_dialog (windowing_system,
+ "Open",
allow_multiple_selection,
filter,
filter_index);
Modified: trunk/moon/class/System.Windows/System.Windows.Controls/SaveFileDialog.cs
===================================================================
--- trunk/moon/class/System.Windows/System.Windows.Controls/SaveFileDialog.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/System.Windows/System.Windows.Controls/SaveFileDialog.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -101,7 +101,9 @@
if (!NativeMethods.surface_is_user_initiated_event (Deployment.Current.Surface.Native))
throw new SecurityException ("Action was not initiated by the user");
- string result = NativeMethods.save_file_dialog_show ("Save", filter, filter_index);
+ IntPtr windowing_system = NativeMethods.runtime_get_windowing_system ();
+ string result = NativeMethods.moon_windowing_system_show_save_file_dialog (windowing_system,
+ "Save", filter, filter_index);
if (result == null)
return false;
Modified: trunk/moon/class/tuning/SecurityAttributes/automatic/System.Windows.auto.sc
===================================================================
--- trunk/moon/class/tuning/SecurityAttributes/automatic/System.Windows.auto.sc 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/class/tuning/SecurityAttributes/automatic/System.Windows.auto.sc 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,5 +1,5 @@
# [SecurityCritical] needed to execute code inside 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
-# 595 methods needs to be decorated.
+# 599 methods needs to be decorated.
# p/invoke declaration
+SC-M: Mono.Kind Mono.NativeMethods::collection_get_element_type(System.IntPtr)
@@ -332,9 +332,18 @@
+SC-M: System.Int32 Mono.NativeMethods::keyboard_get_modifiers()
# p/invoke declaration
-+SC-M: System.Int32 Mono.NativeMethods::message_box_show(System.String,System.String,System.Int32)
++SC-M: System.Int32 Mono.NativeMethods::local_message_receiver_create_listening_point(System.String,System.String)
# p/invoke declaration
++SC-M: System.Int32 Mono.NativeMethods::local_message_receiver_destroy_listening_point(System.String,System.String)
+
+# p/invoke declaration
++SC-M: System.Int32 Mono.NativeMethods::local_message_sender_send_message_async(System.String,System.String,System.String)
+
+# p/invoke declaration
++SC-M: System.Int32 Mono.NativeMethods::moon_windowing_system_show_message_box(System.IntPtr,System.String,System.String,System.Int32)
+
+# p/invoke declaration
+SC-M: System.Int32 Mono.NativeMethods::mouse_wheel_event_args_get_wheel_delta(System.IntPtr)
# p/invoke declaration
@@ -797,12 +806,18 @@
+SC-M: System.IntPtr Mono.NativeMethods::media_frame_new(System.IntPtr,System.IntPtr,System.UInt32,System.UInt64,System.Boolean)
# p/invoke declaration
-+SC-M: System.IntPtr Mono.NativeMethods::moon_window_gtk_get_native_widget(System.IntPtr)
++SC-M: System.IntPtr Mono.NativeMethods::moon_window_get_platform_window(System.IntPtr)
# p/invoke declaration
-+SC-M: System.IntPtr Mono.NativeMethods::moon_window_gtk_new(System.Boolean,System.Int32,System.Int32,System.IntPtr,System.IntPtr)
++SC-M: System.IntPtr Mono.NativeMethods::moon_windowing_system_create_window(System.IntPtr,System.Boolean,System.Int32,System.Int32,System.IntPtr,System.IntPtr)
# p/invoke declaration
++SC-M: System.IntPtr Mono.NativeMethods::moon_windowing_system_show_open_file_dialog(System.IntPtr,System.String,System.Boolean,System.String,System.Int32)
+
+# p/invoke declaration
++SC-M: System.IntPtr Mono.NativeMethods::moon_windowing_system_show_save_file_dialog_(System.IntPtr,System.String,System.String,System.Int32)
+
+# p/invoke declaration
+SC-M: System.IntPtr Mono.NativeMethods::moonlight_object_to_npobject(System.IntPtr)
# p/invoke declaration
@@ -848,9 +863,6 @@
+SC-M: System.IntPtr Mono.NativeMethods::object_key_frame_new()
# p/invoke declaration
-+SC-M: System.IntPtr Mono.NativeMethods::open_file_dialog_show(System.String,System.Boolean,System.String,System.Int32)
-
-# p/invoke declaration
+SC-M: System.IntPtr Mono.NativeMethods::out_of_browser_settings_new()
# p/invoke declaration
@@ -1010,7 +1022,7 @@
+SC-M: System.IntPtr Mono.NativeMethods::run_new()
# p/invoke declaration
-+SC-M: System.IntPtr Mono.NativeMethods::save_file_dialog_show_(System.String,System.String,System.Int32)
++SC-M: System.IntPtr Mono.NativeMethods::runtime_get_windowing_system()
# p/invoke declaration
+SC-M: System.IntPtr Mono.NativeMethods::scale_transform_new()
Modified: trunk/moon/configure.ac
===================================================================
--- trunk/moon/configure.ac 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/configure.ac 2010-01-06 23:53:29 UTC (rev 149148)
@@ -70,6 +70,8 @@
MOONLIGHT_CHECK_UNWIND
+MOONLIGHT_CHECK_PAL
+
dnl
dnl The silverlight TargetRuntime versions we claim to support
@@ -116,7 +118,7 @@
AC_SUBST(MOON_EXTRA_CFLAGS)
AC_SUBST(MOON_EXTRA_LIBS)
-MOON_PROG_CFLAGS="$GTK_CFLAGS $ALSA_CFLAGS $FFMPEG_CFLAGS $PULSEAUDIO_CFLAGS $MONO_CFLAGS -I\$(top_srcdir)/src/"
+MOON_PROG_CFLAGS="$GTK_CFLAGS $ALSA_CFLAGS $FFMPEG_CFLAGS $PULSEAUDIO_CFLAGS $MONO_CFLAGS -I\$(top_srcdir)/src/ -I\$(top_srcdir)/src/pal"
MOON_PROG_LIBS="$GTK_LIBS $FFMPEG_LIBS $UNWIND_LIBS \$(top_builddir)/src/libmoon.la"
AC_SUBST(MOON_PROG_CFLAGS)
AC_SUBST(MOON_PROG_LIBS)
@@ -285,6 +287,13 @@
EOF
fi
+# PAL support
+cat <<EOF
+
+ Platform abstraction layer:
+ Backend: $pal_backend
+EOF
+
# blank line
cat <<EOF
Modified: trunk/moon/gtk/Moonlight.Gtk/MoonlightHost.cs
===================================================================
--- trunk/moon/gtk/Moonlight.Gtk/MoonlightHost.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/gtk/Moonlight.Gtk/MoonlightHost.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -47,6 +47,7 @@
{
private IntPtr surface;
private IntPtr window;
+ private IntPtr windowingSystem;
/// <summary>
/// Public constructor
@@ -67,9 +68,11 @@
public MoonlightHost ()
{
Mono.Xaml.XamlLoader.AllowMultipleSurfacesPerDomain = true;
- window = NativeMethods.moon_window_gtk_new (false, 0, 0, IntPtr.Zero, IntPtr.Zero);
+
+ windowingSystem = NativeMethods.runtime_get_windowing_system ();
+ window = NativeMethods.moon_windowing_system_create_window (windowingSystem, false, 0, 0, IntPtr.Zero, IntPtr.Zero);
surface = NativeMethods.surface_new (window);
- Raw = NativeMethods.moon_window_gtk_get_native_widget (window);
+ Raw = NativeMethods.moon_window_get_platform_window (window);
SizeAllocated += OnSizeAllocated;
}
@@ -199,7 +202,7 @@
#endregion
- private void OnSizeAllocated (object o, SizeAllocatedArgs args)
+ private void OnSizeAllocated (object o, SizeAllocatedArgs args)
{
NativeMethods.surface_resize (surface, Allocation.Width, Allocation.Height);
}
Added: trunk/moon/m4/pal.m4
===================================================================
--- trunk/moon/m4/pal.m4 (rev 0)
+++ trunk/moon/m4/pal.m4 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,9 @@
+AC_DEFUN([MOONLIGHT_CHECK_PAL],
+[
+ dnl
+ dnl eventually we need to replace all this with platform and/or --enable checks, but for now...
+ dnl
+
+ AC_DEFINE([PAL_GTK],1,[Hack in support for the pal gtk cpp symbol so we can start using it.])
+ pal_backend="gtk (hacked)"
+])
\ No newline at end of file
Modified: trunk/moon/perf/perf-suite-tool/perf-suite-tool.cpp
===================================================================
--- trunk/moon/perf/perf-suite-tool/perf-suite-tool.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/perf/perf-suite-tool/perf-suite-tool.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -36,6 +36,11 @@
#include <stdlib.h>
#include <unistd.h>
#include <gtk/gtk.h>
+#define Visual _XxVisual
+#define Region _XxRegion
+#include "gdk/gdkx.h"
+#undef Visual
+#undef Region
#include <gdk/gdkkeysyms.h>
#include <signal.h>
#include <sys/syscall.h>
Modified: trunk/moon/plugin/Makefile.am
===================================================================
--- trunk/moon/plugin/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -9,6 +9,7 @@
INCLUDES = \
-I$(top_srcdir)/src \
+ -I$(top_srcdir)/src/pal \
-I$(top_srcdir)/src/zip \
-I/usr/include/X11 \
$(PLUGIN_CFLAGS) \
@@ -62,10 +63,11 @@
plugin-debug.h \
plugin-utils.cpp \
plugin-spinner.h \
- windowless.cpp \
- windowless.h
+ ../src/pal/gtk/windowless-gtk.cpp \
+ ../src/pal/gtk/windowless-gtk.h
+
#--- libmoonpluginxpi ----------------------
libmoonpluginxpi_la_LDFLAGS = $(libmoonplugin_la_LDFLAGS) -rpath /nowhere
Modified: trunk/moon/plugin/cbinding.h
===================================================================
--- trunk/moon/plugin/cbinding.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/cbinding.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -8,6 +8,7 @@
#include <glib.h>
#include <cairo.h>
+#include "pal.h"
#include "enums.h"
class Accessibility;
@@ -516,11 +517,22 @@
class MmsPlaylistEntry;
class MmsSecondDownloader;
class MmsSource;
+class MoonButtonEvent;
+class MoonClipboard;
+class MoonCrossingEvent;
class MoonError;
+class MoonEvent;
+class MoonFocusEvent;
+class MoonIMContext;
+class MoonKeyEvent;
class MoonlightConfiguration;
+class MoonMotionEvent;
+class MoonMouseEvent;
+class MoonPixbuf;
+class MoonPixbufLoader;
+class MoonScrollWheelEvent;
class MoonWindow;
-class MoonWindowGtk;
-class MoonWindowless;
+class MoonWindowingSystem;
class MouseButtonEventArgs;
class MouseEventArgs;
class MouseWheelEventArgs;
Modified: trunk/moon/plugin/firefox/ff2/Makefile.am
===================================================================
--- trunk/moon/plugin/firefox/ff2/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/firefox/ff2/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -2,6 +2,7 @@
INCLUDES = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/asf \
+ -I$(top_srcdir)/src/pal \
-I$(top_srcdir)/plugin \
-I$(top_srcdir)/plugin/moz-sdk \
-I/usr/include/X11 \
Modified: trunk/moon/plugin/firefox/ff3/Makefile.am
===================================================================
--- trunk/moon/plugin/firefox/ff3/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/firefox/ff3/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -2,6 +2,7 @@
INCLUDES = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/asf \
+ -I$(top_srcdir)/src/pal \
-I$(top_srcdir)/plugin \
-I$(top_srcdir)/plugin/moz-sdk \
-I/usr/include/X11 \
Modified: trunk/moon/plugin/moonlight.h
===================================================================
--- trunk/moon/plugin/moonlight.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/moonlight.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -30,13 +30,12 @@
#undef Visual
#include <glib.h>
+#include <gtk/gtkwidget.h>
#if GLIB_SIZEOF_VOID_P == 8
#define GDK_NATIVE_WINDOW_POINTER 1
#endif
-#include <gtk/gtk.h>
-
#include "libmoon.h"
#include "silverlight-versions.h"
Modified: trunk/moon/plugin/plugin-class.cpp
===================================================================
--- trunk/moon/plugin/plugin-class.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/plugin-class.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1498,15 +1498,15 @@
MoonlightMouseEventArgsObject::GetProperty (int id, NPIdentifier name, NPVariant *result)
{
MouseEventArgs *event_args = GetMouseEventArgs ();
- int state = event_args->GetState ();
+ MoonModifier modifiers = event_args->GetEvent()->GetModifiers ();
switch (id) {
case MoonId_Shift:
- BOOLEAN_TO_NPVARIANT ((state & GDK_SHIFT_MASK) != 0, *result);
+ BOOLEAN_TO_NPVARIANT ((modifiers & MoonModifier_Shift) != 0, *result);
return true;
case MoonId_Ctrl:
- BOOLEAN_TO_NPVARIANT ((state & GDK_CONTROL_MASK) != 0, *result);
+ BOOLEAN_TO_NPVARIANT ((modifiers & MoonModifier_Control) != 0, *result);
return true;
case MoonId_Handled:
@@ -1674,14 +1674,15 @@
MoonlightKeyEventArgsObject::GetProperty (int id, NPIdentifier name, NPVariant *result)
{
KeyEventArgs *args = GetKeyEventArgs ();
+ MoonModifier modifiers = args->GetEvent()->GetModifiers();
switch (id) {
case MoonId_Shift:
- BOOLEAN_TO_NPVARIANT ((args->GetModifiers () & GDK_SHIFT_MASK) != 0, *result);
+ BOOLEAN_TO_NPVARIANT ((modifiers & MoonModifier_Shift) != 0, *result);
return true;
case MoonId_Ctrl:
- BOOLEAN_TO_NPVARIANT ((args->GetModifiers () & GDK_CONTROL_MASK) != 0, *result);
+ BOOLEAN_TO_NPVARIANT ((modifiers & MoonModifier_Control) != 0, *result);
return true;
case MoonId_Handled:
@@ -1844,7 +1845,7 @@
MoonlightObject::ClearEventProxies ()
{
g_hash_table_foreach (event_listener_proxies, detach_xaml_proxy, NULL);
-#if GTK_CHECK_VERSION(2,12,0)
+#if GLIB_CHECK_VERSION(2,12,0)
g_hash_table_remove_all (event_listener_proxies);
#else
g_hash_table_destroy (event_listener_proxies);
Modified: trunk/moon/plugin/plugin-debug.cpp
===================================================================
--- trunk/moon/plugin/plugin-debug.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/plugin-debug.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -12,7 +12,7 @@
#include <config.h>
-#include <gtk/gtkmessagedialog.h>
+#include <gtk/gtk.h>
#include <sys/types.h>
#include <sys/stat.h>
Modified: trunk/moon/plugin/plugin.cpp
===================================================================
--- trunk/moon/plugin/plugin.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/plugin.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -28,19 +28,13 @@
#include "plugin-downloader.h"
#include "npstream-request.h"
#include "xap.h"
-#include "windowless.h"
-#include "window-gtk.h"
+#include "window.h"
#include "unzip.h"
#include "deployment.h"
#include "uri.h"
#include "timemanager.h"
+#include "pal/gtk/windowless-gtk.h"
-#define Visual _XxVisual
-#define Region _XxRegion
-#include "gdk/gdkx.h"
-#undef Visual
-#undef Region
-
#ifdef DEBUG
#define d(x) x
#else
@@ -394,6 +388,14 @@
gtk_widget_show_all (dialog);
}
+#if PAL_GTK
+static MoonWindow *
+create_gtk_windowless (int width, int height, PluginInstance *forPlugin)
+{
+ return new MoonWindowlessGtk (width, height, forPlugin);
+}
+#endif
+
PluginInstance::PluginInstance (NPP instance, guint16 mode)
{
refcount = 1;
@@ -456,6 +458,17 @@
cleanup_pointers = NULL;
+ if (plugin_instances == NULL) {
+ // first plugin is initialized
+
+ // FIXME add some ifdefs + runtime checks here
+#if PAL_GTK
+ runtime_get_windowing_system()->SetWindowlessCtor (create_gtk_windowless);
+#else
+#error "no PAL backend"
+#endif
+ }
+
plugin_instances = g_slist_append (plugin_instances, instance);
/* back pointer to us */
@@ -1064,11 +1077,11 @@
if (moon_window == NULL) {
if (windowless) {
- moon_window = new MoonWindowless (window->width, window->height, this);
+ moon_window = runtime_get_windowing_system()->CreateWindowless (window->width, window->height, this);
moon_window->SetTransparent (true);
}
else {
- moon_window = new MoonWindowGtk (false, window->width, window->height);
+ moon_window = runtime_get_windowing_system()->CreateWindow (false, window->width, window->height);
}
created = true;
} else {
@@ -1135,7 +1148,7 @@
g_signal_connect (G_OBJECT(container), "button-press-event", G_CALLBACK (PluginInstance::plugin_button_press_callback), this);
- gtk_container_add (GTK_CONTAINER (container), ((MoonWindowGtk*)moon_window)->GetWidget());
+ gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (moon_window->GetPlatformWindow()));
gtk_widget_show_all (container);
connected_to_container = true;
}
@@ -1989,8 +2002,7 @@
return 0;
}
-
- return ((MoonWindowless*)moon_window)->HandleEvent ((XEvent*)event);
+ return moon_window->HandleEvent (event);
}
void
Deleted: trunk/moon/plugin/windowless.cpp
===================================================================
--- trunk/moon/plugin/windowless.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/windowless.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,341 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * windowless.cpp: Windowsless Surface subclass
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2007 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#include <config.h>
-
-#include "windowless.h"
-
-#define Visual _XxVisual
-#define Region _XxRegion
-#include <gdk/gdkx.h>
-#undef Visual
-#undef Region
-
-#ifdef DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-MoonWindowless::MoonWindowless (int width, int height, PluginInstance *plugin)
- : MoonWindow (width, height)
-{
- this->plugin = plugin;
-
- UpdateWindowInfo ();
-}
-
-void
-MoonWindowless::UpdateWindowInfo ()
-{
- // It appears opera doesn't do a good job of keeping the NPWindow members valid
- // between SetWindow calls so we have to work around this by copying the members
- // we need. This is really ugly.
-
- NPWindow *window = plugin->GetWindow();
- NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct*)window->ws_info;
- visualid = ws_info->visual ? visualid = ws_info->visual->visualid : 0;
- x = window->x;
- y = window->y;
-}
-
-void
-MoonWindowless::Resize (int width, int height)
-{
- bool emit_resize = false;
-
- UpdateWindowInfo ();
-
- if (this->width != width || this->height != height) {
- this->width = width;
- this->height = height;
-
- emit_resize = true;
- }
-
- surface->HandleUIWindowAllocation (emit_resize);
-}
-
-void
-MoonWindowless::SetCursor (MouseCursor cursor)
-{
-#if (NP_VERSION_MINOR >= NPVERS_HAS_WINDOWLESS_CURSORS)
- NPCursor npcursor;
- switch (cursor) {
- case MouseCursorDefault:
- npcursor = NPCursorAuto;
- break;
- case MouseCursorArrow:
- npcursor = NPCursorPointer;
- break;
- case MouseCursorWait:
- npcursor = NPCursorWait;
- break;
- case MouseCursorIBeam:
- npcursor = NPCursorText;
- break;
- case MouseCursorStylus:
- npcursor = NPCursorPointer; // XXX ugh...
- break;
- case MouseCursorEraser:
- npcursor = NPCursorPointer; // XXX ugh...
- break;
- case MouseCursorNone:
- // Silverlight display no cursor if the enumeration value is invalid (e.g. -1)
- default:
- npcursor = NPCursorNone;
- break;
- }
-
- NPN_SetValue (plugin->GetInstance(), NPPVcursor, (void*)npcursor);
-#endif
-}
-
-void
-MoonWindowless::Invalidate (Rect r)
-{
- NPRect nprect;
-
- // Mozilla gets seriously confused about invalidations
- // outside the windowless bounds.
- r = r.Intersection (Rect (0, 0, GetWidth(), GetHeight())).RoundOut ();
-
- nprect.left = (uint16_t)r.x;
- nprect.top = (uint16_t)r.y;
- nprect.right = (uint16_t)(r.x + r.width);
- nprect.bottom = (uint16_t)(r.y + r.height);
-
- NPN_InvalidateRect (plugin->GetInstance(), &nprect);
-}
-
-void
-MoonWindowless::ProcessUpdates ()
-{
- //NPN_ForceRedraw (plugin->GetInstance());
-}
-
-gboolean
-MoonWindowless::HandleEvent (XEvent *event)
-{
- XEvent *xev = (XEvent*)event;
- gboolean handled = FALSE;
-
- SetCurrentDeployment ();
-
- switch (xev->type) {
- case GraphicsExpose: {
- GdkDrawable *drawable = gdk_pixmap_foreign_new ((GdkNativeWindow)xev->xgraphicsexpose.drawable);
- if (!drawable) {
- drawable = gdk_window_foreign_new ((GdkNativeWindow)xev->xgraphicsexpose.drawable);
- }
-
- if (drawable) {
- GdkVisual *visual = gdkx_visual_get (visualid);
-
- if (visual) {
- GdkEventExpose expose;
-
- expose.type = GDK_EXPOSE;
- expose.window = NULL;
- expose.send_event = FALSE;
- expose.area = Rect (xev->xgraphicsexpose.x,
- xev->xgraphicsexpose.y,
- xev->xgraphicsexpose.width,
- xev->xgraphicsexpose.height).ToGdkRectangle ();
- /* XXX ugh */
- expose.region = gdk_region_rectangle (&expose.area);
-
- expose.area.x = expose.area.y = 0;
-
- surface->PaintToDrawable (drawable, visual, &expose, x, y, GetTransparent(), false);
- handled = TRUE;
-
- gdk_region_destroy (expose.region);
- } else {
- d(printf ("no gdk visual\n"));
- }
-
- g_object_unref (drawable);
- } else {
- d(printf ("no gdk drawable\n"));
- }
- break;
- }
- case MotionNotify: {
- GdkEventMotion motion;
-
- motion.type = GDK_MOTION_NOTIFY;
- motion.window = NULL;
- motion.send_event = xev->xmotion.send_event;
- motion.x = xev->xmotion.x;
- motion.y = xev->xmotion.y;
- motion.axes = NULL;
- motion.state = xev->xmotion.state;
- motion.is_hint = xev->xmotion.is_hint;
- motion.device = NULL; // XXX
- motion.x_root = xev->xmotion.x_root;
- motion.y_root = xev->xmotion.y_root;
-
- handled = surface->HandleUIMotion (&motion);
- break;
- }
- case ButtonPress:
- case ButtonRelease: {
- GdkEventButton button;
-
- button.type = xev->type == ButtonPress ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
- button.window = NULL;
- button.send_event = xev->xbutton.send_event;
- button.time = xev->xbutton.time;
- button.x = xev->xbutton.x;
- button.y = xev->xbutton.y;
- button.x_root = xev->xbutton.x_root;
- button.y_root = xev->xbutton.y_root;
- button.state = xev->xbutton.state;
- button.button = xev->xbutton.button;
- button.axes = NULL;
-
- if (xev->type == ButtonPress)
- handled = PluginInstance::plugin_button_press_callback (NULL, &button, plugin);
- if (!handled) {
- if (xev->type == ButtonPress)
- handled = surface->HandleUIButtonPress (&button);
- else
- handled = surface->HandleUIButtonRelease (&button);
- }
- break;
- }
- case KeyPress:
- case KeyRelease: {
- // make sure everything is initialized correctly (structure members vary with gdk version)
- GdkEventKey *key = (GdkEventKey*) gdk_event_new (xev->type == KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
- // gtk_im_context_xim_filter_keypress will dereference the NULL window leading to a SEGSIGV
- key->window = GetGdkWindow ();
- key->send_event = xev->xkey.send_event;
- key->time = xev->xkey.time;
- key->state = xev->xkey.state;
- key->hardware_keycode = xev->xkey.keycode;
-
- gint effective_group;
-
- gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
- xev->xkey.keycode,
- (GdkModifierType)xev->xkey.state, // XXX
- 0, // XXX
- &key->keyval,
- &effective_group,
- NULL,
- NULL);
-
- key->group = (guint8)effective_group;
-
- if (xev->type == KeyPress)
- handled = surface->HandleUIKeyPress (key);
- else
- handled = surface->HandleUIKeyRelease (key);
-
- gdk_event_free ((GdkEvent*) key);
- break;
- }
- case EnterNotify:
- case LeaveNotify: {
- GdkEventCrossing crossing;
-
- crossing.type = xev->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
- crossing.window = crossing.subwindow = NULL;
- crossing.send_event = xev->xcrossing.send_event;
- crossing.time = xev->xcrossing.time;
- crossing.x = xev->xcrossing.x;
- crossing.y = xev->xcrossing.y;
- crossing.x_root = xev->xcrossing.x_root;
- crossing.y_root = xev->xcrossing.y_root;
- // crossing.mode = (GdkCrossingMode)xev->xcrossing.mode; // XXX
- crossing.mode = GDK_CROSSING_NORMAL;
- crossing.detail = (GdkNotifyType)xev->xcrossing.detail; // XXX
- crossing.focus = xev->xcrossing.focus;
- crossing.state = xev->xcrossing.state;
-
- surface->HandleUICrossing (&crossing);
- break;
- }
- case FocusIn: {
- surface->HandleUIFocusIn (NULL);
- break;
- }
-
- case FocusOut: {
- surface->HandleUIFocusOut (NULL);
- break;
- }
- default:
- d(printf ("Unhandled Xlib event %d\n", xev->type));
- break;
- }
-
- return handled;
-}
-
-void
-MoonWindowless::Show ()
-{
- // nothing needed here
-}
-
-void
-MoonWindowless::Hide ()
-{
- // nothing needed here
-}
-
-void
-MoonWindowless::EnableEvents (bool first)
-{
- // nothing needed here, NPAPI pushes events through
- // HandleEvent.
-}
-
-void
-MoonWindowless::DisableEvents ()
-{
- // nothing needed here, NPAPI pushes events through
- // HandleEvent.
-}
-
-void
-MoonWindowless::GrabFocus ()
-{
- // we can't grab focus - the browser handles that.
-}
-
-bool
-MoonWindowless::HasFocus ()
-{
- // XXX maybe we should track the focus in/out events?
- return false;
-}
-
-void
-MoonWindowless::SetSurface (Surface *s)
-{
- MoonWindow::SetSurface (s);
- s->HandleUIWindowAvailable ();
-}
-
-GdkWindow*
-MoonWindowless::GetGdkWindow ()
-{
- GdkNativeWindow window;
- NPN_GetValue (plugin->GetInstance(), NPNVnetscapeWindow, (void*)&window);
- GdkWindow *gdk = gdk_window_foreign_new (window);
- return gdk;
-}
Deleted: trunk/moon/plugin/windowless.h
===================================================================
--- trunk/moon/plugin/windowless.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/plugin/windowless.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * windowless.h: windowless plugin's MoonWindow implementation
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2008 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#ifndef __MOON_WINDOWLESS__
-#define __MOON_WINDOWLESS__
-
-#include "moonlight.h"
-#include "runtime.h"
-#include "plugin.h"
-
-class MoonWindowless : public MoonWindow {
- PluginInstance *plugin;
- VisualID visualid;
- int x;
- int y;
-
- void UpdateWindowInfo ();
-
- public:
- MoonWindowless (int width, int height, PluginInstance *plugin);
-
- virtual void Resize (int width, int height);
-
- virtual void SetCursor (MouseCursor cursor);
- virtual void Invalidate (Rect r);
- virtual void ProcessUpdates ();
-
- virtual gboolean HandleEvent (XEvent *event);
-
- virtual void Show ();
- virtual void Hide ();
-
- virtual void EnableEvents (bool first);
- virtual void DisableEvents ();
-
- virtual void GrabFocus ();
- virtual bool HasFocus ();
-
- virtual void SetSurface (Surface *s);
-
- virtual bool IsFullScreen () { return false; }
-
- virtual GdkWindow* GetGdkWindow ();
-};
-
-#endif /* __MOON_WINDOWLESS__ */
-
Modified: trunk/moon/src/Makefile.am
===================================================================
--- trunk/moon/src/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -4,7 +4,7 @@
noinst_LTLIBRARIES = libmoonxpi.la
noinst_SCRIPTS = xaml-to-header.exe
-INCLUDES = $(MOON_CFLAGS) -Wall -DUSE_OPT_RGB24=1 -DG_LOG_DOMAIN=\"Moonlight\" -I$(top_srcdir)/plugin
+INCLUDES = $(MOON_CFLAGS) -Wall -DUSE_OPT_RGB24=1 -DG_LOG_DOMAIN=\"Moonlight\" -I$(top_srcdir)/plugin -I$(srcdir)/pal -I$(srcdir)/pal/gtk
libmoon_include_headers = \
animation.h \
@@ -61,7 +61,6 @@
media.h \
mediaelement.h \
mediaplayer.h \
- messagebox.h \
mms-downloader.h \
moon-curves.h \
moonlightconfiguration.h\
@@ -72,6 +71,13 @@
mutex.h \
namescope.h \
openfile.h \
+ pal/pal.h \
+ pal/window.h \
+ pal/gtk/clipboard-gtk.h \
+ pal/gtk/im-gtk.h \
+ pal/gtk/pal-gtk.h \
+ pal/gtk/pixbuf-gtk.h \
+ pal/gtk/window-gtk.h \
panel.h \
pipeline.h \
pipeline-asf.h \
@@ -113,8 +119,6 @@
utils.h \
validators.h \
value.h \
- window-gtk.h \
- window.h \
writeablebitmap.h \
xaml.h \
xap.h \
@@ -169,7 +173,6 @@
media.cpp \
mediaelement.cpp \
mediaplayer.cpp \
- messagebox.cpp \
mms-downloader.cpp \
moon-curves.c \
moonlightconfiguration.cpp \
@@ -179,6 +182,13 @@
multiscalesubimage.cpp \
namescope.cpp \
openfile.cpp \
+ pal/pal.cpp \
+ pal/window.cpp \
+ pal/gtk/clipboard-gtk.cpp \
+ pal/gtk/im-gtk.cpp \
+ pal/gtk/pal-gtk.cpp \
+ pal/gtk/pixbuf-gtk.cpp \
+ pal/gtk/window-gtk.cpp \
panel.cpp \
pipeline-asf.cpp \
pipeline.cpp \
@@ -216,8 +226,6 @@
utils.cpp \
validators.cpp \
value.cpp \
- window.cpp \
- window-gtk.cpp \
writeablebitmap.cpp \
xaml.cpp \
xap.cpp \
Modified: trunk/moon/src/bitmapimage.cpp
===================================================================
--- trunk/moon/src/bitmapimage.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/bitmapimage.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -66,18 +66,18 @@
// Expands RGB to ARGB allocating new buffer for it.
//
static gpointer
-expand_rgb_to_argb (GdkPixbuf *pixbuf)
+expand_rgb_to_argb (MoonPixbuf *pixbuf)
{
- guchar *pb_pixels = gdk_pixbuf_get_pixels (pixbuf);
+ guchar *pb_pixels = pixbuf->GetPixels ();
guchar *p;
- int w = gdk_pixbuf_get_width (pixbuf);
- int h = gdk_pixbuf_get_height (pixbuf);
+ int w = pixbuf->GetWidth ();
+ int h = pixbuf->GetHeight ();
int stride = w * 4;
guchar *data = (guchar *) g_malloc (stride * h);
guchar *out;
for (int y = 0; y < h; y ++) {
- p = pb_pixels + y * gdk_pixbuf_get_rowstride (pixbuf);
+ p = pb_pixels + y * pixbuf->GetRowStride ();
out = data + y * (stride);
for (int x = 0; x < w; x ++) {
guchar r, g, b;
@@ -97,18 +97,18 @@
// Converts RGBA unmultiplied alpha to ARGB pre-multiplied alpha.
//
static gpointer
-premultiply_rgba (GdkPixbuf *pixbuf)
+premultiply_rgba (MoonPixbuf *pixbuf)
{
- guchar *pb_pixels = gdk_pixbuf_get_pixels (pixbuf);
+ guchar *pb_pixels = pixbuf->GetPixels ();
guchar *p;
- int w = gdk_pixbuf_get_width (pixbuf);
- int h = gdk_pixbuf_get_height (pixbuf);
+ int w = pixbuf->GetWidth ();
+ int h = pixbuf->GetHeight ();
int stride = w * 4;
guchar *data = (guchar *) g_malloc (stride * h);
guchar *out;
for (int y = 0; y < h; y ++) {
- p = pb_pixels + y * gdk_pixbuf_get_rowstride (pixbuf);
+ p = pb_pixels + y * pixbuf->GetRowStride ();
out = data + y * (stride);
for (int x = 0; x < w; x ++) {
guchar r, g, b, a;
@@ -141,7 +141,7 @@
SetObjectType (Type::BITMAPIMAGE);
downloader = NULL;
loader = NULL;
- gerror = NULL;
+ moon_error = NULL;
part_name = NULL;
get_res_aborter = NULL;
policy = MediaPolicy;
@@ -334,8 +334,6 @@
void
BitmapImage::DownloaderComplete ()
{
- MoonError moon_error;
-
if (downloader)
CleanupDownloader ();
@@ -348,7 +346,7 @@
guchar *buffer = (guchar *)downloader->GetBuffer ();
if (buffer == NULL) {
- MoonError::FillIn (&moon_error, MoonError::EXCEPTION, 4001, "downloader buffer was NULL");
+ moon_error = new MoonError (MoonError::EXCEPTION, 4001, "downloader buffer was NULL");
goto failed;
}
@@ -360,7 +358,7 @@
int fd;
if ((fd = g_open (filename, O_RDONLY)) == -1) {
- MoonError::FillIn (&moon_error, MoonError::EXCEPTION, 4001, "failed to open file");
+ moon_error = new MoonError (MoonError::EXCEPTION, 4001, "failed to open file");
goto failed;
}
@@ -374,14 +372,12 @@
PixbufWrite (b, offset, n);
offset += n;
- } while (n > 0 && !gerror);
+ } while (n > 0 && !moon_error);
close (fd);
- if (gerror) {
- MoonError::FillIn (&moon_error, MoonError::EXCEPTION, 4001, gerror->message);
+ if (moon_error)
goto failed;
- }
}
}
@@ -398,44 +394,40 @@
downloader = NULL;
if (loader)
- gdk_pixbuf_loader_close (loader, NULL);
+ loader->Close ();
CleanupLoader ();
- Emit (ImageFailedEvent, new ImageErrorEventArgs (moon_error));
+ Emit (ImageFailedEvent, new ImageErrorEventArgs (*moon_error));
}
void
BitmapImage::PixmapComplete ()
{
- MoonError moon_error;
-
SetProgress (1.0);
if (!loader) goto failed;
- gdk_pixbuf_loader_close (loader, gerror == NULL ? &gerror : NULL);
+ loader->Close (moon_error == NULL ? &moon_error : NULL);
- if (gerror) {
- MoonError::FillIn (&moon_error, MoonError::EXCEPTION, 4001, gerror->message);
+ if (moon_error)
goto failed;
- }
{
- GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+ MoonPixbuf *pixbuf = loader->GetPixbuf ();
if (pixbuf == NULL) {
- MoonError::FillIn (&moon_error, MoonError::EXCEPTION, 4001, "failed to create image data");
+ moon_error = new MoonError (MoonError::EXCEPTION, 4001, "failed to create image data");
goto failed;
}
- SetPixelWidth (gdk_pixbuf_get_width (pixbuf));
- SetPixelHeight (gdk_pixbuf_get_height (pixbuf));
+ SetPixelWidth (pixbuf->GetWidth ());
+ SetPixelHeight (pixbuf->GetHeight ());
// PixelFormat has been dropped and only Pbgra32 is supported
// http://blogs.msdn.com/silverlight_sdk/archive/2009/07/01/breaking-changes-document-errata-silverlight-3.aspx
// not clear if '3' channel is still supported (converted to 4) in SL3
- if (gdk_pixbuf_get_n_channels (pixbuf) == 4) {
+ if (pixbuf->GetNumChannels () == 4) {
SetBitmapData (premultiply_rgba (pixbuf));
} else {
SetBitmapData (expand_rgb_to_argb (pixbuf));
@@ -443,7 +435,7 @@
Invalidate ();
- g_object_unref (loader);
+ delete loader;
loader = NULL;
Emit (ImageOpenedEvent, new RoutedEventArgs ());
@@ -454,7 +446,7 @@
failed:
CleanupLoader ();
- Emit (ImageFailedEvent, new ImageErrorEventArgs (moon_error));
+ Emit (ImageFailedEvent, new ImageErrorEventArgs (*moon_error));
}
void
@@ -474,9 +466,9 @@
g_object_unref (loader);
loader = NULL;
}
- if (gerror) {
- g_error_free (gerror);
- gerror = NULL;
+ if (moon_error) {
+ delete moon_error;
+ moon_error = NULL;
}
}
@@ -486,17 +478,17 @@
if (!(moonlight_flags & RUNTIME_INIT_ALL_IMAGE_FORMATS)) {
// 89 50 4E 47 == png magic
if (buffer[0] == 0x89)
- loader = gdk_pixbuf_loader_new_with_type ("png", NULL);
+ loader = runtime_get_windowing_system()->CreatePixbufLoader ("png");
// ff d8 ff e0 == jfif magic
else if (buffer[0] == 0xff)
- loader = gdk_pixbuf_loader_new_with_type ("jpeg", NULL);
+ loader = runtime_get_windowing_system()->CreatePixbufLoader ("jpeg");
else {
Abort ();
Emit (ImageFailedEvent, new ImageErrorEventArgs (MoonError (MoonError::EXCEPTION, 4001, "unsupported image type")));
}
} else {
- loader = gdk_pixbuf_loader_new ();
+ loader = runtime_get_windowing_system()->CreatePixbufLoader (NULL);
}
}
@@ -507,9 +499,8 @@
if (loader == NULL && offset == 0)
CreateLoader ((unsigned char *)buffer);
- if (loader != NULL && gerror == NULL) {
- gdk_pixbuf_loader_write (GDK_PIXBUF_LOADER (loader), (const guchar *)buffer, n, &gerror);
- }
+ if (loader != NULL && moon_error == NULL)
+ loader->Write ((const guchar *)buffer, n, &moon_error);
}
void
Modified: trunk/moon/src/bitmapimage.h
===================================================================
--- trunk/moon/src/bitmapimage.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/bitmapimage.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -14,8 +14,7 @@
#ifndef __BITMAPIMAGE_H__
#define __BITMAPIMAGE_H__
-#include <gdk/gdkpixbuf.h>
-
+#include "pal.h"
#include "utils.h"
#include "dependencyobject.h"
#include "downloader.h"
@@ -25,8 +24,8 @@
class BitmapImage : public BitmapSource {
private:
Downloader *downloader;
- GdkPixbufLoader *loader;
- GError *gerror;
+ MoonPixbufLoader *loader;
+ MoonError *moon_error;
char *part_name;
Cancellable *get_res_aborter;
DownloaderAccessPolicy policy;
Modified: trunk/moon/src/canvas.cpp
===================================================================
--- trunk/moon/src/canvas.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/canvas.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -20,6 +20,7 @@
#include "runtime.h"
#include "namescope.h"
#include "collection.h"
+#include "window.h"
#include "deployment.h"
Canvas::Canvas ()
Modified: trunk/moon/src/cbinding.cpp
===================================================================
--- trunk/moon/src/cbinding.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/cbinding.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -39,6 +39,7 @@
#include "multiscaleimage.h"
#include "multiscalesubimage.h"
#include "namescope.h"
+#include "pal.h"
#include "panel.h"
#include "pipeline.h"
#include "popup.h"
@@ -63,7 +64,6 @@
#include "uri.h"
#include "usercontrol.h"
#include "window.h"
-#include "window-gtk.h"
#include "writeablebitmap.h"
#include "xaml.h"
#include "xap.h"
@@ -3312,6 +3312,17 @@
/**
* MoonWindow
**/
+gpointer
+moon_window_get_platform_window (MoonWindow *instance)
+{
+ if (instance == NULL)
+ // Need to find a proper way to get the default value for the specified type and return that if instance is NULL.
+ return (gpointer) 0;
+
+ return instance->GetPlatformWindow ();
+}
+
+
bool
moon_window_get_transparent (MoonWindow *instance)
{
@@ -3333,25 +3344,49 @@
/**
- * MoonWindowGtk
+ * MoonWindowingSystem
**/
-void *
-moon_window_gtk_get_native_widget (MoonWindowGtk *instance)
+MoonWindow *
+moon_windowing_system_create_window (MoonWindowingSystem *instance, bool fullscreen, int width, int height, MoonWindow *parentWindow, Surface *surface)
{
if (instance == NULL)
return NULL;
- return instance->GetNativeWidget ();
+ return instance->CreateWindow (fullscreen, width, height, parentWindow, surface);
}
-MoonWindowGtk *
-moon_window_gtk_new (bool fullscreen, int w, int h, MoonWindow *parent, Surface *surface)
+int
+moon_windowing_system_show_message_box (MoonWindowingSystem *instance, const char *caption, const char *text, int buttons)
{
- return new MoonWindowGtk (fullscreen, w, h, parent, surface);
+ if (instance == NULL)
+ // Need to find a proper way to get the default value for the specified type and return that if instance is NULL.
+ return (int) 0;
+
+ return instance->ShowMessageBox (caption, text, buttons);
}
+gchar* *
+moon_windowing_system_show_open_file_dialog (MoonWindowingSystem *instance, const char *title, bool multsel, const char *filter, int idx)
+{
+ if (instance == NULL)
+ return NULL;
+
+ return instance->ShowOpenFileDialog (title, multsel, filter, idx);
+}
+
+
+char *
+moon_windowing_system_show_save_file_dialog (MoonWindowingSystem *instance, const char *title, const char *filter, int idx)
+{
+ if (instance == NULL)
+ return NULL;
+
+ return instance->ShowSaveFileDialog (title, filter, idx);
+}
+
+
/**
* MouseButtonEventArgs
**/
Modified: trunk/moon/src/cbinding.h
===================================================================
--- trunk/moon/src/cbinding.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/cbinding.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -8,6 +8,7 @@
#include <glib.h>
#include <cairo.h>
+#include "pal.h"
#include "enums.h"
class Accessibility;
@@ -516,11 +517,22 @@
class MmsPlaylistEntry;
class MmsSecondDownloader;
class MmsSource;
+class MoonButtonEvent;
+class MoonClipboard;
+class MoonCrossingEvent;
class MoonError;
+class MoonEvent;
+class MoonFocusEvent;
+class MoonIMContext;
+class MoonKeyEvent;
class MoonlightConfiguration;
+class MoonMotionEvent;
+class MoonMouseEvent;
+class MoonPixbuf;
+class MoonPixbufLoader;
+class MoonScrollWheelEvent;
class MoonWindow;
-class MoonWindowGtk;
-class MoonWindowless;
+class MoonWindowingSystem;
class MouseButtonEventArgs;
class MouseEventArgs;
class MouseWheelEventArgs;
@@ -2103,20 +2115,29 @@
* MoonWindow
**/
/* @GeneratePInvoke */
+gpointer moon_window_get_platform_window (MoonWindow *instance);
+
+/* @GeneratePInvoke */
bool moon_window_get_transparent (MoonWindow *instance);
/* @GeneratePInvoke */
void moon_window_set_transparent (MoonWindow *instance, bool flag);
/**
- * MoonWindowGtk
+ * MoonWindowingSystem
**/
/* @GeneratePInvoke */
-void *moon_window_gtk_get_native_widget (MoonWindowGtk *instance);
+MoonWindow *moon_windowing_system_create_window (MoonWindowingSystem *instance, bool fullscreen, int width, int height, MoonWindow *parentWindow, Surface *surface);
/* @GeneratePInvoke */
-MoonWindowGtk *moon_window_gtk_new (bool fullscreen, int w, int h, MoonWindow *parent, Surface *surface);
+int moon_windowing_system_show_message_box (MoonWindowingSystem *instance, const char *caption, const char *text, int buttons);
+/* @GeneratePInvoke */
+gchar* *moon_windowing_system_show_open_file_dialog (MoonWindowingSystem *instance, const char *title, bool multsel, const char *filter, int idx);
+
+/* @GeneratePInvoke */
+char *moon_windowing_system_show_save_file_dialog (MoonWindowingSystem *instance, const char *title, const char *filter, int idx);
+
/**
* MouseButtonEventArgs
**/
Modified: trunk/moon/src/deepzoomimagetilesource.cpp
===================================================================
--- trunk/moon/src/deepzoomimagetilesource.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/deepzoomimagetilesource.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -19,6 +19,7 @@
#include "application.h"
#include "debug.h"
#include "runtime.h"
+#include "deployment.h"
#include "deepzoomimagetilesource.h"
#include "multiscalesubimage.h"
Modified: trunk/moon/src/dependencyproperty.cpp
===================================================================
--- trunk/moon/src/dependencyproperty.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/dependencyproperty.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -17,6 +17,7 @@
#include "dependencyproperty.h"
#include "animation.h"
#include "runtime.h"
+#include "deployment.h"
#include "validators.h"
#include "eventargs.h"
#include "deployment.h"
Modified: trunk/moon/src/dirty.cpp
===================================================================
--- trunk/moon/src/dirty.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/dirty.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -22,6 +22,7 @@
#include "clock.h"
#include "dirty.h"
#include "list.h"
+#include "window.h"
#include "deployment.h"
class DirtyNode : public List::Node {
Modified: trunk/moon/src/downloader.cpp
===================================================================
--- trunk/moon/src/downloader.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/downloader.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -46,6 +46,7 @@
#include "file-downloader.h"
#include "mms-downloader.h"
#include "runtime.h"
+#include "deployment.h"
#include "utils.h"
#include "error.h"
#include "debug.h"
Modified: trunk/moon/src/enums.h
===================================================================
--- trunk/moon/src/enums.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/enums.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -240,7 +240,18 @@
KeyUNKNOWN = 255
};
+enum TabletDeviceType {
+ TabletDeviceTypeMouse,
+ TabletDeviceTypeStylus,
+ TabletDeviceTypeTouch
+};
+enum TouchAction {
+ TouchActionDown = 1,
+ TouchActionMove = 2,
+ TouchActionUp = 3
+};
+
// Silverlight 2.0 Enums:
enum BindingMode {
Modified: trunk/moon/src/eventargs.cpp
===================================================================
--- trunk/moon/src/eventargs.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/eventargs.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -10,8 +10,6 @@
#include <config.h>
-#include <gdk/gdkkeysyms.h>
-
#include "eventargs.h"
#include "uielement.h"
#include "collection.h"
@@ -224,52 +222,45 @@
log_source = (LogSource) 0;
}
-MouseEventArgs::MouseEventArgs (GdkEvent *event)
+MouseEventArgs::MouseEventArgs (MoonMouseEvent *event)
: RoutedEventArgs (Type::MOUSEEVENTARGS)
{
- this->event = gdk_event_copy (event);
+ this->event = (MoonMouseEvent*)event->Clone();
}
-MouseEventArgs::MouseEventArgs (Type::Kind kind, GdkEvent *event)
+MouseEventArgs::MouseEventArgs (Type::Kind kind, MoonMouseEvent *event)
: RoutedEventArgs (kind)
{
- this->event = gdk_event_copy (event);
+ this->event = (MoonMouseEvent*)event->Clone();
}
MouseEventArgs::MouseEventArgs ()
: RoutedEventArgs (Type::MOUSEEVENTARGS)
{
- event = gdk_event_new (GDK_MOTION_NOTIFY);
+ event = NULL;
}
MouseEventArgs::~MouseEventArgs ()
{
- gdk_event_free (event);
+ delete event;
}
-int
-MouseEventArgs::GetState ()
-{
- GdkModifierType state;
- gdk_event_get_state (event, &state);
- return (int)state;
-}
-
void
MouseEventArgs::GetPosition (UIElement *relative_to, double *x, double *y)
{
- *x = *y = 0.0;
- if (gdk_event_get_coords (event, x, y)) {
- if (relative_to) {
- // FIXME this a nasty place to do this we should be able to
- // reduce the problem for this kind of hit testing.
- if (relative_to->IsAttached ())
- relative_to->GetDeployment ()->GetSurface ()->ProcessDirtyElements ();
+ if (event) {
+ Point p = event->GetPosition ();
+ *x = p.x;
+ *y = p.y;
+ }
-
- relative_to->TransformPoint (x, y);
- }
- }
+ if (relative_to) {
+ // FIXME this a nasty place to do this we should be able to
+ // reduce the problem for this kind of hit testing.
+ if (relative_to->IsAttached ())
+ relative_to->GetDeployment ()->GetSurface ()->ProcessDirtyElements ();
+ relative_to->TransformPoint (x, y);
+ }
}
StylusInfo*
@@ -277,41 +268,9 @@
{
TabletDeviceType type = TabletDeviceTypeMouse;
bool is_inverted = false;
- GdkDevice *gdk_device;
- switch (event->type) {
- case GDK_MOTION_NOTIFY:
- gdk_device = ((GdkEventMotion*)event)->device;
- break;
- case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- gdk_device = ((GdkEventButton*)event)->device;
- break;
+ GetEvent()->GetStylusInfo (&type, &is_inverted);
- default:
- case GDK_ENTER_NOTIFY:
- case GDK_LEAVE_NOTIFY:
- /* GdkEventCrossing doesn't have a device field. ugh */
- gdk_device = NULL;
- break;
- }
-
- if (gdk_device) {
- switch (gdk_device->source) {
- case GDK_SOURCE_PEN:
- case GDK_SOURCE_ERASER:
- type = TabletDeviceTypeStylus;
- break;
- case GDK_SOURCE_MOUSE:
- case GDK_SOURCE_CURSOR: /* XXX not sure where to lump this in.. in the stylus block? */
- default:
- type = TabletDeviceTypeMouse;
- break;
- }
-
- is_inverted = (gdk_device->source == GDK_SOURCE_ERASER);
- }
-
StylusInfo *info = new StylusInfo ();
info->SetValue (StylusInfo::DeviceTypeProperty, Value (type));
@@ -328,9 +287,9 @@
double x, y;
GetPosition (ink_presenter, &x, &y);
- if (!((GdkEventMotion *) event)->device || !gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &pressure))
- pressure = 0.0;
-
+
+ pressure = GetEvent()->GetPressure ();
+
StylusPoint *point = new StylusPoint ();
point->SetValue (StylusPoint::XProperty, Value(x));
point->SetValue (StylusPoint::YProperty, Value(y));
@@ -343,167 +302,70 @@
return points;
}
-MouseButtonEventArgs::MouseButtonEventArgs (GdkEvent *event)
- : MouseEventArgs (Type::MOUSEBUTTONEVENTARGS, event)
-{
-}
-
MouseButtonEventArgs::MouseButtonEventArgs ()
: MouseEventArgs (Type::MOUSEBUTTONEVENTARGS, NULL)
{
- event = gdk_event_new (GDK_BUTTON_PRESS);
}
-int
-MouseButtonEventArgs::GetButton ()
+MouseButtonEventArgs::MouseButtonEventArgs (MoonButtonEvent *event)
+ : MouseEventArgs (Type::MOUSEBUTTONEVENTARGS, event)
{
- switch (event->type) {
- case GDK_BUTTON_RELEASE:
- case GDK_3BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- case GDK_BUTTON_PRESS:
- return ((GdkEventButton *) event)->button;
- break;
- default:
- return 0;
- }
}
-int
-MouseButtonEventArgs::GetClickCount ()
+MouseButtonEventArgs::~MouseButtonEventArgs ()
{
- switch (event->type) {
- case GDK_3BUTTON_PRESS:
- return 3;
- case GDK_2BUTTON_PRESS:
- return 2;
- case GDK_BUTTON_PRESS:
- return 1;
- default:
- return 0;
- }
}
-MouseButtonEventArgs::~MouseButtonEventArgs ()
+MouseWheelEventArgs::MouseWheelEventArgs ()
+ : MouseEventArgs (Type::MOUSEWHEELEVENTARGS, NULL)
{
}
-MouseWheelEventArgs::MouseWheelEventArgs (GdkEvent *event)
+MouseWheelEventArgs::MouseWheelEventArgs (MoonScrollWheelEvent *event)
: MouseEventArgs (Type::MOUSEWHEELEVENTARGS, event)
{
}
-MouseWheelEventArgs::MouseWheelEventArgs ()
- : MouseEventArgs (Type::MOUSEWHEELEVENTARGS, NULL)
-{
- event = gdk_event_new (GDK_SCROLL);
-}
-
-
MouseWheelEventArgs::~MouseWheelEventArgs ()
{
}
-#define MOON_SCROLL_WHEEL_DELTA 10
-
int
MouseWheelEventArgs::GetWheelDelta ()
{
- /* we only handle UP/DOWN scroll events for the time being */
- switch (((GdkEventScroll*)event)->direction) {
- case GDK_SCROLL_UP:
- return MOON_SCROLL_WHEEL_DELTA;
- case GDK_SCROLL_DOWN:
- return -MOON_SCROLL_WHEEL_DELTA;
-
- default:
- case GDK_SCROLL_LEFT:
- case GDK_SCROLL_RIGHT:
- return 0;
- }
+ MoonScrollWheelEvent *event = (MoonScrollWheelEvent*)GetEvent();
+ return event ? event->GetWheelDelta () : 0;
}
-KeyEventArgs::KeyEventArgs (GdkEventKey *event)
+KeyEventArgs::KeyEventArgs (MoonKeyEvent *event)
: RoutedEventArgs (Type::KEYEVENTARGS)
{
- this->event = (GdkEventKey *) gdk_event_copy ((GdkEvent *)event);
+ this->event = (MoonKeyEvent*)event->Clone ();
}
KeyEventArgs::KeyEventArgs ()
: RoutedEventArgs (Type::KEYEVENTARGS)
{
- event = (GdkEventKey *) gdk_event_new (GDK_KEY_PRESS);
+ this->event = NULL;
}
KeyEventArgs::~KeyEventArgs ()
{
- gdk_event_free ((GdkEvent *) event);
+ delete event;
}
-GdkEventKey *
-KeyEventArgs::GetEvent ()
-{
- return event;
-}
-
int
KeyEventArgs::GetKey ()
{
- return Keyboard::MapKeyValToKey (event->keyval);
+ return event ? event->GetSilverlightKey() : KeyUNKNOWN;
}
int
KeyEventArgs::GetPlatformKeyCode ()
{
- return (moonlight_flags & RUNTIME_INIT_EMULATE_KEYCODES) ? Keyboard::MapGdkToVKey (event) : event->hardware_keycode;
+ return event ? event->GetPlatformKeycode() : 0;
}
-GdkModifierType
-KeyEventArgs::GetModifiers ()
-{
- return (GdkModifierType) event->state;
-}
-
-bool
-KeyEventArgs::IsModifier ()
-{
-#if GTK_CHECK_VERSION(2,10,0)
- if (gtk_check_version(2,10,0))
- return event->is_modifier;
- else
-#endif
- switch (event->keyval) {
- case GDK_Shift_L:
- case GDK_Shift_R:
- case GDK_Control_L:
- case GDK_Control_R:
- case GDK_Meta_L:
- case GDK_Meta_R:
- case GDK_Alt_L:
- case GDK_Alt_R:
- case GDK_Super_L:
- case GDK_Super_R:
- case GDK_Hyper_L:
- case GDK_Hyper_R:
- return true;
- default:
- return false;
- }
-}
-
-guint
-KeyEventArgs::GetKeyVal ()
-{
- return event->keyval;
-}
-
-gunichar
-KeyEventArgs::GetUnicode ()
-{
- return gdk_keyval_to_unicode (event->keyval);
-}
-
-
//
// ErrorEventArgs
//
Modified: trunk/moon/src/eventargs.h
===================================================================
--- trunk/moon/src/eventargs.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/eventargs.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -14,10 +14,10 @@
#include <glib.h>
#include <cairo.h>
-#include <gdk/gdkevents.h>
#include "dependencyobject.h"
#include "keyboard.h"
#include "enums.h"
+#include "pal.h"
#include "error.h"
class StylusInfo;
@@ -207,7 +207,7 @@
public:
/* @GenerateCBinding,GeneratePInvoke */
KeyEventArgs ();
- KeyEventArgs (GdkEventKey *event);
+ KeyEventArgs (MoonKeyEvent *event);
/* @GenerateCBinding,GeneratePInvoke */
int GetKey ();
@@ -215,18 +215,12 @@
/* @GenerateCBinding,GeneratePInvoke */
int GetPlatformKeyCode ();
- // accessors for the native GdkEventKey
- GdkEventKey *GetEvent ();
- GdkModifierType GetModifiers ();
- gunichar GetUnicode ();
- guint GetKeyVal ();
- bool IsModifier ();
-
+ MoonKeyEvent *GetEvent () { return event; }
protected:
virtual ~KeyEventArgs ();
private:
- GdkEventKey *event;
+ MoonKeyEvent *event;
};
/* @Namespace=None */
@@ -234,12 +228,10 @@
public:
/* @GenerateCBinding,GeneratePInvoke */
MouseEventArgs ();
- MouseEventArgs (GdkEvent *event);
+ MouseEventArgs (MoonMouseEvent *event);
- GdkEvent *GetEvent () { return event; }
-
- int GetState ();
-
+ MoonMouseEvent *GetEvent () { return event; }
+
/* @GenerateCBinding,GeneratePInvoke */
void GetPosition (UIElement *relative_to, double *x, double *y);
@@ -251,9 +243,10 @@
protected:
virtual ~MouseEventArgs ();
- MouseEventArgs (Type::Kind kind, GdkEvent *event);
+ MouseEventArgs (Type::Kind kind, MoonMouseEvent *event);
- GdkEvent *event;
+private:
+ MoonMouseEvent *event;
};
/* @Namespace=None */
@@ -275,10 +268,7 @@
public:
/* @GenerateCBinding,GeneratePInvoke */
MouseButtonEventArgs ();
- MouseButtonEventArgs (GdkEvent *event);
-
- int GetButton ();
- int GetClickCount ();
+ MouseButtonEventArgs (MoonButtonEvent *event);
protected:
virtual ~MouseButtonEventArgs ();
@@ -289,7 +279,7 @@
public:
/* @GenerateCBinding,GeneratePInvoke */
MouseWheelEventArgs ();
- MouseWheelEventArgs (GdkEvent *event);
+ MouseWheelEventArgs (MoonScrollWheelEvent *event);
/* @GenerateCBinding,GeneratePInvoke */
int GetWheelDelta ();
Modified: trunk/moon/src/glyphs.cpp
===================================================================
--- trunk/moon/src/glyphs.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/glyphs.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -22,6 +22,7 @@
#include "file-downloader.h"
#include "runtime.h"
+#include "deployment.h"
#include "glyphs.h"
#include "utils.h"
#include "debug.h"
Modified: trunk/moon/src/keyboard.cpp
===================================================================
--- trunk/moon/src/keyboard.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/keyboard.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -11,7 +11,6 @@
#include <config.h>
#include <stdio.h>
-#include <gdk/gdkkeysyms.h>
#include "keyboard.h"
@@ -82,210 +81,3 @@
{
return pressedKeys && (g_hash_table_lookup (pressedKeys, GINT_TO_POINTER (key)) != NULL);
}
-
-Key
-Keyboard::MapKeyValToKey (guint keyval)
-{
- switch (keyval) {
- case GDK_BackSpace: return KeyBACKSPACE;
- case GDK_Tab: case GDK_ISO_Left_Tab: return KeyTAB;
- case GDK_Return: case GDK_KP_Enter: return KeyENTER;
- case GDK_Shift_L: case GDK_Shift_R: return KeySHIFT;
- case GDK_Control_L: case GDK_Control_R: return KeyCTRL;
- case GDK_Alt_L: case GDK_Alt_R: return KeyALT;
- case GDK_Caps_Lock: return KeyCAPSLOCK;
- case GDK_Escape: return KeyESCAPE;
- case GDK_space: case GDK_KP_Space: return KeySPACE;
- case GDK_Page_Up: case GDK_KP_Page_Up: return KeyPAGEUP;
- case GDK_Page_Down: case GDK_KP_Page_Down: return KeyPAGEDOWN;
- case GDK_End: case GDK_KP_End: return KeyEND;
- case GDK_Home: case GDK_KP_Home: return KeyHOME;
- case GDK_Left: case GDK_KP_Left: return KeyLEFT;
- case GDK_Up: case GDK_KP_Up: return KeyUP;
- case GDK_Right: case GDK_KP_Right: return KeyRIGHT;
- case GDK_Down: case GDK_KP_Down: return KeyDOWN;
- case GDK_Insert: case GDK_KP_Insert: return KeyINSERT;
- case GDK_Delete: case GDK_KP_Delete: return KeyDELETE;
- case GDK_0: case GDK_parenright: return KeyDIGIT0;
- case GDK_1: case GDK_exclam: return KeyDIGIT1;
- case GDK_2: case GDK_at: return KeyDIGIT2;
- case GDK_3: case GDK_numbersign: return KeyDIGIT3;
- case GDK_4: case GDK_dollar: return KeyDIGIT4;
- case GDK_5: case GDK_percent: return KeyDIGIT5;
- case GDK_6: case GDK_asciicircum: return KeyDIGIT6;
- case GDK_7: case GDK_ampersand: return KeyDIGIT7;
- case GDK_8: case GDK_multiply: return KeyDIGIT8;
- case GDK_9: case GDK_parenleft: return KeyDIGIT9;
- case GDK_a: case GDK_A: return KeyA;
- case GDK_b: case GDK_B: return KeyB;
- case GDK_c: case GDK_C: return KeyC;
- case GDK_d: case GDK_D: return KeyD;
- case GDK_e: case GDK_E: return KeyE;
- case GDK_f: case GDK_F: return KeyF;
- case GDK_g: case GDK_G: return KeyG;
- case GDK_h: case GDK_H: return KeyH;
- case GDK_i: case GDK_I: return KeyI;
- case GDK_j: case GDK_J: return KeyJ;
- case GDK_k: case GDK_K: return KeyK;
- case GDK_l: case GDK_L: return KeyL;
- case GDK_m: case GDK_M: return KeyM;
- case GDK_n: case GDK_N: return KeyN;
- case GDK_o: case GDK_O: return KeyO;
- case GDK_p: case GDK_P: return KeyP;
- case GDK_q: case GDK_Q: return KeyQ;
- case GDK_r: case GDK_R: return KeyR;
- case GDK_s: case GDK_S: return KeyS;
- case GDK_t: case GDK_T: return KeyT;
- case GDK_u: case GDK_U: return KeyU;
- case GDK_v: case GDK_V: return KeyV;
- case GDK_w: case GDK_W: return KeyW;
- case GDK_x: case GDK_X: return KeyX;
- case GDK_y: case GDK_Y: return KeyY;
- case GDK_z: case GDK_Z: return KeyZ;
-
- case GDK_F1: case GDK_KP_F1: return KeyF1;
- case GDK_F2: case GDK_KP_F2: return KeyF2;
- case GDK_F3: case GDK_KP_F3: return KeyF3;
- case GDK_F4: case GDK_KP_F4: return KeyF4;
- case GDK_F5: return KeyF5;
- case GDK_F6: return KeyF6;
- case GDK_F7: return KeyF7;
- case GDK_F8: return KeyF8;
- case GDK_F9: return KeyF9;
- case GDK_F10: return KeyF10;
- case GDK_F11: return KeyF11;
- case GDK_F12: return KeyF12;
-
- case GDK_KP_0: return KeyNUMPAD0;
- case GDK_KP_1: return KeyNUMPAD1;
- case GDK_KP_2: return KeyNUMPAD2;
- case GDK_KP_3: return KeyNUMPAD3;
- case GDK_KP_4: return KeyNUMPAD4;
- case GDK_KP_5: return KeyNUMPAD5;
- case GDK_KP_6: return KeyNUMPAD6;
- case GDK_KP_7: return KeyNUMPAD7;
- case GDK_KP_8: return KeyNUMPAD8;
- case GDK_KP_9: return KeyNUMPAD9;
-
- case GDK_KP_Multiply: case GDK_asterisk: return KeyMULTIPLY;
- case GDK_KP_Add: case GDK_plus: case GDK_equal: return KeyADD;
- case GDK_KP_Subtract: case GDK_minus: case GDK_underscore: return KeySUBTRACT;
- case GDK_KP_Decimal: case GDK_period: return KeyDECIMAL;
- case GDK_KP_Divide: case GDK_slash: return KeyDIVIDE;
-
- default:
- return KeyUNKNOWN;
- }
-}
-
-int
-Keyboard::MapGdkToVKey (GdkEventKey *event)
-{
- if (event->keyval >= GDK_A && event->keyval <= GDK_Z)
- return event->keyval;
- if (event->keyval >= GDK_a && event->keyval <= GDK_z)
- return event->keyval - GDK_a + GDK_A;
-
- if (event->keyval >= GDK_F1 && event->keyval <= GDK_F24)
- return event->keyval - GDK_F1 + 0x70;
-
- if (event->keyval >= GDK_KP_0 && event->keyval <= GDK_KP_9)
- return event->keyval - GDK_KP_0 + 0x60;
-
- switch (event->keyval) {
- case GDK_Delete:
- return 0x2e;
-
- case GDK_parenright:
- case GDK_0:
- return 0x30;
-
- case GDK_exclam:
- case GDK_1:
- return 0x31;
-
- case GDK_at:
- case GDK_2:
- return 0x32;
-
- case GDK_numbersign:
- case GDK_3:
- return 0x33;
-
- case GDK_dollar:
- case GDK_4:
- return 0x34;
-
- case GDK_percent:
- case GDK_5:
- return 0x35;
-
- case GDK_asciicircum:
- case GDK_6:
- return 0x36;
-
- case GDK_ampersand:
- case GDK_7:
- return 0x37;
-
- case GDK_multiply:
- case GDK_8:
- return 0x38;
-
- case GDK_parenleft:
- case GDK_9:
- return 0x39;
-
- case GDK_Num_Lock:
- return 0x90;
-
- case GDK_colon:
- case GDK_semicolon:
- return 0xba;
-
- case GDK_equal:
- case GDK_plus:
- return 0xbb;
-
- case GDK_comma:
- case GDK_less:
- return 0xbc;
-
- case GDK_minus:
- case GDK_underscore:
- return 0xbd;
-
- case GDK_period:
- case GDK_greater:
- return 0xbe;
-
- case GDK_slash:
- case GDK_question:
- return 0xbf;
-
- case GDK_grave:
- case GDK_asciitilde:
- return 0xc0;
-
- case GDK_bracketleft:
- case GDK_braceleft:
- return 0xdb;
-
- case GDK_backslash:
- case GDK_bar:
- return 0xdc;
-
- case GDK_bracketright:
- case GDK_braceright:
- return 0xdd;
-
- case GDK_quotedbl:
- case GDK_apostrophe:
- return 0xde;
-
- default:
- printf ("default case for keyval 0x%0x keycode %d\n", event->keyval, event->hardware_keycode);
- return event->hardware_keycode;
- }
-}
-
Modified: trunk/moon/src/keyboard.h
===================================================================
--- trunk/moon/src/keyboard.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/keyboard.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -13,8 +13,6 @@
#include <glib.h>
-#include <gdk/gdkevents.h>
-
#include "enums.h"
class Keyboard {
@@ -31,10 +29,6 @@
static void OnKeyRelease (Key key);
static bool IsKeyPressed (Key key);
-
- static Key MapKeyValToKey (guint keyval);
-
- static int MapGdkToVKey (GdkEventKey *event);
};
#endif /* __KEYBOARD_H__ */
Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/media.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -14,7 +14,6 @@
#define __MEDIA_H__
#include <glib.h>
-#include <gdk/gdkpixbuf.h>
#include "value.h"
#include "brush.h"
Modified: trunk/moon/src/mediaelement.h
===================================================================
--- trunk/moon/src/mediaelement.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/mediaelement.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -14,7 +14,6 @@
#define __MOON_MEDIAELEMENT_H__
#include <glib.h>
-#include <gdk/gdkpixbuf.h>
#include "value.h"
#include "frameworkelement.h"
Deleted: trunk/moon/src/messagebox.cpp
===================================================================
--- trunk/moon/src/messagebox.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/messagebox.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,53 +0,0 @@
-/*
- * messagebox.cpp: MessageBox dialog
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2007, 2009 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#include <config.h>
-#include "messagebox.h"
-
-int
-message_box_show (const char *caption, const char* text, int buttons)
-{
- if (!caption || !text)
- return MESSAGE_BOX_RESULT_NONE;
-
- // NOTE: this dialog is displayed even WITHOUT any user action
- //if (!Deployment::GetCurrent ()->GetSurface ()->IsUserInitiatedEvent ())
- // return MESSAGE_BOX_RESULT_NONE;
-
- GtkButtonsType bt = buttons == MESSAGE_BOX_BUTTON_OK ? GTK_BUTTONS_OK : GTK_BUTTONS_OK_CANCEL;
-
- GtkWidget *widget = gtk_message_dialog_new (NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_OTHER,
- bt,
- text);
-
- gtk_window_set_title (GTK_WINDOW (widget), caption);
-
- gint result = gtk_dialog_run (GTK_DIALOG (widget));
- gtk_widget_destroy (widget);
-
- switch (result) {
- case GTK_RESPONSE_OK:
- return MESSAGE_BOX_RESULT_OK;
- case GTK_RESPONSE_CANCEL:
- return MESSAGE_BOX_RESULT_CANCEL;
- case GTK_RESPONSE_YES:
- return MESSAGE_BOX_RESULT_YES;
- case GTK_RESPONSE_NO:
- return MESSAGE_BOX_RESULT_NO;
- case GTK_RESPONSE_NONE:
- default:
- return MESSAGE_BOX_RESULT_NONE;
- }
-}
-
Deleted: trunk/moon/src/messagebox.h
===================================================================
--- trunk/moon/src/messagebox.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/messagebox.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,46 +0,0 @@
-/*
- * messagebox.h: MessageBox dialog
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2009 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#ifndef __MESSAGEBOX_H__
-#define __MESSAGEBOX_H__
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include "runtime.h"
-#include "deployment.h"
-
-G_BEGIN_DECLS
-
-// much match values from System.Windows.MessageBoxButtons
-#define MESSAGE_BOX_BUTTON_OK 0
-#define MESSAGE_BOX_BUTTON_OK_CANCEL 1
-
-// much match values from System.Windows.MessageBoxResult
-#define MESSAGE_BOX_RESULT_NONE 0
-#define MESSAGE_BOX_RESULT_OK 1
-#define MESSAGE_BOX_RESULT_CANCEL 2
-#define MESSAGE_BOX_RESULT_YES 6
-#define MESSAGE_BOX_RESULT_NO 7
-
-// older gtk+ (like 2.8 used in SLED10) don't support icon-less GTK_MESSAGE_OTHER
-#ifndef GTK_MESSAGE_OTHER
-#define GTK_MESSAGE_OTHER GTK_MESSAGE_INFO
-#endif
-
-/* @GeneratePInvoke */
-int message_box_show (const char *caption, const char* text, int buttons);
-
-G_END_DECLS
-
-#endif
-
Modified: trunk/moon/src/openfile.cpp
===================================================================
--- trunk/moon/src/openfile.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/openfile.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -11,106 +11,22 @@
*/
#include <config.h>
-#include "openfile.h"
-// FIXME: Silverlight 1.1 (alpha, refresh) doesn't allow the selection(*) of
-// symlinks on Mac OSX. (*) actually it de-selects them on the fly. We should
-// be able to duplicate this with lstat and the selection-changed event.
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
-static void
-set_filters (GtkFileChooser *chooser, const char* filter, int idx)
-{
- if (!filter || (strlen (filter) <= 1))
- return;
+#include <glib/gstdio.h>
- char **filters = g_strsplit (filter, "|", 0);
+#include <gtk/gtk.h>
- // to be valid (managed code) we know we have an even number of items
- // (if not we're still safe by dropping the last one)
- int pos = 0;
- int n = g_strv_length (filters) >> 1;
- for (int i=0; i < n; i++) {
- char *name = g_strstrip (filters[pos++]);
- if (strlen (name) < 1)
- continue;
+#include "openfile.h"
+#include "runtime.h"
+#include "deployment.h"
- char *pattern = g_strstrip (filters[pos++]);
- if (strlen (pattern) < 1)
- continue;
+#define MOONLIGHT_MINIMUM_FILE_ENTRY_COST 1024
+#define MOONLIGHT_FILE_SIZE_MASK (MOONLIGHT_MINIMUM_FILE_ENTRY_COST - 1)
- GtkFileFilter *ff = gtk_file_filter_new ();
- gtk_file_filter_set_name (ff, g_strdup (name));
- // there can be multiple patterns in a single string
- if (g_strrstr (pattern, ";")) {
- int n = 0;
- char **patterns = g_strsplit (pattern, ";", 0);
- while (char *p = patterns[n++])
- gtk_file_filter_add_pattern (ff, g_strdup (p));
- g_strfreev (patterns);
- } else {
- // or a single one
- gtk_file_filter_add_pattern (ff, g_strdup (pattern));
- }
- gtk_file_chooser_add_filter (chooser, ff);
- // idx (FilterIndex) is 1 (not 0) based
- if (i == (idx - 1))
- gtk_file_chooser_set_filter (chooser, ff);
- }
- g_strfreev (filters);
-}
-
-char **
-open_file_dialog_show (const char *title, bool multsel, const char *filter, int idx)
-{
- GtkWidget *widget = gtk_file_chooser_dialog_new (title, NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
-
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- set_filters (chooser, filter, idx);
- gtk_file_chooser_set_select_multiple (chooser, multsel ? TRUE : FALSE);
-
- char **ret = NULL;
- if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_ACCEPT){
- GSList *k, *l = gtk_file_chooser_get_filenames (chooser);
- int i, count = g_slist_length (l);
-
- ret = g_new (char *, count + 1);
- ret [count] = NULL;
-
- for (i = 0, k = l; k; k = k->next)
- ret [i++] = (char *) k->data;
-
- g_slist_free (l);
- }
-
- gtk_widget_destroy (widget);
-
- return ret;
-}
-
-char *
-save_file_dialog_show (const char *title, const char *filter, int idx)
-{
- GtkWidget *widget = gtk_file_chooser_dialog_new (title, NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
-
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- set_filters (chooser, filter, idx);
- gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
-
- char *ret = NULL;
- if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_ACCEPT)
- ret = gtk_file_chooser_get_filename (chooser);
-
- gtk_widget_destroy (widget);
-
- return ret;
-}
-
// NOTE: this is used from 'mscorlib.dll' System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs
// NOTE: we let the caller supply the string so i18n can occur in managed land only
gboolean
Modified: trunk/moon/src/openfile.h
===================================================================
--- trunk/moon/src/openfile.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/openfile.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -13,29 +13,10 @@
#ifndef __OPENFILE_H__
#define __OPENFILE_H__
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-
#include <glib.h>
-#include <glib/gstdio.h>
-#include <gtk/gtk.h>
-
-#include "runtime.h"
-#include "deployment.h"
-
G_BEGIN_DECLS
-#define MOONLIGHT_MINIMUM_FILE_ENTRY_COST 1024
-#define MOONLIGHT_FILE_SIZE_MASK (MOONLIGHT_MINIMUM_FILE_ENTRY_COST - 1)
-
-/* @GeneratePInvoke */
-char **open_file_dialog_show (const char *title, bool multsel, const char *filter, int idx);
-
-/* @GeneratePInvoke */
-char *save_file_dialog_show (const char *title, const char *filter, int idx);
-
// NOTE: this is used from 'mscorlib.dll' System.IO.IsolatedStorage/MoonIsolatedStorageFile.cs
gboolean isolated_storage_increase_quota_to (const char *primary_text, const char* secondary_text);
Added: trunk/moon/src/pal/gtk/clipboard-gtk.cpp
===================================================================
--- trunk/moon/src/pal/gtk/clipboard-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/clipboard-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include "pal-gtk.h"
+
+#include "clipboard-gtk.h"
+
+#include "runtime.h"
+#include "window-gtk.h"
+
+MoonClipboardGtk::MoonClipboardGtk (MoonWindowGtk *win, MoonClipboardType clipboardType)
+{
+ GtkWidget *widget = GTK_WIDGET (win->GetPlatformWindow ());
+ GdkWindow *window = GDK_WINDOW (widget->window);
+ GdkDisplay *display = gdk_drawable_get_display (GDK_DRAWABLE (window));
+
+ GdkAtom gdk_type;
+
+ switch (clipboardType) {
+ case MoonClipboard_Clipboard: gdk_type = GDK_SELECTION_CLIPBOARD; break;
+ case MoonClipboard_Primary: gdk_type = GDK_SELECTION_PRIMARY; break;
+ }
+
+ if (display)
+ clipboard = gtk_clipboard_get_for_display (display, gdk_type);
+ else
+ clipboard = NULL;
+}
+
+void
+MoonClipboardGtk::SetSelection (const char *text, int length)
+{
+}
+
+void
+MoonClipboardGtk::SetText (const char *text, int length)
+{
+ gtk_clipboard_set_text (clipboard, text, length);
+}
+
+class AsyncClosure {
+public:
+ AsyncClosure (MoonClipboard *clipboard, MoonClipboardGetTextCallback cb, gpointer data) : clipboard (clipboard), cb (cb), cb_data (data) { }
+ MoonClipboard *clipboard;
+ MoonClipboardGetTextCallback cb;
+ gpointer cb_data;
+};
+
+void
+MoonClipboardGtk::async_get_text (GtkClipboard *gtk_clipboard, const char *text, gpointer data)
+{
+ AsyncClosure *closure = (AsyncClosure*)data;
+ MoonClipboard *clipboard = closure->clipboard;
+ MoonClipboardGetTextCallback cb = closure->cb;
+ gpointer cb_data = closure->cb_data;
+
+ delete closure;
+
+ cb (clipboard, text, cb_data);
+}
+
+void
+MoonClipboardGtk::AsyncGetText (MoonClipboardGetTextCallback cb, gpointer data)
+{
+ AsyncClosure *closure = new AsyncClosure (this, cb, data);
+ gtk_clipboard_request_text (clipboard, async_get_text, closure);
+}
+
+char*
+MoonClipboardGtk::GetText ()
+{
+ return gtk_clipboard_wait_for_text (clipboard);
+}
Added: trunk/moon/src/pal/gtk/clipboard-gtk.h
===================================================================
--- trunk/moon/src/pal/gtk/clipboard-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/clipboard-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,27 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef MOON_CLIPBOARD_GTK_H
+#define MOON_CLIPBOARD_GTK_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "window-gtk.h"
+#include "pal.h"
+
+class MoonClipboardGtk : public MoonClipboard {
+public:
+ MoonClipboardGtk (MoonWindowGtk *win, MoonClipboardType clipboardType);
+
+ void SetSelection (const char *text, int length);
+
+ virtual void SetText (const char *text, int length);
+ virtual void AsyncGetText (MoonClipboardGetTextCallback cb, gpointer data);
+ virtual char* GetText ();
+
+private:
+ static void async_get_text (GtkClipboard *clipboard, const char *text, gpointer data);
+ GtkClipboard *clipboard;
+};
+
+#endif
Added: trunk/moon/src/pal/gtk/im-gtk.cpp
===================================================================
--- trunk/moon/src/pal/gtk/im-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/im-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include "im-gtk.h"
+
+#include <gtk/gtkimmulticontext.h>
+
+MoonIMContextGtk::MoonIMContextGtk ()
+{
+ im = gtk_im_multicontext_new ();
+}
+
+MoonIMContextGtk::~MoonIMContextGtk ()
+{
+ g_object_unref (im);
+ im = NULL;
+}
+
+
+void
+MoonIMContextGtk::SetUsePreedit (bool flag)
+{
+ gtk_im_context_set_use_preedit (im, flag);
+}
+
+void
+MoonIMContextGtk::SetClientWindow (MoonWindow* window)
+{
+ gtk_im_context_set_client_window (im, window ? GTK_WIDGET(window->GetPlatformWindow ())->window : NULL);
+}
+
+bool
+MoonIMContextGtk::FilterKeyPress (MoonKeyEvent* event)
+{
+ return gtk_im_context_filter_keypress (im, (GdkEventKey*)event->GetPlatformEvent());
+}
+
+void
+MoonIMContextGtk::SetSurroundingText (const char *text, int offset, int length)
+{
+ gtk_im_context_set_surrounding (im, text, offset, length);
+}
+
+void
+MoonIMContextGtk::Reset ()
+{
+ gtk_im_context_reset (im);
+}
+
+
+void
+MoonIMContextGtk::FocusIn ()
+{
+ gtk_im_context_focus_in (im);
+}
+
+void
+MoonIMContextGtk::FocusOut ()
+{
+ gtk_im_context_focus_out (im);
+}
+
+void
+MoonIMContextGtk::SetCursorLocation (Rect r)
+{
+ GdkRectangle area;
+ Rect rect;
+
+ area = r.ToGdkRectangle ();
+
+ gtk_im_context_set_cursor_location (im, &area);
+}
+
+void
+MoonIMContextGtk::SetRetrieveSurroundingCallback (MoonCallback cb, gpointer data)
+{
+ g_signal_connect (im, "retrieve-surrounding", G_CALLBACK (cb), data);
+}
+
+void
+MoonIMContextGtk::SetDeleteSurroundingCallback (MoonCallback cb, gpointer data)
+{
+ g_signal_connect (im, "delete-surrounding", G_CALLBACK (cb), data);
+}
+
+void
+MoonIMContextGtk::SetCommitCallback (MoonCallback cb, gpointer data)
+{
+ g_signal_connect (im, "commit", G_CALLBACK (cb), data);
+}
+
+gpointer
+MoonIMContextGtk::GetPlatformIMContext ()
+{
+ return im;
+}
+
Added: trunk/moon/src/pal/gtk/im-gtk.h
===================================================================
--- trunk/moon/src/pal/gtk/im-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/im-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef MOON_IM_GTK_H
+#define MOON_IM_GTK_H
+
+#include "pal.h"
+#include "window.h"
+
+#include <gtk/gtk.h>
+
+class MoonIMContextGtk : public MoonIMContext {
+public:
+ MoonIMContextGtk ();
+ virtual ~MoonIMContextGtk ();
+
+ virtual void SetUsePreedit (bool flag);
+ virtual void SetClientWindow (MoonWindow* window);
+ virtual void SetSurroundingText (const char *text, int offset, int length);
+ virtual void Reset ();
+
+ virtual void FocusIn ();
+ virtual void FocusOut ();
+
+ virtual void SetCursorLocation (Rect r);
+
+ virtual bool FilterKeyPress (MoonKeyEvent* event);
+
+ virtual void SetRetrieveSurroundingCallback (MoonCallback cb, gpointer data);
+ virtual void SetDeleteSurroundingCallback (MoonCallback cb, gpointer data);
+ virtual void SetCommitCallback (MoonCallback cb, gpointer data);
+
+ virtual gpointer GetPlatformIMContext ();
+
+ private:
+ GtkIMContext *im;
+};
+
+#endif /* MOON_IM_GTK_H */
Added: trunk/moon/src/pal/gtk/pal-gtk.cpp
===================================================================
--- trunk/moon/src/pal/gtk/pal-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/pal-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,896 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include "pal-gtk.h"
+
+#include "runtime.h"
+#include "window-gtk.h"
+#include "pixbuf-gtk.h"
+#include "im-gtk.h"
+
+#define Visual _XxVisual
+#define Region _XxRegion
+#include <gdk/gdkx.h>
+#include <cairo-xlib.h>
+#undef Visual
+#undef Region
+
+#include <gdk/gdkkeysyms.h>
+
+
+static Key
+MapKeyvalToKey (guint keyval)
+{
+ switch (keyval) {
+ case GDK_BackSpace: return KeyBACKSPACE;
+ case GDK_Tab: case GDK_ISO_Left_Tab: return KeyTAB;
+ case GDK_Return: case GDK_KP_Enter: return KeyENTER;
+ case GDK_Shift_L: case GDK_Shift_R: return KeySHIFT;
+ case GDK_Control_L: case GDK_Control_R: return KeyCTRL;
+ case GDK_Alt_L: case GDK_Alt_R: return KeyALT;
+ case GDK_Caps_Lock: return KeyCAPSLOCK;
+ case GDK_Escape: return KeyESCAPE;
+ case GDK_space: case GDK_KP_Space: return KeySPACE;
+ case GDK_Page_Up: case GDK_KP_Page_Up: return KeyPAGEUP;
+ case GDK_Page_Down: case GDK_KP_Page_Down: return KeyPAGEDOWN;
+ case GDK_End: case GDK_KP_End: return KeyEND;
+ case GDK_Home: case GDK_KP_Home: return KeyHOME;
+ case GDK_Left: case GDK_KP_Left: return KeyLEFT;
+ case GDK_Up: case GDK_KP_Up: return KeyUP;
+ case GDK_Right: case GDK_KP_Right: return KeyRIGHT;
+ case GDK_Down: case GDK_KP_Down: return KeyDOWN;
+ case GDK_Insert: case GDK_KP_Insert: return KeyINSERT;
+ case GDK_Delete: case GDK_KP_Delete: return KeyDELETE;
+ case GDK_0: case GDK_parenright: return KeyDIGIT0;
+ case GDK_1: case GDK_exclam: return KeyDIGIT1;
+ case GDK_2: case GDK_at: return KeyDIGIT2;
+ case GDK_3: case GDK_numbersign: return KeyDIGIT3;
+ case GDK_4: case GDK_dollar: return KeyDIGIT4;
+ case GDK_5: case GDK_percent: return KeyDIGIT5;
+ case GDK_6: case GDK_asciicircum: return KeyDIGIT6;
+ case GDK_7: case GDK_ampersand: return KeyDIGIT7;
+ case GDK_8: case GDK_multiply: return KeyDIGIT8;
+ case GDK_9: case GDK_parenleft: return KeyDIGIT9;
+ case GDK_a: case GDK_A: return KeyA;
+ case GDK_b: case GDK_B: return KeyB;
+ case GDK_c: case GDK_C: return KeyC;
+ case GDK_d: case GDK_D: return KeyD;
+ case GDK_e: case GDK_E: return KeyE;
+ case GDK_f: case GDK_F: return KeyF;
+ case GDK_g: case GDK_G: return KeyG;
+ case GDK_h: case GDK_H: return KeyH;
+ case GDK_i: case GDK_I: return KeyI;
+ case GDK_j: case GDK_J: return KeyJ;
+ case GDK_k: case GDK_K: return KeyK;
+ case GDK_l: case GDK_L: return KeyL;
+ case GDK_m: case GDK_M: return KeyM;
+ case GDK_n: case GDK_N: return KeyN;
+ case GDK_o: case GDK_O: return KeyO;
+ case GDK_p: case GDK_P: return KeyP;
+ case GDK_q: case GDK_Q: return KeyQ;
+ case GDK_r: case GDK_R: return KeyR;
+ case GDK_s: case GDK_S: return KeyS;
+ case GDK_t: case GDK_T: return KeyT;
+ case GDK_u: case GDK_U: return KeyU;
+ case GDK_v: case GDK_V: return KeyV;
+ case GDK_w: case GDK_W: return KeyW;
+ case GDK_x: case GDK_X: return KeyX;
+ case GDK_y: case GDK_Y: return KeyY;
+ case GDK_z: case GDK_Z: return KeyZ;
+
+ case GDK_F1: case GDK_KP_F1: return KeyF1;
+ case GDK_F2: case GDK_KP_F2: return KeyF2;
+ case GDK_F3: case GDK_KP_F3: return KeyF3;
+ case GDK_F4: case GDK_KP_F4: return KeyF4;
+ case GDK_F5: return KeyF5;
+ case GDK_F6: return KeyF6;
+ case GDK_F7: return KeyF7;
+ case GDK_F8: return KeyF8;
+ case GDK_F9: return KeyF9;
+ case GDK_F10: return KeyF10;
+ case GDK_F11: return KeyF11;
+ case GDK_F12: return KeyF12;
+
+ case GDK_KP_0: return KeyNUMPAD0;
+ case GDK_KP_1: return KeyNUMPAD1;
+ case GDK_KP_2: return KeyNUMPAD2;
+ case GDK_KP_3: return KeyNUMPAD3;
+ case GDK_KP_4: return KeyNUMPAD4;
+ case GDK_KP_5: return KeyNUMPAD5;
+ case GDK_KP_6: return KeyNUMPAD6;
+ case GDK_KP_7: return KeyNUMPAD7;
+ case GDK_KP_8: return KeyNUMPAD8;
+ case GDK_KP_9: return KeyNUMPAD9;
+
+ case GDK_KP_Multiply: case GDK_asterisk: return KeyMULTIPLY;
+ case GDK_KP_Add: case GDK_plus: case GDK_equal: return KeyADD;
+ case GDK_KP_Subtract: case GDK_minus: case GDK_underscore: return KeySUBTRACT;
+ case GDK_KP_Decimal: case GDK_period: return KeyDECIMAL;
+ case GDK_KP_Divide: case GDK_slash: return KeyDIVIDE;
+
+ default:
+ return KeyUNKNOWN;
+ }
+}
+
+static int
+MapGdkToVKey (GdkEventKey *event)
+{
+ if (event->keyval >= GDK_A && event->keyval <= GDK_Z)
+ return event->keyval;
+ if (event->keyval >= GDK_a && event->keyval <= GDK_z)
+ return event->keyval - GDK_a + GDK_A;
+
+ if (event->keyval >= GDK_F1 && event->keyval <= GDK_F24)
+ return event->keyval - GDK_F1 + 0x70;
+
+ if (event->keyval >= GDK_KP_0 && event->keyval <= GDK_KP_9)
+ return event->keyval - GDK_KP_0 + 0x60;
+
+ switch (event->keyval) {
+ case GDK_Delete:
+ return 0x2e;
+
+ case GDK_parenright:
+ case GDK_0:
+ return 0x30;
+
+ case GDK_exclam:
+ case GDK_1:
+ return 0x31;
+
+ case GDK_at:
+ case GDK_2:
+ return 0x32;
+
+ case GDK_numbersign:
+ case GDK_3:
+ return 0x33;
+
+ case GDK_dollar:
+ case GDK_4:
+ return 0x34;
+
+ case GDK_percent:
+ case GDK_5:
+ return 0x35;
+
+ case GDK_asciicircum:
+ case GDK_6:
+ return 0x36;
+
+ case GDK_ampersand:
+ case GDK_7:
+ return 0x37;
+
+ case GDK_multiply:
+ case GDK_8:
+ return 0x38;
+
+ case GDK_parenleft:
+ case GDK_9:
+ return 0x39;
+
+ case GDK_Num_Lock:
+ return 0x90;
+
+ case GDK_colon:
+ case GDK_semicolon:
+ return 0xba;
+
+ case GDK_equal:
+ case GDK_plus:
+ return 0xbb;
+
+ case GDK_comma:
+ case GDK_less:
+ return 0xbc;
+
+ case GDK_minus:
+ case GDK_underscore:
+ return 0xbd;
+
+ case GDK_period:
+ case GDK_greater:
+ return 0xbe;
+
+ case GDK_slash:
+ case GDK_question:
+ return 0xbf;
+
+ case GDK_grave:
+ case GDK_asciitilde:
+ return 0xc0;
+
+ case GDK_bracketleft:
+ case GDK_braceleft:
+ return 0xdb;
+
+ case GDK_backslash:
+ case GDK_bar:
+ return 0xdc;
+
+ case GDK_bracketright:
+ case GDK_braceright:
+ return 0xdd;
+
+ case GDK_quotedbl:
+ case GDK_apostrophe:
+ return 0xde;
+
+ default:
+ printf ("default case for keyval 0x%0x keycode %d\n", event->keyval, event->hardware_keycode);
+ return event->hardware_keycode;
+ }
+}
+
+class MoonKeyEventGtk : public MoonKeyEvent {
+public:
+ MoonKeyEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventKey*)gdk_event_copy (event);
+
+ key = MapKeyvalToKey (this->event->keyval);
+ keycode = (moonlight_flags & RUNTIME_INIT_EMULATE_KEYCODES) ? MapGdkToVKey (this->event) : this->event->hardware_keycode;
+ }
+
+ virtual ~MoonKeyEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent* Clone ()
+ {
+ return new MoonKeyEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent ()
+ {
+ return event;
+ }
+
+ virtual Key GetSilverlightKey ()
+ {
+ return key;
+ }
+
+ virtual int GetPlatformKeycode ()
+ {
+ return keycode;
+ }
+
+ virtual int GetPlatformKeyval ()
+ {
+ return event->keyval;
+ }
+
+ virtual gunichar GetUnicode ()
+ {
+ return gdk_keyval_to_unicode (event->keyval);
+ }
+
+ virtual MoonModifier GetModifiers ()
+ {
+ return (MoonModifier) event->state;
+ }
+
+
+ virtual bool IsModifier ()
+ {
+#if GTK_CHECK_VERSION(2,10,0)
+ if (gtk_check_version(2,10,0))
+ return event->is_modifier;
+ else
+#endif
+ switch (event->keyval) {
+ case GDK_Shift_L:
+ case GDK_Shift_R:
+ case GDK_Control_L:
+ case GDK_Control_R:
+ case GDK_Meta_L:
+ case GDK_Meta_R:
+ case GDK_Alt_L:
+ case GDK_Alt_R:
+ case GDK_Super_L:
+ case GDK_Super_R:
+ case GDK_Hyper_L:
+ case GDK_Hyper_R:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+private:
+ GdkEventKey *event;
+
+ Key key;
+ int keycode;
+};
+
+static void GetStylusInfoFromDevice (GdkDevice *gdk_device, TabletDeviceType *type, bool *is_inverted)
+{
+ if (!gdk_device)
+ return;
+
+ switch (gdk_device->source) {
+ case GDK_SOURCE_PEN:
+ case GDK_SOURCE_ERASER:
+ *type = TabletDeviceTypeStylus;
+ break;
+ case GDK_SOURCE_MOUSE:
+ case GDK_SOURCE_CURSOR: /* XXX not sure where to lump this in.. in the stylus block? */
+ default:
+ *type = TabletDeviceTypeMouse;
+ break;
+ }
+
+ *is_inverted = (gdk_device->source == GDK_SOURCE_ERASER);
+}
+
+class MoonButtonEventGtk : public MoonButtonEvent {
+public:
+ MoonButtonEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventButton*)gdk_event_copy (event);
+ }
+
+ virtual ~MoonButtonEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent* Clone ()
+ {
+ return new MoonButtonEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent ()
+ {
+ return event;
+ }
+
+ virtual Point GetPosition ()
+ {
+ return Point (event->x, event->y);
+ }
+
+ virtual double GetPressure ()
+ {
+ double pressure = 0.0;
+ if (!event->device || !gdk_event_get_axis ((GdkEvent*)event, GDK_AXIS_PRESSURE, &pressure))
+ pressure = 0.0;
+ return pressure;
+ }
+
+ virtual void GetStylusInfo (TabletDeviceType *type, bool *is_inverted)
+ {
+ GetStylusInfoFromDevice (event->device, type, is_inverted);
+ }
+
+ virtual MoonModifier GetModifiers ()
+ {
+ g_assert_not_reached ();
+ }
+
+ bool IsRelease ()
+ {
+ return event->type == GDK_BUTTON_RELEASE;
+ }
+
+ int GetButton ()
+ {
+ return event->button;
+ }
+
+ // the number of clicks. gdk provides them as event->type ==
+ // GDK_3BUTTON_PRESS/GDK_2BUTTON_PRESS/GDK_BUTTON_PRESS
+ virtual int GetNumberOfClicks ()
+ {
+ switch (event->type) {
+ case GDK_BUTTON_PRESS: return 1;
+ case GDK_2BUTTON_PRESS: return 2;
+ case GDK_3BUTTON_PRESS: return 3;
+ default: return 0;
+ }
+ }
+
+private:
+ GdkEventButton *event;
+};
+
+
+class MoonMotionEventGtk : public MoonMotionEvent {
+public:
+ MoonMotionEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventMotion*)gdk_event_copy (event);
+ }
+
+ virtual ~MoonMotionEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent* Clone ()
+ {
+ return new MoonMotionEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent ()
+ {
+ return event;
+ }
+
+ virtual Point GetPosition ()
+ {
+ return Point (event->x, event->y);
+ }
+
+ virtual double GetPressure ()
+ {
+ double pressure = 0.0;
+ if (!event->device || !gdk_event_get_axis ((GdkEvent*)event, GDK_AXIS_PRESSURE, &pressure))
+ pressure = 0.0;
+ return pressure;
+ }
+
+ virtual void GetStylusInfo (TabletDeviceType *type, bool *is_inverted)
+ {
+ GetStylusInfoFromDevice (event->device, type, is_inverted);
+ }
+
+ virtual MoonModifier GetModifiers ()
+ {
+ g_assert_not_reached ();
+ }
+
+private:
+ GdkEventMotion *event;
+};
+
+class MoonCrossingEventGtk : public MoonCrossingEvent {
+public:
+ MoonCrossingEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventCrossing*)gdk_event_copy (event);
+ }
+
+ virtual ~MoonCrossingEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent* Clone ()
+ {
+ return new MoonCrossingEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent ()
+ {
+ return event;
+ }
+
+ virtual Point GetPosition ()
+ {
+ return Point (event->x, event->y);
+ }
+
+ virtual double GetPressure ()
+ {
+ return 0.0;
+ }
+
+ virtual void GetStylusInfo (TabletDeviceType *type, bool *is_inverted)
+ {
+ }
+
+ virtual MoonModifier GetModifiers ()
+ {
+ g_assert_not_reached ();
+ }
+
+ virtual bool IsEnter ()
+ {
+ return event->type == GDK_ENTER_NOTIFY;
+ }
+
+private:
+ GdkEventCrossing *event;
+};
+
+class MoonFocusEventGtk : public MoonFocusEvent {
+public:
+ MoonFocusEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventFocus*)gdk_event_copy (event);
+ }
+
+ virtual ~MoonFocusEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent *Clone ()
+ {
+ return new MoonFocusEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent()
+ {
+ return event;
+ }
+
+ virtual bool IsIn ()
+ {
+ return event->in != 0;
+ }
+
+private:
+ GdkEventFocus *event;
+};
+
+class MoonScrollWheelEventGtk : public MoonScrollWheelEvent {
+public:
+ MoonScrollWheelEventGtk (GdkEvent *event)
+ {
+ this->event = (GdkEventScroll*)gdk_event_copy (event);
+ }
+
+ virtual ~MoonScrollWheelEventGtk ()
+ {
+ gdk_event_free ((GdkEvent*)event);
+ }
+
+ virtual MoonEvent* Clone ()
+ {
+ return new MoonScrollWheelEventGtk ((GdkEvent*)event);
+ }
+
+ virtual gpointer GetPlatformEvent ()
+ {
+ return event;
+ }
+
+ virtual Point GetPosition ()
+ {
+ return Point (event->x, event->y);
+ }
+
+ virtual double GetPressure ()
+ {
+ double pressure = 0.0;
+ if (!event->device || !gdk_event_get_axis ((GdkEvent*)event, GDK_AXIS_PRESSURE, &pressure))
+ pressure = 0.0;
+ return pressure;
+ }
+
+ virtual void GetStylusInfo (TabletDeviceType *type, bool *is_inverted)
+ {
+ GetStylusInfoFromDevice (event->device, type, is_inverted);
+ }
+
+ virtual MoonModifier GetModifiers ()
+ {
+ g_assert_not_reached ();
+ }
+
+#define MOON_SCROLL_WHEEL_DELTA 10
+
+ virtual int GetWheelDelta ()
+ {
+ /* we only handle UP/DOWN scroll events for the time being */
+ switch (event->direction) {
+ case GDK_SCROLL_UP:
+ return MOON_SCROLL_WHEEL_DELTA;
+ case GDK_SCROLL_DOWN:
+ return -MOON_SCROLL_WHEEL_DELTA;
+
+ default:
+ case GDK_SCROLL_LEFT:
+ case GDK_SCROLL_RIGHT:
+ return 0;
+ }
+ }
+
+private:
+ GdkEventScroll *event;
+};
+
+/// our windowing system
+
+MoonWindowingSystemGtk::MoonWindowingSystemGtk ()
+{
+ if (!(moonlight_flags & RUNTIME_INIT_USE_BACKEND_IMAGE) && RunningOnNvidia ()) {
+ printf ("Moonlight: Forcing client-side rendering because we detected binary drivers which are known to suffer performance problems.\n");
+ moonlight_flags |= RUNTIME_INIT_USE_BACKEND_IMAGE;
+ }
+}
+
+MoonWindowingSystemGtk::~MoonWindowingSystemGtk ()
+{
+}
+
+
+cairo_surface_t *
+MoonWindowingSystemGtk::CreateSurface ()
+{
+ // FIXME...
+ g_assert_not_reached ();
+}
+
+MoonWindow *
+MoonWindowingSystemGtk::CreateWindow (bool fullscreen, int width, int height, MoonWindow *parentWindow, Surface *surface)
+{
+ MoonWindowGtk *gtkwindow = new MoonWindowGtk (fullscreen, width, height, parentWindow, surface);
+ RegisterWindow (gtkwindow);
+ return gtkwindow;
+}
+
+MoonWindow *
+MoonWindowingSystemGtk::CreateWindowless (int width, int height, PluginInstance *forPlugin)
+{
+ MoonWindowGtk *gtkwindow = (MoonWindowGtk*)MoonWindowingSystem::CreateWindowless (width, height, forPlugin);
+ if (gtkwindow)
+ RegisterWindow (gtkwindow);
+ return gtkwindow;
+}
+
+// older gtk+ (like 2.8 used in SLED10) don't support icon-less GTK_MESSAGE_OTHER
+#ifndef GTK_MESSAGE_OTHER
+#define GTK_MESSAGE_OTHER GTK_MESSAGE_INFO
+#endif
+
+int
+MoonWindowingSystemGtk::ShowMessageBox (const char *caption, const char *text, int buttons)
+{
+ if (!caption || !text)
+ return MESSAGE_BOX_RESULT_NONE;
+
+ // NOTE: this dialog is displayed even WITHOUT any user action
+ //if (!Deployment::GetCurrent ()->GetSurface ()->IsUserInitiatedEvent ())
+ // return MESSAGE_BOX_RESULT_NONE;
+
+ GtkButtonsType bt = buttons == MESSAGE_BOX_BUTTON_OK ? GTK_BUTTONS_OK : GTK_BUTTONS_OK_CANCEL;
+
+ GtkWidget *widget = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_OTHER,
+ bt,
+ text);
+
+ gtk_window_set_title (GTK_WINDOW (widget), caption);
+
+ gint result = gtk_dialog_run (GTK_DIALOG (widget));
+ gtk_widget_destroy (widget);
+
+ switch (result) {
+ case GTK_RESPONSE_OK:
+ return MESSAGE_BOX_RESULT_OK;
+ case GTK_RESPONSE_CANCEL:
+ return MESSAGE_BOX_RESULT_CANCEL;
+ case GTK_RESPONSE_YES:
+ return MESSAGE_BOX_RESULT_YES;
+ case GTK_RESPONSE_NO:
+ return MESSAGE_BOX_RESULT_NO;
+ case GTK_RESPONSE_NONE:
+ default:
+ return MESSAGE_BOX_RESULT_NONE;
+ }
+}
+
+static void
+set_filters (GtkFileChooser *chooser, const char* filter, int idx)
+{
+ if (!filter || (strlen (filter) <= 1))
+ return;
+
+ char **filters = g_strsplit (filter, "|", 0);
+
+ // to be valid (managed code) we know we have an even number of items
+ // (if not we're still safe by dropping the last one)
+ int pos = 0;
+ int n = g_strv_length (filters) >> 1;
+ for (int i=0; i < n; i++) {
+ char *name = g_strstrip (filters[pos++]);
+ if (strlen (name) < 1)
+ continue;
+
+ char *pattern = g_strstrip (filters[pos++]);
+ if (strlen (pattern) < 1)
+ continue;
+
+ GtkFileFilter *ff = gtk_file_filter_new ();
+ gtk_file_filter_set_name (ff, g_strdup (name));
+ // there can be multiple patterns in a single string
+ if (g_strrstr (pattern, ";")) {
+ int n = 0;
+ char **patterns = g_strsplit (pattern, ";", 0);
+ while (char *p = patterns[n++])
+ gtk_file_filter_add_pattern (ff, g_strdup (p));
+ g_strfreev (patterns);
+ } else {
+ // or a single one
+ gtk_file_filter_add_pattern (ff, g_strdup (pattern));
+ }
+ gtk_file_chooser_add_filter (chooser, ff);
+ // idx (FilterIndex) is 1 (not 0) based
+ if (i == (idx - 1))
+ gtk_file_chooser_set_filter (chooser, ff);
+ }
+ g_strfreev (filters);
+}
+
+char**
+MoonWindowingSystemGtk::ShowOpenFileDialog (const char *title, bool multsel, const char *filter, int idx)
+{
+ GtkWidget *widget = gtk_file_chooser_dialog_new (title, NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
+ set_filters (chooser, filter, idx);
+ gtk_file_chooser_set_select_multiple (chooser, multsel ? TRUE : FALSE);
+
+ gchar **ret = NULL;
+ if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_ACCEPT){
+ GSList *k, *l = gtk_file_chooser_get_filenames (chooser);
+ int i, count = g_slist_length (l);
+
+ ret = g_new (gchar *, count + 1);
+ ret [count] = NULL;
+
+ for (i = 0, k = l; k; k = k->next)
+ ret [i++] = (gchar *) k->data;
+
+ g_slist_free (l);
+ }
+
+ gtk_widget_destroy (widget);
+
+ return ret;
+}
+
+char*
+MoonWindowingSystemGtk::ShowSaveFileDialog (const char *title, const char *filter, int idx)
+{
+ GtkWidget *widget = gtk_file_chooser_dialog_new (title, NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
+
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
+ set_filters (chooser, filter, idx);
+ gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
+
+ char* ret = NULL;
+ if (gtk_dialog_run (GTK_DIALOG (widget)) == GTK_RESPONSE_ACCEPT)
+ ret = gtk_file_chooser_get_filename (chooser);
+
+ gtk_widget_destroy (widget);
+
+ return ret;
+}
+
+void
+MoonWindowingSystemGtk::RegisterWindow (MoonWindow *window)
+{
+}
+
+void
+MoonWindowingSystemGtk::UnregisterWindow (MoonWindow *window)
+{
+}
+
+guint
+MoonWindowingSystemGtk::AddTimeout (gint priority, gint ms, MoonSourceFunc timeout, gpointer data)
+{
+ return g_timeout_add_full (priority, ms, (GSourceFunc)timeout, data, NULL);
+}
+
+void
+MoonWindowingSystemGtk::RemoveTimeout (guint timeoutId)
+{
+ g_source_remove (timeoutId);
+}
+
+MoonIMContext*
+MoonWindowingSystemGtk::CreateIMContext ()
+{
+ return new MoonIMContextGtk ();
+}
+
+MoonEvent*
+MoonWindowingSystemGtk::CreateEventFromPlatformEvent (gpointer platformEvent)
+{
+ GdkEvent *gdk = (GdkEvent*)platformEvent;
+
+ switch (gdk->type) {
+ case GDK_MOTION_NOTIFY: {
+ GdkEventMotion *mev = (GdkEventMotion*)gdk;
+ if (mev->is_hint) {
+#if GTK_CHECK_VERSION(2,12,0)
+ if (gtk_check_version (2, 12, 0)) {
+ gdk_event_request_motions (mev);
+ }
+ else
+#endif
+ {
+ int ix, iy;
+ GdkModifierType state;
+ gdk_window_get_pointer (mev->window, &ix, &iy, (GdkModifierType*)&state);
+ mev->x = ix;
+ mev->y = iy;
+ }
+ }
+
+ return new MoonMotionEventGtk (gdk);
+ }
+ case GDK_BUTTON_PRESS:
+ case GDK_2BUTTON_PRESS:
+ case GDK_3BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
+ return new MoonButtonEventGtk (gdk);
+
+ case GDK_KEY_PRESS:
+ case GDK_KEY_RELEASE:
+ return new MoonKeyEventGtk (gdk);
+
+ case GDK_ENTER_NOTIFY:
+ case GDK_LEAVE_NOTIFY:
+ return new MoonCrossingEventGtk (gdk);
+
+ case GDK_FOCUS_CHANGE:
+ return new MoonFocusEventGtk (gdk);
+
+ case GDK_SCROLL:
+ return new MoonScrollWheelEventGtk (gdk);
+ default:
+ printf ("unhandled gtk event %d\n", gdk->type);
+ return NULL;
+ }
+}
+
+guint
+MoonWindowingSystemGtk::GetCursorBlinkTimeout (MoonWindow *window)
+{
+ GdkScreen *screen;
+ GtkWidget *widget;
+ GtkSettings *settings;
+ guint timeout;
+
+ if (!(widget = GTK_WIDGET (window->GetPlatformWindow ())))
+ return CURSOR_BLINK_TIMEOUT_DEFAULT;
+
+ if (!(screen = gdk_drawable_get_screen (widget->window)))
+ return CURSOR_BLINK_TIMEOUT_DEFAULT;
+
+ if (!(settings = gtk_settings_get_for_screen (screen)))
+ return CURSOR_BLINK_TIMEOUT_DEFAULT;
+
+ g_object_get (settings, "gtk-cursor-blink-time", &timeout, NULL);
+
+ return timeout;
+}
+
+
+MoonPixbufLoader*
+MoonWindowingSystemGtk::CreatePixbufLoader (const char *imageType)
+{
+ if (imageType)
+ return new MoonPixbufLoaderGtk (imageType);
+ else
+ return new MoonPixbufLoaderGtk ();
+}
+
+bool
+MoonWindowingSystemGtk::RunningOnNvidia ()
+{
+ int event, error, opcode;
+
+ Display *display = XOpenDisplay (NULL);
+ bool result = XQueryExtension (display, "NV-GLX", &opcode, &event, &error);
+ XCloseDisplay (display);
+
+ return result;
+}
Added: trunk/moon/src/pal/gtk/pal-gtk.h
===================================================================
--- trunk/moon/src/pal/gtk/pal-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/pal-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef MOON_PAL_GTK_H
+#define MOON_PAL_GTK_H
+
+#include "pal.h"
+
+class MoonWindowingSystemGtk : public MoonWindowingSystem {
+public:
+ MoonWindowingSystemGtk ();
+ virtual ~MoonWindowingSystemGtk ();
+
+ // creates a platform/windowing system specific surface
+ virtual cairo_surface_t *CreateSurface ();
+
+ MoonWindow *CreateWindow (bool fullscreen, int width, int height, MoonWindow *parentWindow, Surface *surface);
+ MoonWindow *CreateWindowless (int width, int height, PluginInstance *forPlugin);
+
+ virtual int ShowMessageBox (const char *caption, const char *text, int buttons);
+
+ virtual gchar** ShowOpenFileDialog (const char *title, bool multsel, const char *filter, int idx);
+ virtual char* ShowSaveFileDialog (const char *title, const char *filter, int idx);
+
+ virtual guint AddTimeout (gint priority, gint ms, MoonSourceFunc timeout, gpointer data);
+ virtual void RemoveTimeout (guint timeoutId);
+
+ virtual MoonIMContext* CreateIMContext ();
+
+ virtual MoonEvent* CreateEventFromPlatformEvent (gpointer platformEvent);
+
+ virtual guint GetCursorBlinkTimeout (MoonWindow *window);
+
+ virtual MoonPixbufLoader* CreatePixbufLoader (const char *imageType);
+
+
+ void UnregisterWindow (MoonWindow *window);
+
+private:
+ void RegisterWindow (MoonWindow *window);
+
+ bool RunningOnNvidia ();
+};
+
+#endif
Added: trunk/moon/src/pal/gtk/pixbuf-gtk.cpp
===================================================================
--- trunk/moon/src/pal/gtk/pixbuf-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/pixbuf-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include "pal-gtk.h"
+
+#include "runtime.h"
+
+#include "pixbuf-gtk.h"
+
+MoonPixbufLoaderGtk::MoonPixbufLoaderGtk (const char *imageType)
+{
+ gdk_loader = gdk_pixbuf_loader_new_with_type (imageType, NULL);
+}
+
+MoonPixbufLoaderGtk::MoonPixbufLoaderGtk ()
+{
+ gdk_loader = gdk_pixbuf_loader_new ();
+}
+
+MoonPixbufLoaderGtk::~MoonPixbufLoaderGtk ()
+{
+ g_object_unref (gdk_loader);
+}
+
+void
+MoonPixbufLoaderGtk::Write (const guchar *buffer, int buflen, MoonError **error)
+{
+ GError *gerror = NULL;
+
+ gdk_pixbuf_loader_write (gdk_loader, buffer, buflen, &gerror);
+
+ if (gerror && error)
+ *error = new MoonError (MoonError::EXCEPTION, 4001, gerror->message);
+}
+
+void
+MoonPixbufLoaderGtk::Close (MoonError **error)
+{
+ GError *gerror = NULL;
+
+ gdk_pixbuf_loader_close (gdk_loader, &gerror);
+
+ if (gerror && error)
+ *error = new MoonError (MoonError::EXCEPTION, 4001, gerror->message);
+}
+
+MoonPixbuf*
+MoonPixbufLoaderGtk::GetPixbuf ()
+{
+ GdkPixbuf *gdk_pixbuf = gdk_pixbuf_loader_get_pixbuf (gdk_loader);
+ return new MoonPixbufGtk (gdk_pixbuf); // we pass off the ref here, so don't unref
+}
+
+
+MoonPixbufGtk::MoonPixbufGtk (GdkPixbuf *pixbuf)
+{
+ gdk_pixbuf = pixbuf;
+}
+
+MoonPixbufGtk::~MoonPixbufGtk ()
+{
+ g_object_unref (gdk_pixbuf);
+}
+
+gint
+MoonPixbufGtk::GetWidth ()
+{
+ return gdk_pixbuf_get_width (gdk_pixbuf);
+}
+
+gint
+MoonPixbufGtk::GetHeight ()
+{
+ return gdk_pixbuf_get_height (gdk_pixbuf);
+}
+
+gint
+MoonPixbufGtk::GetRowStride ()
+{
+ return gdk_pixbuf_get_rowstride (gdk_pixbuf);
+}
+
+gint
+MoonPixbufGtk::GetNumChannels ()
+{
+ return gdk_pixbuf_get_n_channels (gdk_pixbuf);
+}
+
+guchar*
+MoonPixbufGtk::GetPixels ()
+{
+ return gdk_pixbuf_get_pixels (gdk_pixbuf);
+}
+
Added: trunk/moon/src/pal/gtk/pixbuf-gtk.h
===================================================================
--- trunk/moon/src/pal/gtk/pixbuf-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/pixbuf-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef MOON_PIXBUF_GTK_H
+#define MOON_PIXBUF_GTK_H
+
+#include "pal.h"
+
+class MoonPixbufGtk : public MoonPixbuf {
+public:
+ MoonPixbufGtk (GdkPixbuf *pixbuf);
+ ~MoonPixbufGtk ();
+
+ virtual gint GetWidth ();
+ virtual gint GetHeight ();
+ virtual gint GetRowStride ();
+ virtual gint GetNumChannels ();
+ virtual guchar *GetPixels ();
+
+private:
+ GdkPixbuf *gdk_pixbuf;
+};
+
+class MoonPixbufLoaderGtk : public MoonPixbufLoader {
+public:
+ MoonPixbufLoaderGtk (const char *imageType);
+ MoonPixbufLoaderGtk ();
+ ~MoonPixbufLoaderGtk ();
+
+ virtual void Write (const guchar *buffer, int buflen, MoonError **error);
+ virtual void Close (MoonError **error);
+ virtual MoonPixbuf *GetPixbuf ();
+
+private:
+ GdkPixbufLoader *gdk_loader;
+};
+
+#endif /* MOON_PIXBUF_GTK_H */
Copied: trunk/moon/src/pal/gtk/window-gtk.cpp (from rev 149147, trunk/moon/src/window-gtk.cpp)
===================================================================
--- trunk/moon/src/pal/gtk/window-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/window-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,773 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * window-gtk.cpp: MoonWindow implementation using gtk widgets.
+ *
+ * Contact:
+ * Moonlight List (moonlig...@lists.ximian.com)
+ *
+ * Copyright 2007-2008 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#include "window-gtk.h"
+#include "clipboard-gtk.h"
+#include "deployment.h"
+#include "timemanager.h"
+
+#define Visual _XxVisual
+#define Region _XxRegion
+#include <gdk/gdkx.h>
+#include <cairo-xlib.h>
+#undef Visual
+#undef Region
+
+MoonWindowGtk::MoonWindowGtk (bool fullscreen, int w, int h, MoonWindow *parent, Surface *surface)
+ : MoonWindow (fullscreen, w, h, parent, surface)
+{
+ this->deployment = Deployment::GetCurrent ();
+ this->fullscreen = fullscreen;
+
+ if (IsFullScreen())
+ InitializeFullScreen(parent);
+ else
+ InitializeNormal();
+}
+
+MoonWindowGtk::~MoonWindowGtk ()
+{
+ /* gtk_widget_destroy can cause reentry (into another plugin if this destruction causes layout changes) */
+ DeploymentStack deployment_push_pop;
+ DisableEvents ();
+ if (widget != NULL)
+ gtk_widget_destroy (widget);
+}
+
+MoonClipboard*
+MoonWindowGtk::GetClipboard (MoonClipboardType clipboardType)
+{
+ return new MoonClipboardGtk (this, clipboardType);
+}
+
+gpointer
+MoonWindowGtk::GetPlatformWindow ()
+{
+ GtkWidget *w = widget;
+ while (w->parent)
+ w = w->parent;
+
+ return w;
+}
+
+void
+MoonWindowGtk::InitializeFullScreen (MoonWindow *parent)
+{
+ widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ // only fullscreen on the monitor the plugin is on
+ GdkWindow *gdk = GDK_WINDOW (parent->GetPlatformWindow ());
+ int monitor = gdk_screen_get_monitor_at_window (gdk_screen_get_default (), gdk);
+ GdkRectangle bounds;
+ gdk_screen_get_monitor_geometry (gdk_screen_get_default (), monitor, &bounds);
+ width = bounds.width;
+ height = bounds.height;
+ gtk_window_move (GTK_WINDOW (widget), bounds.x, bounds.y);
+
+ gtk_window_fullscreen (GTK_WINDOW (widget));
+
+ InitializeCommon ();
+
+ Show();
+
+ g_object_unref (gdk);
+}
+
+void
+MoonWindowGtk::InitializeNormal ()
+{
+ if (width == -1 || height == -1) {
+ g_warning ("you must specify width and height when creating a non-fullscreen gtk window");
+ width = 0;
+ height = 0;
+ }
+
+ widget = gtk_event_box_new ();
+
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (widget), false);
+
+ InitializeCommon ();
+
+ Show ();
+}
+
+void
+MoonWindowGtk::InitializeCommon ()
+{
+ // don't let gtk clear the window we'll do all the drawing.
+ //gtk_widget_set_app_paintable (widget, true);
+ gtk_widget_set_double_buffered (widget, false);
+ gtk_widget_set_size_request (widget, width, height);
+
+ g_signal_connect (widget, "size-allocate", G_CALLBACK (widget_size_allocate), this);
+ g_signal_connect (widget, "destroy", G_CALLBACK (widget_destroyed), this);
+
+ gtk_widget_add_events (widget,
+ GDK_POINTER_MOTION_MASK |
+#if !DEBUG
+ GDK_POINTER_MOTION_HINT_MASK |
+#endif
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ ((moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) != 0 ? GDK_SCROLL_MASK : 0) |
+ GDK_FOCUS_CHANGE_MASK);
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+}
+
+void
+MoonWindowGtk::Resize (int width, int height)
+{
+ gtk_widget_set_size_request (widget, width, height);
+ gtk_widget_queue_resize (widget);
+}
+
+/* XPM */
+static const char *dot[] = {
+ "18 18 4 1",
+ " c None",
+ ". c #808080",
+ "+ c #303030",
+ "@ c #000000",
+ ".+. ",
+ "@@@ ",
+ ".@. ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " "
+};
+
+/* XPM */
+static const char *eraser[] = {
+ "20 20 49 1",
+ " c None",
+ ". c #000000",
+ "+ c #858585",
+ "@ c #E8E8E8",
+ "# c #E9E9E9",
+ "$ c #E7E7E7",
+ "% c #E2E2E2",
+ "& c #D6D6D6",
+ "* c #7D7D7D",
+ "= c #565656",
+ "- c #E1E1E1",
+ "; c #E0E0E0",
+ "> c #DEDEDE",
+ ", c #DFDFDF",
+ "' c #474747",
+ ") c #6C6C6C",
+ "! c #B0B0B0",
+ "~ c #E3E3E3",
+ "{ c #4E4E4E",
+ "] c #636363",
+ "^ c #E6E6E6",
+ "/ c #505050",
+ "( c #4A4A4A",
+ "_ c #C7C7C7",
+ ": c #272727",
+ "< c #797979",
+ "[ c #E5E5E5",
+ "} c #DDDDDD",
+ "| c #9C9C9C",
+ "1 c #232323",
+ "2 c #E4E4E4",
+ "3 c #656565",
+ "4 c #313131",
+ "5 c #EAEAEA",
+ "6 c #ECECEC",
+ "7 c #EEEEEE",
+ "8 c #EFEFEF",
+ "9 c #F0F0F0",
+ "0 c #999999",
+ "a c #5D5D5D",
+ "b c #343434",
+ "c c #757575",
+ "d c #383838",
+ "e c #CECECE",
+ "f c #A9A9A9",
+ "g c #6F6F6F",
+ "h c #B3B3B3",
+ "i c #787878",
+ "j c #3F3F3F",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ........... ",
+ " .+@#@@@$$%&*. ",
+ " =-;%>>>>>>>,' ",
+ " )!~>>>>>>>>>>{ ",
+ " ]^>>>>>>>>>,,/ ",
+ " (_;>>>>>>>>,>&: ",
+ " <[,}>>>>>>>-,| ",
+ " 1[-;>>>>>>>$2,3 ",
+ " 45678999998550a ",
+ " b~,,,,,,,,,;$c ",
+ " de-,,,,,,,,,fg ",
+ " bh%%,,;}}}>>ij ",
+ " ............ ",
+ " "
+};
+
+void
+MoonWindowGtk::SetBackgroundColor (Color *color)
+{
+ GdkColor gdk_color;
+ gdk_color.red = color->r * 0xffff;
+ gdk_color.green = color->g * 0xffff;
+ gdk_color.blue = color->b * 0xffff;
+
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &gdk_color);
+
+ MoonWindow::SetBackgroundColor (color);
+}
+
+void
+MoonWindowGtk::SetCursor (MouseCursor cursor)
+{
+ if (widget->window) {
+
+ GdkCursor *c = NULL;
+ switch (cursor) {
+ case MouseCursorDefault:
+ c = NULL;
+ break;
+ case MouseCursorArrow:
+ c = gdk_cursor_new (GDK_LEFT_PTR);
+ break;
+ case MouseCursorHand:
+ c = gdk_cursor_new (GDK_HAND2);
+ break;
+ case MouseCursorWait:
+ c = gdk_cursor_new (GDK_WATCH);
+ break;
+ case MouseCursorIBeam:
+ c = gdk_cursor_new (GDK_XTERM);
+ break;
+ case MouseCursorStylus:
+ c = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), gdk_pixbuf_new_from_xpm_data ((const char**) dot), 0, 0);
+ break;
+ case MouseCursorEraser:
+ c = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), gdk_pixbuf_new_from_xpm_data ((const char**) eraser), 8, 8);
+ break;
+ case MouseCursorSizeNS:
+ c = gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW);
+ break;
+ case MouseCursorSizeWE:
+ c = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
+ break;
+ case MouseCursorNone:
+ // Silverlight display no cursor if the enumeration value is invalid (e.g. -1)
+ default:
+ //from gdk-cursor doc :"To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create a cursor with no pixels in it."
+ GdkPixmap *empty = gdk_bitmap_create_from_data (NULL, "0x00", 1, 1);
+ GdkColor empty_color = {0, 0, 0, 0};
+ c = gdk_cursor_new_from_pixmap (empty, empty, &empty_color, &empty_color, 0, 0);
+ g_object_unref (empty);
+ break;
+ }
+
+
+ gdk_window_set_cursor (widget->window, c);
+
+ if (c)
+ gdk_cursor_unref (c);
+ }
+}
+
+void
+MoonWindowGtk::Invalidate (Rect r)
+{
+ gtk_widget_queue_draw_area (widget,
+ (int) (widget->allocation.x + r.x),
+ (int) (widget->allocation.y + r.y),
+ (int) r.width, (int)r.height);
+}
+
+void
+MoonWindowGtk::ProcessUpdates ()
+{
+ if (widget->window)
+ gdk_window_process_updates (widget->window, false);
+}
+
+gboolean
+MoonWindowGtk::HandleEvent (gpointer platformEvent)
+{
+ // nothing to do here, since we don't pump events into the gtk
+ // window, gtk calls our signal handlers directly.
+ return TRUE;
+}
+
+void
+MoonWindowGtk::Show ()
+{
+ gtk_widget_show (widget);
+
+ // The window has to be realized for this call to work
+ gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_CURSOR);
+ /* we need to explicitly enable the devices */
+ for (GList *l = gdk_devices_list(); l; l = l->next) {
+#if THIS_NOLONGER_BREAKS_LARRYS_MOUSE
+ GdkDevice *device = GDK_DEVICE(l->data);
+ //if (!device->has_cursor)
+ gdk_device_set_mode (device, GDK_MODE_SCREEN);
+#endif
+ }
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+}
+
+void
+MoonWindowGtk::Hide ()
+{
+ gtk_widget_hide (widget);
+}
+
+void
+MoonWindowGtk::EnableEvents (bool first)
+{
+ g_signal_connect (widget, "motion-notify-event", G_CALLBACK (motion_notify), this);
+ g_signal_connect (widget, "enter-notify-event", G_CALLBACK (crossing_notify), this);
+ g_signal_connect (widget, "leave-notify-event", G_CALLBACK (crossing_notify), this);
+ g_signal_connect (widget, "key-press-event", G_CALLBACK (key_press), this);
+ g_signal_connect (widget, "key-release-event", G_CALLBACK (key_release), this);
+ g_signal_connect (widget, "button-press-event", G_CALLBACK (button_press), this);
+ g_signal_connect (widget, "button-release-event", G_CALLBACK (button_release), this);
+ g_signal_connect (widget, "scroll-event", G_CALLBACK (scroll), this);
+ g_signal_connect (widget, "focus-in-event", G_CALLBACK (focus_in), this);
+ g_signal_connect (widget, "focus-out-event", G_CALLBACK (focus_out), this);
+
+ g_signal_connect (widget, "expose-event", G_CALLBACK (expose_event), this);
+ if (first) {
+ g_signal_connect (widget, "realize", G_CALLBACK (realized), this);
+ g_signal_connect (widget, "unrealize", G_CALLBACK (unrealized), this);
+
+ if (GTK_WIDGET_REALIZED (widget))
+ realized (widget, this);
+ }
+}
+
+void
+MoonWindowGtk::DisableEvents ()
+{
+ g_signal_handlers_disconnect_matched (widget, G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL, this);
+}
+
+void
+MoonWindowGtk::GrabFocus ()
+{
+ gtk_widget_grab_focus (widget);
+}
+
+bool
+MoonWindowGtk::HasFocus ()
+{
+ return GTK_WIDGET_HAS_FOCUS (widget);
+}
+
+gboolean
+MoonWindowGtk::expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)data;
+
+ window->SetCurrentDeployment ();
+
+ if (!window->surface)
+ return true;
+
+ // we draw to a backbuffer pixmap, then transfer the contents
+ // to the widget's window.
+ GdkPixmap *pixmap = gdk_pixmap_new (widget->window,
+ MAX (event->area.width, 1), MAX (event->area.height, 1), -1);
+
+ window->PaintToDrawable (pixmap,
+ gdk_drawable_get_visual (widget->window),
+ event,
+ widget->allocation.x,
+ widget->allocation.y,
+ window->GetTransparent (),
+ true);
+
+ GdkGC *gc = gdk_gc_new (pixmap);
+
+ gdk_gc_set_clip_region (gc, event->region);
+
+ gdk_draw_drawable (widget->window, gc, pixmap,
+ 0, 0,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height);
+
+ g_object_unref (pixmap);
+ g_object_unref (gc);
+
+ return true;
+}
+
+gboolean
+MoonWindowGtk::button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)data;
+
+ window->SetCurrentDeployment ();
+
+ if (event->button != 1 && event->button != 3)
+ return false;
+
+ if (window->surface) {
+ MoonButtonEvent *mevent = (MoonButtonEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIButtonPress (mevent);
+ delete mevent;
+ }
+
+ // If we don't support right clicks (i.e. inside the browser)
+ // return false here
+ if (event->button == 3 && (moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) == 0)
+ return false;
+
+ // ignore HandleUIButtonPress's return value, and always
+ // return true here, or it gets bubbled up to firefox.
+ return true;
+}
+
+gboolean
+MoonWindowGtk::button_release (GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonButtonEvent *mevent = (MoonButtonEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIButtonRelease (mevent);
+ delete mevent;
+ }
+ // ignore HandleUIButtonRelease's return value, and always
+ // return true here, or it gets bubbled up to firefox.
+ return true;
+}
+
+gboolean
+MoonWindowGtk::scroll (GtkWidget *widget, GdkEventScroll *event, gpointer data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonScrollWheelEvent *mevent = (MoonScrollWheelEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIScroll (mevent);
+ delete mevent;
+ }
+ // ignore HandleUIScroll's return value, and always
+ // return true here, or it gets bubbled up to firefox.
+ return true;
+}
+
+gboolean
+MoonWindowGtk::motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonMotionEvent *mevent = (MoonMotionEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIMotion (mevent);
+ delete mevent;
+ }
+ // ignore HandleUIMotion's return value, and always
+ // return true here, or it gets bubbled up to firefox.
+ return true;
+}
+
+gboolean
+MoonWindowGtk::crossing_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonCrossingEvent *mevent = (MoonCrossingEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUICrossing (mevent);
+ delete mevent;
+ return true;
+ }
+
+ return false;
+}
+
+gboolean
+MoonWindowGtk::focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonFocusEvent *mevent = (MoonFocusEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIFocusIn (mevent);
+ delete mevent;
+ return true;
+ }
+
+ return false;
+}
+
+gboolean
+MoonWindowGtk::focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonFocusEvent *mevent = (MoonFocusEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIFocusOut (mevent);
+ delete mevent;
+ return true;
+ }
+
+ return false;
+}
+
+gboolean
+MoonWindowGtk::key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonKeyEvent *mevent = (MoonKeyEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIKeyPress (mevent);
+ delete mevent;
+ return true;
+ }
+
+ return false;
+}
+
+gboolean
+MoonWindowGtk::key_release (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ MoonKeyEvent *mevent = (MoonKeyEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (event);
+ window->surface->HandleUIKeyRelease (mevent);
+ delete mevent;
+ return true;
+ }
+
+ return false;
+}
+
+void
+MoonWindowGtk::widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
+{
+ MoonWindowGtk *window = (MoonWindowGtk*)data;
+
+ window->SetCurrentDeployment ();
+
+ //printf ("Surface::size-allocate callback: current = %dx%d; new = %dx%d\n",
+ // s->width, s->height, allocation->width, allocation->height);
+
+ bool emit_resize = false;
+
+ if (window->width != allocation->width || window->height != allocation->height) {
+ window->width = allocation->width;
+ window->height = allocation->height;
+
+ emit_resize = true;
+ }
+
+ if (window->surface)
+ window->surface->HandleUIWindowAllocation (emit_resize);
+}
+
+void
+MoonWindowGtk::widget_destroyed (GtkWidget *widget, gpointer user_data)
+{
+ MoonWindowGtk* window = (MoonWindowGtk*)user_data;
+
+ window->widget = NULL;
+ if (window->surface)
+ window->surface->HandleUIWindowDestroyed (window);
+}
+
+gboolean
+MoonWindowGtk::realized (GtkWidget *widget, gpointer user_data)
+{
+ MoonWindowGtk* window = (MoonWindowGtk*)user_data;
+
+#ifdef USE_XRANDR
+#if INTEL_DRIVERS_STOP_SUCKING
+ // apparently the i965 drivers blank external screens when
+ // getting the screen info (um, ugh?). needless to say, this
+ // annoyance is worse than not using the monitor's refresh as
+ // the upper bound for our fps.
+ //
+ // http://lists.freedesktop.org/archives/xorg/2007-August/027616.html
+ int event_base, error_base;
+ GdkWindow *gdk_root = gtk_widget_get_root_window (widget);
+ Display *dpy = GDK_WINDOW_XDISPLAY(gdk_root);
+ Window root = GDK_WINDOW_XID (gdk_root);
+ if (XRRQueryExtension (dpy, &event_base, &error_base)) {
+ XRRScreenConfiguration *info = XRRGetScreenInfo (dpy,
+ root);
+ short rate = XRRConfigCurrentRate (info);
+ printf ("screen refresh rate = %d\n", rate);
+ if (window->surface)
+ window->surface->GetTimeManager()->SetMaximumRefreshRate (rate);
+ XRRFreeScreenConfigInfo (info);
+ }
+#endif
+#endif
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface) {
+ window->surface->HandleUIWindowUnavailable ();
+ window->surface->HandleUIWindowAvailable ();
+ }
+
+#if SANITY
+ Deployment::SetCurrent (NULL);
+#endif
+
+ return true;
+}
+
+gboolean
+MoonWindowGtk::unrealized (GtkWidget *widget, gpointer user_data)
+{
+ MoonWindowGtk* window = (MoonWindowGtk*)user_data;
+
+ window->SetCurrentDeployment ();
+
+ if (window->surface)
+ window->surface->HandleUIWindowUnavailable ();
+
+#if SANITY
+ Deployment::SetCurrent (NULL);
+#endif
+
+ return true;
+}
+
+static cairo_t *
+runtime_cairo_create (GdkWindow *drawable, GdkVisual *visual, bool native)
+{
+ int width, height;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ gdk_drawable_get_size (drawable, &width, &height);
+
+ if (native)
+ surface = cairo_xlib_surface_create (gdk_x11_drawable_get_xdisplay (drawable),
+ gdk_x11_drawable_get_xid (drawable),
+ GDK_VISUAL_XVISUAL (visual),
+ width, height);
+ else
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
+
+ cr = cairo_create (surface);
+ cairo_surface_destroy (surface);
+
+ return cr;
+}
+
+void
+MoonWindowGtk::PaintToDrawable (GdkDrawable *drawable, GdkVisual *visual, GdkEventExpose *event, int off_x, int off_y, bool transparent, bool clear_transparent)
+{
+// LOG_UI ("Surface::PaintToDrawable (%p, %p, (%d,%d %d,%d), %d, %d, %d, %d)\n",
+// drawable, visual, event->area.x, event->area.y, event->area.width, event->area.height,
+// off_x, off_y, transparent, clear_transparent);
+
+ if (event->area.x > (off_x + GetWidth()) || event->area.y > (off_y + GetHeight()))
+ return;
+
+ SetCurrentDeployment ();
+
+#if 0
+#if TIME_REDRAW
+ STARTTIMER (expose, "redraw");
+#endif
+ if (cache_size_multiplier == -1)
+ cache_size_multiplier = gdk_drawable_get_depth (drawable) / 8 + 1;
+#endif
+#ifdef DEBUG_INVALIDATE
+ printf ("Got a request to repaint at %d %d %d %d\n", event->area.x, event->area.y, event->area.width, event->area.height);
+#endif
+ cairo_t *ctx = runtime_cairo_create (drawable, visual, !(moonlight_flags & RUNTIME_INIT_USE_BACKEND_IMAGE));
+ Region *region = new Region (event->region);
+
+ region->Offset (-off_x, -off_y);
+ cairo_surface_set_device_offset (cairo_get_target (ctx),
+ off_x - event->area.x,
+ off_y - event->area.y);
+
+ surface->Paint (ctx, region, transparent, clear_transparent);
+
+ if (moonlight_flags & RUNTIME_INIT_USE_BACKEND_IMAGE) {
+ cairo_surface_flush (cairo_get_target (ctx));
+ cairo_t *native = runtime_cairo_create (drawable, visual, true);
+
+ cairo_surface_set_device_offset (cairo_get_target (native),
+ 0, 0);
+ cairo_surface_set_device_offset (cairo_get_target (ctx),
+ 0, 0);
+
+ cairo_set_source_surface (native, cairo_get_target (ctx),
+ 0, 0);
+
+ region->Offset (off_x, off_y);
+ region->Offset (-event->area.x, -event->area.y);
+ region->Draw (native);
+
+ cairo_fill (native);
+ cairo_destroy (native);
+ }
+
+ cairo_destroy (ctx);
+
+ delete region;
+
+#if TIME_REDRAW
+ ENDTIMER (expose, "redraw");
+#endif
+
+}
+
Copied: trunk/moon/src/pal/gtk/window-gtk.h (from rev 149147, trunk/moon/src/window-gtk.h)
===================================================================
--- trunk/moon/src/pal/gtk/window-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/window-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * window-gtk.h: MoonWindow implementation using gtk widgets.
+ *
+ * Contact:
+ * Moonlight List (moonlig...@lists.ximian.com)
+ *
+ * Copyright 2007 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#ifndef __MOON_WINDOW_GTK_H__
+#define __MOON_WINDOW_GTK_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "window.h"
+#include "runtime.h"
+
+/* @Namespace=System.Windows */
+class MoonWindowGtk : public MoonWindow {
+public:
+ /* @GenerateCBinding,GeneratePInvoke */
+ MoonWindowGtk (bool fullscreen, int w = -1, int h = -1, MoonWindow* parent = NULL, Surface *surface = NULL);
+
+ virtual ~MoonWindowGtk ();
+
+ virtual void Resize (int width, int height);
+ virtual void SetCursor (MouseCursor cursor);
+ virtual void SetBackgroundColor (Color *color);
+ virtual void Invalidate (Rect r);
+ virtual void ProcessUpdates ();
+ virtual gboolean HandleEvent (gpointer platformEvent);
+ virtual void Show ();
+ virtual void Hide ();
+ virtual void EnableEvents (bool first);
+ virtual void DisableEvents ();
+
+ virtual void GrabFocus ();
+ virtual bool HasFocus ();
+
+ GtkWidget* GetWidget() { return widget; }
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ void *GetNativeWidget () { return GetWidget (); } // same as GetWidget, just without bleeding GtkWidget into the cbindings
+
+
+ virtual MoonClipboard *GetClipboard (MoonClipboardType clipboardType);
+
+ virtual gpointer GetPlatformWindow ();
+
+protected:
+ void PaintToDrawable (GdkDrawable *drawable, GdkVisual *visual, GdkEventExpose *event, int off_x, int off_y, bool transparent, bool clear_transparent);
+
+private:
+ GtkWidget *widget;
+
+ static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
+ static gboolean motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
+ static gboolean crossing_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
+ static gboolean key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+ static gboolean key_release (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
+ static gboolean button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
+ static gboolean button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
+ static gboolean scroll (GtkWidget *widget, GdkEventScroll *event, gpointer user_data);
+ static gboolean focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
+ static gboolean focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
+ static gboolean realized (GtkWidget *widget, gpointer user_data);
+ static gboolean unrealized (GtkWidget *widget, gpointer user_data);
+
+ static void widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data);
+ static void widget_destroyed (GtkWidget *widget, gpointer user_data);
+
+ void InitializeFullScreen (MoonWindow *parent);
+ void InitializeNormal ();
+ void InitializeCommon ();
+};
+
+#endif /* __MOON_WINDOW_GTK_H__ */
Copied: trunk/moon/src/pal/gtk/windowless-gtk.cpp (from rev 149147, trunk/moon/plugin/windowless.cpp)
===================================================================
--- trunk/moon/src/pal/gtk/windowless-gtk.cpp (rev 0)
+++ trunk/moon/src/pal/gtk/windowless-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,369 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * windowless-gtk.cpp: Windowsless Surface subclass for Gtk
+ *
+ * Contact:
+ * Moonlight List (moonlig...@lists.ximian.com)
+ *
+ * Copyright 2009 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#include <config.h>
+
+#include "windowless-gtk.h"
+
+#define Visual _XxVisual
+#define Region _XxRegion
+#include <gdk/gdkx.h>
+#undef Visual
+#undef Region
+
+#ifdef DEBUG
+#define d(x) x
+#else
+#define d(x)
+#endif
+
+MoonWindowlessGtk::MoonWindowlessGtk (int w, int h, PluginInstance *plugin)
+ : MoonWindowGtk (false, w, h)
+{
+ this->plugin = plugin;
+
+ UpdateWindowInfo ();
+}
+
+MoonWindowlessGtk::~MoonWindowlessGtk ()
+{
+}
+
+void
+MoonWindowlessGtk::UpdateWindowInfo ()
+{
+ // It appears opera doesn't do a good job of keeping the NPWindow members valid
+ // between SetWindow calls so we have to work around this by copying the members
+ // we need. This is really ugly.
+
+ NPWindow *window = plugin->GetWindow();
+ NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct*)window->ws_info;
+ visualid = ws_info->visual ? visualid = ws_info->visual->visualid : 0;
+ x = window->x;
+ y = window->y;
+}
+
+void
+MoonWindowlessGtk::Resize (int width, int height)
+{
+ bool emit_resize = false;
+
+ UpdateWindowInfo ();
+
+ if (this->width != width || this->height != height) {
+ this->width = width;
+ this->height = height;
+
+ emit_resize = true;
+ }
+
+ surface->HandleUIWindowAllocation (emit_resize);
+}
+
+void
+MoonWindowlessGtk::SetCursor (MouseCursor cursor)
+{
+#if (NP_VERSION_MINOR >= NPVERS_HAS_WINDOWLESS_CURSORS)
+ NPCursor npcursor;
+ switch (cursor) {
+ case MouseCursorDefault:
+ npcursor = NPCursorAuto;
+ break;
+ case MouseCursorArrow:
+ npcursor = NPCursorPointer;
+ break;
+ case MouseCursorWait:
+ npcursor = NPCursorWait;
+ break;
+ case MouseCursorIBeam:
+ npcursor = NPCursorText;
+ break;
+ case MouseCursorStylus:
+ npcursor = NPCursorPointer; // XXX ugh...
+ break;
+ case MouseCursorEraser:
+ npcursor = NPCursorPointer; // XXX ugh...
+ break;
+ case MouseCursorNone:
+ // Silverlight display no cursor if the enumeration value is invalid (e.g. -1)
+ default:
+ npcursor = NPCursorNone;
+ break;
+ }
+
+ NPN_SetValue (plugin->GetInstance(), NPPVcursor, (void*)npcursor);
+#endif
+}
+
+void
+MoonWindowlessGtk::Invalidate (Rect r)
+{
+ NPRect nprect;
+
+ // Mozilla gets seriously confused about invalidations
+ // outside the windowless bounds.
+ r = r.Intersection (Rect (0, 0, GetWidth(), GetHeight())).RoundOut ();
+
+ nprect.left = (uint16_t)r.x;
+ nprect.top = (uint16_t)r.y;
+ nprect.right = (uint16_t)(r.x + r.width);
+ nprect.bottom = (uint16_t)(r.y + r.height);
+
+ NPN_InvalidateRect (plugin->GetInstance(), &nprect);
+}
+
+void
+MoonWindowlessGtk::ProcessUpdates ()
+{
+ //NPN_ForceRedraw (plugin->GetInstance());
+}
+
+gboolean
+MoonWindowlessGtk::HandleEvent (gpointer platformEvent)
+{
+ XEvent *xev = (XEvent*)platformEvent;
+ gboolean handled = FALSE;
+
+ SetCurrentDeployment ();
+
+ if (!surface)
+ return false;
+
+ switch (xev->type) {
+ case GraphicsExpose: {
+ GdkDrawable *drawable = gdk_pixmap_foreign_new ((GdkNativeWindow)xev->xgraphicsexpose.drawable);
+ if (!drawable) {
+ drawable = gdk_window_foreign_new ((GdkNativeWindow)xev->xgraphicsexpose.drawable);
+ }
+
+ if (drawable) {
+ GdkVisual *visual = gdkx_visual_get (visualid);
+
+ if (visual) {
+ GdkEventExpose expose;
+
+ expose.type = GDK_EXPOSE;
+ expose.window = NULL;
+ expose.send_event = FALSE;
+ expose.area = Rect (xev->xgraphicsexpose.x,
+ xev->xgraphicsexpose.y,
+ xev->xgraphicsexpose.width,
+ xev->xgraphicsexpose.height).ToGdkRectangle ();
+ /* XXX ugh */
+ expose.region = gdk_region_rectangle (&expose.area);
+
+ expose.area.x = expose.area.y = 0;
+
+ PaintToDrawable (drawable, visual, &expose, x, y, GetTransparent(), false);
+
+ handled = TRUE;
+
+ gdk_region_destroy (expose.region);
+ } else {
+ d(printf ("no gdk visual\n"));
+ }
+
+ g_object_unref (drawable);
+ } else {
+ d(printf ("no gdk drawable\n"));
+ }
+ break;
+ }
+ case MotionNotify: {
+ GdkEventMotion motion;
+
+ motion.type = GDK_MOTION_NOTIFY;
+ motion.window = NULL;
+ motion.send_event = xev->xmotion.send_event;
+ motion.x = xev->xmotion.x;
+ motion.y = xev->xmotion.y;
+ motion.axes = NULL;
+ motion.state = xev->xmotion.state;
+ motion.is_hint = xev->xmotion.is_hint;
+ motion.device = NULL; // XXX
+ motion.x_root = xev->xmotion.x_root;
+ motion.y_root = xev->xmotion.y_root;
+
+ MoonMotionEvent *mevent = (MoonMotionEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (&motion);
+ handled = surface->HandleUIMotion (mevent);
+ delete mevent;
+ break;
+ }
+ case ButtonPress:
+ case ButtonRelease: {
+ GdkEventButton button;
+
+ button.type = xev->type == ButtonPress ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE;
+ button.window = NULL;
+ button.send_event = xev->xbutton.send_event;
+ button.time = xev->xbutton.time;
+ button.x = xev->xbutton.x;
+ button.y = xev->xbutton.y;
+ button.x_root = xev->xbutton.x_root;
+ button.y_root = xev->xbutton.y_root;
+ button.state = xev->xbutton.state;
+ button.button = xev->xbutton.button;
+ button.axes = NULL;
+
+ if (xev->type == ButtonPress)
+ handled = PluginInstance::plugin_button_press_callback (NULL, &button, plugin);
+ if (!handled) {
+ MoonButtonEvent *mevent = (MoonButtonEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (&button);
+ if (xev->type == ButtonPress)
+ handled = surface->HandleUIButtonPress (mevent);
+ else
+ handled = surface->HandleUIButtonRelease (mevent);
+
+ delete mevent;
+ }
+ break;
+ }
+ case KeyPress:
+ case KeyRelease: {
+ // make sure everything is initialized correctly (structure members vary with gdk version)
+ GdkEventKey *key = (GdkEventKey*) gdk_event_new (xev->type == KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
+ // gtk_im_context_xim_filter_keypress will dereference the NULL window leading to a SEGSIGV
+ key->window = (GdkWindow*)GetPlatformWindow ();
+ key->send_event = xev->xkey.send_event;
+ key->time = xev->xkey.time;
+ key->state = xev->xkey.state;
+ key->hardware_keycode = xev->xkey.keycode;
+
+ gint effective_group;
+
+ gdk_keymap_translate_keyboard_state (gdk_keymap_get_default (),
+ xev->xkey.keycode,
+ (GdkModifierType)xev->xkey.state, // XXX
+ 0, // XXX
+ &key->keyval,
+ &effective_group,
+ NULL,
+ NULL);
+
+ key->group = (guint8)effective_group;
+
+ MoonKeyEvent *mevent = (MoonKeyEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (key);
+
+ if (xev->type == KeyPress)
+ handled = surface->HandleUIKeyPress (mevent);
+ else
+ handled = surface->HandleUIKeyRelease (mevent);
+
+ delete mevent;
+
+ gdk_event_free ((GdkEvent*) key);
+ break;
+ }
+ case EnterNotify:
+ case LeaveNotify: {
+ GdkEventCrossing crossing;
+
+ crossing.type = xev->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
+ crossing.window = crossing.subwindow = NULL;
+ crossing.send_event = xev->xcrossing.send_event;
+ crossing.time = xev->xcrossing.time;
+ crossing.x = xev->xcrossing.x;
+ crossing.y = xev->xcrossing.y;
+ crossing.x_root = xev->xcrossing.x_root;
+ crossing.y_root = xev->xcrossing.y_root;
+ // crossing.mode = (GdkCrossingMode)xev->xcrossing.mode; // XXX
+ crossing.mode = GDK_CROSSING_NORMAL;
+ crossing.detail = (GdkNotifyType)xev->xcrossing.detail; // XXX
+ crossing.focus = xev->xcrossing.focus;
+ crossing.state = xev->xcrossing.state;
+
+ MoonCrossingEvent *mevent = (MoonCrossingEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (&crossing);
+ surface->HandleUICrossing (mevent);
+ delete mevent;
+ break;
+ }
+ case FocusIn:
+ case FocusOut: {
+ GdkEventFocus focus;
+
+ focus.type = GDK_FOCUS_CHANGE;
+ focus.window = NULL;
+ focus.send_event = xev->xfocus.send_event;
+ focus.in = xev->type == FocusIn;
+
+ MoonFocusEvent *mevent = (MoonFocusEvent*)runtime_get_windowing_system()->CreateEventFromPlatformEvent (&focus);
+
+ if (focus.in)
+ surface->HandleUIFocusIn (mevent);
+ else
+ surface->HandleUIFocusOut (mevent);
+
+ break;
+ }
+ default:
+ d(printf ("Unhandled Xlib event %d\n", xev->type));
+ break;
+ }
+
+ return handled;
+}
+
+void
+MoonWindowlessGtk::Show ()
+{
+ // nothing needed here
+}
+
+void
+MoonWindowlessGtk::Hide ()
+{
+ // nothing needed here
+}
+
+void
+MoonWindowlessGtk::EnableEvents (bool first)
+{
+ // nothing needed here, NPAPI pushes events through
+ // HandleEvent.
+}
+
+void
+MoonWindowlessGtk::DisableEvents ()
+{
+ // nothing needed here, NPAPI pushes events through
+ // HandleEvent.
+}
+
+void
+MoonWindowlessGtk::GrabFocus ()
+{
+ // we can't grab focus - the browser handles that.
+}
+
+bool
+MoonWindowlessGtk::HasFocus ()
+{
+ // XXX maybe we should track the focus in/out events?
+ return false;
+}
+
+void
+MoonWindowlessGtk::SetSurface (Surface *s)
+{
+ MoonWindow::SetSurface (s);
+ s->HandleUIWindowAvailable ();
+}
+
+gpointer
+MoonWindowlessGtk::GetPlatformWindow ()
+{
+ GdkNativeWindow window;
+ NPN_GetValue (plugin->GetInstance(), NPNVnetscapeWindow, (void*)&window);
+ GdkWindow *gdk = gdk_window_foreign_new (window);
+ return gdk;
+}
Copied: trunk/moon/src/pal/gtk/windowless-gtk.h (from rev 149147, trunk/moon/plugin/windowless.h)
===================================================================
--- trunk/moon/src/pal/gtk/windowless-gtk.h (rev 0)
+++ trunk/moon/src/pal/gtk/windowless-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * windowless-gtk.h: Windowless (NPAPI) implementation for gtk using browsers.
+ *
+ * Contact:
+ * Moonlight List (moonlig...@lists.ximian.com)
+ *
+ * Copyright 2007 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#ifndef __MOON_WINDOWLESS_GTK_H__
+#define __MOON_WINDOWLESS_GTK_H__
+
+#include "window-gtk.h"
+#include "moonlight.h"
+#include "runtime.h"
+#include "plugin.h"
+
+/* @Namespace=System.Windows */
+class MoonWindowlessGtk : public MoonWindowGtk {
+public:
+ MoonWindowlessGtk (int w = -1, int h = -1, PluginInstance *plugin = NULL);
+
+ virtual ~MoonWindowlessGtk ();
+
+ virtual void Resize (int width, int height);
+
+ virtual void SetCursor (MouseCursor cursor);
+ virtual void Invalidate (Rect r);
+ virtual void ProcessUpdates ();
+
+ virtual gboolean HandleEvent (gpointer platformEvent);
+
+ virtual void Show ();
+ virtual void Hide ();
+
+ virtual void EnableEvents (bool first);
+ virtual void DisableEvents ();
+
+ virtual void GrabFocus ();
+ virtual bool HasFocus ();
+
+ virtual void SetSurface (Surface *s);
+
+ virtual bool IsFullScreen () { return false; }
+
+ virtual gpointer GetPlatformWindow ();
+
+private:
+ PluginInstance *plugin;
+ VisualID visualid;
+ int x;
+ int y;
+
+ void UpdateWindowInfo ();
+};
+
+#endif // __MOON_WINDOWLESS_GTK_H__
Added: trunk/moon/src/pal/pal.h
===================================================================
--- trunk/moon/src/pal/pal.h (rev 0)
+++ trunk/moon/src/pal/pal.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#ifndef MOON_PAL_H
+#define MOON_PAL_H
+
+#include <glib.h>
+
+#include "enums.h"
+#include "cairo.h"
+#include "color.h"
+#include "point.h"
+#include "rect.h"
+#include "error.h"
+
+// I hate X11
+#ifdef FocusIn
+#undef FocusIn
+#endif
+#ifdef FocusOut
+#undef FocusOut
+#endif
+
+// the default for MoonWindowingSystem::GetCursorBlinkTimeout
+#define CURSOR_BLINK_TIMEOUT_DEFAULT 900
+
+class Surface;
+class UIElement;
+class PluginInstance;
+
+class MoonEvent;
+class MoonWindow;
+class MoonClipboard;
+
+enum MoonModifier {
+ MoonModifier_Shift = 1 << 0,
+ MoonModifier_Lock = 1 << 1,
+ MoonModifier_Control = 1 << 2,
+
+ MoonModifier_Mod1 = 1 << 3,
+ MoonModifier_Mod2 = 1 << 4,
+ MoonModifier_Mod3 = 1 << 5,
+ MoonModifier_Mod4 = 1 << 6,
+ MoonModifier_Mod5 = 1 << 7,
+
+ MoonModifier_Super = 1 << 26,
+ MoonModifier_Hyper = 1 << 27,
+ MoonModifier_Meta = 1 << 28,
+};
+
+// useful abstractions for porting moonlight to other platforms.
+
+// returns true if the timeout/idle should be removed
+typedef bool (*MoonSourceFunc) (gpointer data);
+
+typedef bool (*MoonCallback) (gpointer sender, gpointer data);
+
+typedef void (*MoonClipboardGetTextCallback) (MoonClipboard *clipboard, const char *text, gpointer data);
+
+class MoonEvent {
+public:
+ virtual MoonEvent *Clone () = 0;
+
+ // returns a platform event so that other
+ // platform interfaces which consume events can get at the actual data.
+ virtual gpointer GetPlatformEvent() = 0;
+};
+
+class MoonKeyEvent : public MoonEvent {
+public:
+ virtual Key GetSilverlightKey () = 0; // returns the enum value. this requires platform specific mapping
+
+ virtual int GetPlatformKeycode () = 0; // FIXME: do we really need both of these?
+ virtual int GetPlatformKeyval () = 0;
+
+ virtual gunichar GetUnicode () = 0;
+
+ virtual MoonModifier GetModifiers () = 0; // FIXME: should this be separate bool getters instead (like IsShiftDown, IsCtrlDown, IsAltDown)?
+
+ virtual bool IsModifier () = 0;
+};
+
+class MoonMouseEvent : public MoonEvent {
+public:
+ virtual Point GetPosition () = 0;
+
+ virtual double GetPressure () = 0;
+
+ virtual void GetStylusInfo (TabletDeviceType *type, bool *is_inverted) = 0;
+
+ virtual MoonModifier GetModifiers () = 0; // FIXME: should this be separate bool getters instead (like IsShiftDown, IsCtrlDown, IsAltDown)?
+};
+
+class MoonButtonEvent : public MoonMouseEvent {
+public:
+ virtual bool IsRelease () = 0;
+
+ virtual int GetButton () = 0;
+
+ // the number of clicks. gdk provides them as event->type ==
+ // GDK_3BUTTON_PRESS/GDK_2BUTTON_PRESS/GDK_BUTTON_PRESS
+ virtual int GetNumberOfClicks () = 0; // FIXME: will this api work?
+};
+
+class MoonMotionEvent : public MoonMouseEvent {
+};
+
+class MoonCrossingEvent : public MoonMouseEvent {
+public:
+ virtual bool IsEnter () = 0;
+};
+
+class MoonScrollWheelEvent : public MoonMouseEvent {
+public:
+ virtual int GetWheelDelta () = 0;
+};
+
+class MoonFocusEvent : public MoonEvent {
+public:
+ virtual bool IsIn() = 0;
+};
+
+
+class MoonIMContext {
+public:
+ virtual void SetUsePreedit (bool flag) = 0;
+ virtual void SetClientWindow (MoonWindow* window) = 0;
+ virtual void SetSurroundingText (const char *text, int offset, int length) = 0;
+ virtual void Reset () = 0;
+
+ virtual void FocusIn () = 0;
+ virtual void FocusOut () = 0;
+
+ virtual void SetCursorLocation (Rect r) = 0;
+
+ virtual bool FilterKeyPress (MoonKeyEvent* event) = 0;
+
+ virtual void SetRetrieveSurroundingCallback (MoonCallback cb, gpointer data) = 0;
+ virtual void SetDeleteSurroundingCallback (MoonCallback cb, gpointer data) = 0;
+ virtual void SetCommitCallback (MoonCallback cb, gpointer data) = 0;
+
+ virtual gpointer GetPlatformIMContext () = 0;
+};
+
+enum MoonClipboardType {
+ MoonClipboard_Clipboard,
+ MoonClipboard_Primary
+};
+
+class MoonClipboard {
+public:
+ virtual void SetSelection (const char *text, int length) = 0;
+ virtual void SetText (const char *text, int length) = 0;
+ virtual void AsyncGetText (MoonClipboardGetTextCallback cb, gpointer data) = 0;
+ virtual char* GetText () = 0;
+};
+
+class MoonPixbuf {
+public:
+ virtual gint GetWidth () = 0;
+ virtual gint GetHeight () = 0;
+ virtual gint GetRowStride () = 0;
+ virtual gint GetNumChannels () = 0;
+ virtual guchar *GetPixels () = 0;
+};
+
+class MoonPixbufLoader {
+public:
+ virtual void Write (const guchar *buffer, int buflen, MoonError **error = NULL) = 0;
+ virtual void Close (MoonError **error = NULL) = 0;
+ virtual MoonPixbuf *GetPixbuf () = 0;
+};
+
+// must match values from System.Windows.MessageBoxButtons
+#define MESSAGE_BOX_BUTTON_OK 0
+#define MESSAGE_BOX_BUTTON_OK_CANCEL 1
+
+// must match values from System.Windows.MessageBoxResult
+#define MESSAGE_BOX_RESULT_NONE 0
+#define MESSAGE_BOX_RESULT_OK 1
+#define MESSAGE_BOX_RESULT_CANCEL 2
+#define MESSAGE_BOX_RESULT_YES 6
+#define MESSAGE_BOX_RESULT_NO 7
+
+typedef MoonWindow* (*MoonWindowlessCtor)(int width, int height, PluginInstance *forPlugin);
+
+/* @Version=2 */
+class MoonWindowingSystem {
+public:
+ MoonWindowingSystem() { windowless_ctor = NULL; }
+
+ virtual ~MoonWindowingSystem () {}
+
+ // creates a platform/windowing system specific surface
+ virtual cairo_surface_t *CreateSurface () = 0;
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ virtual MoonWindow *CreateWindow (bool fullscreen, int width = -1, int height = -1, MoonWindow *parentWindow = NULL, Surface* surface = NULL) = 0;
+ virtual MoonWindow *CreateWindowless (int width, int height, PluginInstance *forPlugin);
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ virtual int ShowMessageBox (const char *caption, const char *text, int buttons) = 0;
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ virtual gchar** ShowOpenFileDialog (const char *title, bool multsel, const char *filter, int idx) = 0;
+ /* @GenerateCBinding,GeneratePInvoke */
+ virtual char* ShowSaveFileDialog (const char *title, const char *filter, int idx) = 0;
+
+ virtual guint AddTimeout (gint priority, gint ms, MoonSourceFunc timeout, gpointer data) = 0;
+ virtual void RemoveTimeout (guint timeoutId) = 0;
+
+ virtual MoonIMContext* CreateIMContext () = 0;
+
+ virtual MoonEvent* CreateEventFromPlatformEvent (gpointer platformEvent) = 0;
+
+ virtual guint GetCursorBlinkTimeout (MoonWindow *window) = 0;
+
+ virtual MoonPixbufLoader* CreatePixbufLoader (const char *imageType) = 0;
+
+ void SetWindowlessCtor (MoonWindowlessCtor ctor);
+
+private:
+ MoonWindowlessCtor windowless_ctor;
+};
+
+// XXX we need to think about multitouch events/tablets/accelerometers/gtk extension events, etc.
+
+#endif /* MOON_PAL_H */
Copied: trunk/moon/src/pal/window.h (from rev 149147, trunk/moon/src/window.h)
===================================================================
--- trunk/moon/src/pal/window.h (rev 0)
+++ trunk/moon/src/pal/window.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * window.h:
+ *
+ * Contact:
+ * Moonlight List (moonlig...@lists.ximian.com)
+ *
+ * Copyright 2007-2008 Novell, Inc. (http://www.novell.com)
+ *
+ * See the LICENSE file included with the distribution for details.
+ *
+ */
+
+#ifndef __MOON_WINDOW__
+#define __MOON_WINDOW__
+
+#include "pal.h"
+#include "rect.h"
+#include "enums.h"
+#include "color.h"
+#include "deployment.h"
+
+class MoonEvent;
+class MoonWindowingSystem;
+
+/* @Namespace=System.Windows */
+class MoonWindow {
+ public:
+ // FIXME: do something with parentWindow here.
+ MoonWindow (bool fullscreen, int width = -1, int height = -1, MoonWindow *parentWindow = NULL, Surface *s = NULL)
+ : width(width), height(height), surface(s), fullscreen (fullscreen), transparent(false), windowingSystem(NULL) { }
+
+ MoonWindow (int width = -1, int height = -1, PluginInstance *plugin = NULL)
+ : width(width), height(height), surface(NULL), fullscreen (false), transparent(false), windowingSystem(NULL) { }
+
+ virtual ~MoonWindow () { }
+
+ virtual void Resize (int width, int height) = 0;
+
+ virtual void SetCursor (MouseCursor cursor) = 0;
+ virtual void Invalidate (Rect r) = 0;
+ virtual void Invalidate () { Invalidate (Rect (0, 0, width, height)); }
+ virtual void ProcessUpdates () = 0;
+
+ virtual gboolean HandleEvent (gpointer platformEvent) = 0;
+
+ virtual void Show () = 0;
+ virtual void Hide () = 0;
+
+ virtual void EnableEvents (bool first) = 0;
+ virtual void DisableEvents () = 0;
+
+ virtual void GrabFocus () = 0;
+ virtual bool HasFocus () = 0;
+
+ int GetWidth () { return width; }
+ int GetHeight () { return height; }
+
+ virtual void SetSurface (Surface* s) { surface = s; }
+ Surface *GetSurface () { return surface; }
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ void SetTransparent (bool flag) { if (transparent != flag) Invalidate (); transparent = flag; }
+
+ virtual void SetBackgroundColor (Color *color) { Invalidate (); };
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ bool GetTransparent () { return transparent; }
+
+ bool IsFullScreen () { return fullscreen; }
+
+ void SetCurrentDeployment ();
+
+ virtual MoonClipboard *GetClipboard (MoonClipboardType clipboardType) = 0;
+
+ /* @GenerateCBinding,GeneratePInvoke */
+ virtual gpointer GetPlatformWindow () = 0;
+
+ protected:
+ int width;
+ int height;
+ Surface *surface;
+ bool fullscreen;
+ bool transparent;
+ Deployment *deployment;
+
+ MoonWindowingSystem* windowingSystem;
+};
+
+#endif /* __MOON_WINDOW__ */
Modified: trunk/moon/src/pipeline-nocodec-ui.cpp
===================================================================
--- trunk/moon/src/pipeline-nocodec-ui.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/pipeline-nocodec-ui.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -15,7 +15,6 @@
#include <string.h>
#include <fcntl.h>
#include <stdlib.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
#include "pipeline-nocodec-ui.h"
#include "downloader.h"
Modified: trunk/moon/src/pipeline-ui.cpp
===================================================================
--- trunk/moon/src/pipeline-ui.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/pipeline-ui.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -17,8 +17,6 @@
#include <errno.h>
#include <stdlib.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
#define MONO_HEADERS_INCLUDED 1
#include <mono/jit/jit.h>
Modified: trunk/moon/src/popup.cpp
===================================================================
--- trunk/moon/src/popup.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/popup.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -11,7 +11,7 @@
#include "popup.h"
#include "runtime.h"
#include "deployment.h"
-
+
Popup::Popup ()
{
SetObjectType (Type::POPUP);
@@ -130,4 +130,4 @@
control->UpdateEnabled ();
walker.SkipBranch ();
}
-}
\ No newline at end of file
+}
Modified: trunk/moon/src/resources.cpp
===================================================================
--- trunk/moon/src/resources.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/resources.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -226,6 +226,12 @@
return result;
}
+static gboolean
+_true ()
+{
+ return TRUE;
+}
+
bool
ResourceDictionary::Clear ()
{
@@ -234,7 +240,7 @@
g_hash_table_remove_all (hash);
else
#endif
- g_hash_table_foreach_remove (hash, (GHRFunc) gtk_true, NULL);
+ g_hash_table_foreach_remove (hash, (GHRFunc) _true, NULL);
from_resource_dictionary_api = true;
bool rv = Collection::Clear ();
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/runtime.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -13,21 +13,11 @@
#include <config.h>
-#include <gtk/gtk.h>
-
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
-#define Visual _XxVisual
-#define Region _XxRegion
-#include <gdk/gdkx.h>
-#include <gdk/gdkkeysyms.h>
-#include <cairo-xlib.h>
-#undef Visual
-#undef Region
-
#include "debug.h"
#include "runtime.h"
#include "canvas.h"
@@ -50,7 +40,6 @@
#include "incomplete-support.h"
#include "drm.h"
#include "utils.h"
-#include "window-gtk.h"
#include "timemanager.h"
#include "contentcontrol.h"
@@ -59,6 +48,10 @@
#include "grid.h"
#include "cbinding.h"
#include "tabnavigationwalker.h"
+#include "window.h"
+#if PAL_GTK
+#include "pal-gtk.h"
+#endif
#include "pipeline.h"
//#define DEBUG_INVALIDATE 1
@@ -74,6 +67,8 @@
bool Surface::main_thread_inited = false;
pthread_t Surface::main_thread = 0;
+static MoonWindowingSystem *windowing_system = NULL;
+
static bool inited = false;
static bool g_type_inited = false;
static GList* surface_list = NULL;
@@ -127,8 +122,8 @@
{ "idlehint=yes", RUNTIME_INIT_USE_IDLE_HINT, false },
{ "idlehint=no", RUNTIME_INIT_USE_IDLE_HINT, true },
/* default to the image backend until cairo is actually faster that way */
- { "backend=xlib", RUNTIME_INIT_USE_BACKEND_XLIB, false },
- { "backend=image", RUNTIME_INIT_USE_BACKEND_XLIB, true },
+ { "backend=native", RUNTIME_INIT_USE_BACKEND_IMAGE, false },
+ { "backend=image", RUNTIME_INIT_USE_BACKEND_IMAGE, true },
{ "keepmedia=no", RUNTIME_INIT_KEEP_MEDIA, false },
{ "keepmedia=yes", RUNTIME_INIT_KEEP_MEDIA, true },
{ "allimages=no", RUNTIME_INIT_ALL_IMAGE_FORMATS, false },
@@ -138,8 +133,8 @@
};
-#define RUNTIME_INIT_DESKTOP (RUNTIME_INIT_PANGO_TEXT_LAYOUT | RUNTIME_INIT_RENDER_FRONT_TO_BACK | RUNTIME_INIT_USE_UPDATE_POSITION | RUNTIME_INIT_USE_SHAPE_CACHE | RUNTIME_INIT_USE_IDLE_HINT | RUNTIME_INIT_USE_BACKEND_XLIB | RUNTIME_INIT_ALL_IMAGE_FORMATS | RUNTIME_INIT_OUT_OF_BROWSER | RUNTIME_INIT_DESKTOP_EXTENSIONS)
-#define RUNTIME_INIT_BROWSER (RUNTIME_INIT_RENDER_FRONT_TO_BACK | RUNTIME_INIT_USE_UPDATE_POSITION | RUNTIME_INIT_USE_SHAPE_CACHE | RUNTIME_INIT_ALLOW_WINDOWLESS | RUNTIME_INIT_USE_IDLE_HINT | RUNTIME_INIT_USE_BACKEND_XLIB | RUNTIME_INIT_ENABLE_MS_CODECS | RUNTIME_INIT_CREATE_ROOT_DOMAIN)
+#define RUNTIME_INIT_DESKTOP (RUNTIME_INIT_PANGO_TEXT_LAYOUT | RUNTIME_INIT_RENDER_FRONT_TO_BACK | RUNTIME_INIT_USE_UPDATE_POSITION | RUNTIME_INIT_USE_SHAPE_CACHE | RUNTIME_INIT_USE_IDLE_HINT | RUNTIME_INIT_USE_BACKEND_IMAGE | RUNTIME_INIT_ALL_IMAGE_FORMATS | RUNTIME_INIT_OUT_OF_BROWSER | RUNTIME_INIT_DESKTOP_EXTENSIONS)
+#define RUNTIME_INIT_BROWSER (RUNTIME_INIT_RENDER_FRONT_TO_BACK | RUNTIME_INIT_USE_UPDATE_POSITION | RUNTIME_INIT_USE_SHAPE_CACHE | RUNTIME_INIT_ALLOW_WINDOWLESS | RUNTIME_INIT_USE_IDLE_HINT | RUNTIME_INIT_USE_BACKEND_IMAGE | RUNTIME_INIT_ENABLE_MS_CODECS | RUNTIME_INIT_CREATE_ROOT_DOMAIN)
#if DEBUG || LOGGING
static struct env_options debugs[] = {
@@ -189,19 +184,6 @@
};
#endif
-
-static bool
-running_on_nvidia ()
-{
- int event, error, opcode;
-
- Display *display = XOpenDisplay (NULL);
- bool result = XQueryExtension (display, "NV-GLX", &opcode, &event, &error);
- XCloseDisplay (display);
-
- return result;
-}
-
static void
fps_report_default (Surface *surface, int nframes, float nsecs, void *user_data)
{
@@ -225,29 +207,6 @@
return surface_list;
}
-static cairo_t *
-runtime_cairo_create (GdkWindow *drawable, GdkVisual *visual, bool native)
-{
- int width, height;
- cairo_surface_t *surface;
- cairo_t *cr;
-
- gdk_drawable_get_size (drawable, &width, &height);
-
- if (native)
- surface = cairo_xlib_surface_create (gdk_x11_drawable_get_xdisplay (drawable),
- gdk_x11_drawable_get_xid (drawable),
- GDK_VISUAL_XVISUAL (visual),
- width, height);
- else
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
-
- cr = cairo_create (surface);
- cairo_surface_destroy (surface);
-
- return cr;
-}
-
static gboolean
flags_can_be_modifed (void)
{
@@ -692,6 +651,74 @@
#endif
}
+void
+Surface::Paint (cairo_t *ctx, Region *region, bool transparent, bool clear_transparent)
+{
+ frames++;
+
+ region->Draw (ctx);
+ //
+ // These are temporary while we change this to paint at the offset position
+ // instead of using the old approach of modifying the topmost UIElement (a no-no),
+ //
+ // The flag "transparent" is here because I could not
+ // figure out what is painting the background with white now.
+ // The change that made the white painting implicit instead of
+ // explicit is patch 80632. I would appreciate any help in tracking down
+ // the proper way of making the background white when not running in
+ // "transparent" mode.
+ //
+ // Either exposing surface_set_trans to turn the next code is a hack,
+ // or it is normal to request all code that wants to paint to manually
+ // clear the background to white beforehand. For now am going with
+ // making this an explicit surface API.
+ //
+ cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
+
+ if (transparent) {
+ if (clear_transparent) {
+ cairo_set_operator (ctx, CAIRO_OPERATOR_CLEAR);
+ cairo_fill_preserve (ctx);
+ cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
+ }
+
+ cairo_set_source_rgba (ctx,
+ background_color->r,
+ background_color->g,
+ background_color->b,
+ background_color->a);
+ }
+ else {
+ cairo_set_source_rgb (ctx,
+ background_color->r,
+ background_color->g,
+ background_color->b);
+ }
+
+ cairo_fill_preserve (ctx);
+ cairo_clip (ctx);
+
+ cairo_save (ctx);
+ Paint (ctx, region);
+ cairo_restore (ctx);
+
+ if (GetEnableRedrawRegions ()) {
+ // pink: 234, 127, 222
+ // yellow: 234, 239, 110
+ // purple: 127, 127, 222
+ int r = abs (frames) % 3 == 2 ? 127 : 234;
+ int g = abs (frames) % 3 == 1 ? 239 : 127;
+ int b = abs (frames) % 3 == 1 ? 110 : 222;
+
+ cairo_new_path (ctx);
+ region->Draw (ctx);
+ //cairo_set_line_width (ctx, 2.0);
+ cairo_set_source_rgba (ctx, (double) r / 255.0, (double) g / 255.0, (double) b / 255.0, 0.75);
+ cairo_fill (ctx);
+ }
+}
+
+
//
// This will resize the surface (merely a convenience function for
// resizing the widget area that we have.
@@ -988,8 +1015,7 @@
return;
if (value) {
- fullscreen_window = new MoonWindowGtk (true, -1, -1, normal_window, this);
-
+ fullscreen_window = windowing_system->CreateWindow (true, -1, -1, normal_window, this);
active_window = fullscreen_window;
ShowFullScreenMessage ();
@@ -1105,6 +1131,8 @@
time_manager->AddHandler (TimeManager::UpdateInputEvent, update_input_cb, this);
time_manager->NeedRedraw ();
+
+ Emit (Surface::WindowAvailableEvent);
}
void
@@ -1112,130 +1140,8 @@
{
time_manager->RemoveHandler (TimeManager::RenderEvent, render_cb, this);
time_manager->RemoveHandler (TimeManager::UpdateInputEvent, update_input_cb, this);
-}
-void
-Surface::PaintToDrawable (GdkDrawable *drawable, GdkVisual *visual, GdkEventExpose *event, int off_x, int off_y, bool transparent, bool clear_transparent)
-{
- frames++;
-
- LOG_UI ("Surface::PaintToDrawable (%p, %p, (%d,%d %d,%d), %d, %d, %d, %d)\n",
- drawable, visual, event->area.x, event->area.y, event->area.width, event->area.height,
- off_x, off_y, transparent, clear_transparent);
-
- if (event->area.x > (off_x + active_window->GetWidth()) || event->area.y > (off_y + active_window->GetHeight()))
- return;
-
- SetCurrentDeployment ();
-
-#if TIME_REDRAW
- STARTTIMER (expose, "redraw");
-#endif
- if (cache_size_multiplier == -1)
- cache_size_multiplier = gdk_drawable_get_depth (drawable) / 8 + 1;
-
-#ifdef DEBUG_INVALIDATE
- printf ("Got a request to repaint at %d %d %d %d\n", event->area.x, event->area.y, event->area.width, event->area.height);
-#endif
- cairo_t *ctx = runtime_cairo_create (drawable, visual, moonlight_flags & RUNTIME_INIT_USE_BACKEND_XLIB);
- Region *region = new Region (event->region);
-
- region->Offset (-off_x, -off_y);
- cairo_surface_set_device_offset (cairo_get_target (ctx),
- off_x - event->area.x,
- off_y - event->area.y);
- region->Draw (ctx);
- //
- // These are temporary while we change this to paint at the offset position
- // instead of using the old approach of modifying the topmost UIElement (a no-no),
- //
- // The flag "transparent" is here because I could not
- // figure out what is painting the background with white now.
- // The change that made the white painting implicit instead of
- // explicit is patch 80632. I would appreciate any help in tracking down
- // the proper way of making the background white when not running in
- // "transparent" mode.
- //
- // Either exposing surface_set_trans to turn the next code is a hack,
- // or it is normal to request all code that wants to paint to manually
- // clear the background to white beforehand. For now am going with
- // making this an explicit surface API.
- //
- // The second part is for coping with the future: when we support being
- // windowless
- //
- cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
-
- if (transparent) {
- if (clear_transparent) {
- cairo_set_operator (ctx, CAIRO_OPERATOR_CLEAR);
- cairo_fill_preserve (ctx);
- cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
- }
-
- cairo_set_source_rgba (ctx,
- background_color->r,
- background_color->g,
- background_color->b,
- background_color->a);
- }
- else {
- cairo_set_source_rgb (ctx,
- background_color->r,
- background_color->g,
- background_color->b);
- }
-
- cairo_fill_preserve (ctx);
- cairo_clip (ctx);
-
- cairo_save (ctx);
- Paint (ctx, region);
- cairo_restore (ctx);
-
- if (GetEnableRedrawRegions ()) {
- // pink: 234, 127, 222
- // yellow: 234, 239, 110
- // purple: 127, 127, 222
- int r = abs (frames) % 3 == 2 ? 127 : 234;
- int g = abs (frames) % 3 == 1 ? 239 : 127;
- int b = abs (frames) % 3 == 1 ? 110 : 222;
-
- cairo_new_path (ctx);
- region->Draw (ctx);
- //cairo_set_line_width (ctx, 2.0);
- cairo_set_source_rgba (ctx, (double) r / 255.0, (double) g / 255.0, (double) b / 255.0, 0.75);
- cairo_fill (ctx);
- }
-
- if (!(moonlight_flags & RUNTIME_INIT_USE_BACKEND_XLIB)) {
- cairo_surface_flush (cairo_get_target (ctx));
- cairo_t *native = runtime_cairo_create (drawable, visual, true);
-
- cairo_surface_set_device_offset (cairo_get_target (native),
- 0, 0);
- cairo_surface_set_device_offset (cairo_get_target (ctx),
- 0, 0);
-
- cairo_set_source_surface (native, cairo_get_target (ctx),
- 0, 0);
-
- region->Offset (off_x, off_y);
- region->Offset (-event->area.x, -event->area.y);
- region->Draw (native);
-
- cairo_fill (native);
- cairo_destroy (native);
- }
- cairo_destroy (ctx);
-
- delete region;
-
-
-#if TIME_REDRAW
- ENDTIMER (expose, "redraw");
-#endif
-
+ Emit (Surface::WindowUnavailableEvent);
}
/* for emitting focus changed events */
@@ -1387,7 +1293,7 @@
}
EventArgs*
-Surface::CreateArgsForEvent (int event_id, GdkEvent *event)
+Surface::CreateArgsForEvent (int event_id, MoonEvent *event)
{
if (event_id ==UIElement::InvalidatedEvent
|| event_id ==UIElement::GotFocusEvent
@@ -1396,18 +1302,18 @@
else if (event_id == UIElement::MouseLeaveEvent
|| event_id ==UIElement::MouseMoveEvent
|| event_id ==UIElement::MouseEnterEvent)
- return new MouseEventArgs(event);
+ return new MouseEventArgs((MoonMouseEvent*)event);
else if (event_id ==UIElement::MouseLeftButtonMultiClickEvent
|| event_id ==UIElement::MouseLeftButtonDownEvent
|| event_id ==UIElement::MouseLeftButtonUpEvent
|| event_id ==UIElement::MouseRightButtonDownEvent
|| event_id ==UIElement::MouseRightButtonUpEvent)
- return new MouseButtonEventArgs(event);
+ return new MouseButtonEventArgs((MoonButtonEvent*)event);
else if (event_id == UIElement::MouseWheelEvent)
- return new MouseWheelEventArgs(event);
+ return new MouseWheelEventArgs((MoonScrollWheelEvent*)event);
else if (event_id == UIElement::KeyDownEvent
|| event_id == UIElement::KeyUpEvent)
- return new KeyEventArgs((GdkEventKey*)event);
+ return new KeyEventArgs((MoonKeyEvent*)event);
else {
g_warning ("Unknown event id %d\n", event_id);
return new EventArgs();
@@ -1415,7 +1321,7 @@
}
bool
-Surface::EmitEventOnList (int event_id, List *element_list, GdkEvent *event, int end_idx)
+Surface::EmitEventOnList (int event_id, List *element_list, MoonEvent *event, int end_idx)
{
bool handled = false;
@@ -1521,11 +1427,11 @@
}
bool
-Surface::HandleMouseEvent (int event_id, bool emit_leave, bool emit_enter, bool force_emit, GdkEvent *event)
+Surface::HandleMouseEvent (int event_id, bool emit_leave, bool emit_enter, bool force_emit, MoonMouseEvent *event)
{
bool handled = false;
- bool mouse_down = event_id == UIElement::MouseLeftButtonDownEvent ||
- event_id == UIElement::MouseRightButtonDownEvent;
+ bool mouse_down = (event_id == UIElement::MouseLeftButtonDownEvent ||
+ event_id == UIElement::MouseRightButtonDownEvent);
if ((moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) == 0 &&
((event_id == UIElement::MouseRightButtonDownEvent) || (event_id == UIElement::MouseRightButtonDownEvent)))
@@ -1570,12 +1476,9 @@
// the point (x,y), and all visual parents up the
// hierarchy to the root.
List *new_input_list = new List ();
- double x, y;
- gdk_event_get_coords (event, &x, &y);
+ Point p (event->GetPosition ());
- Point p (x,y);
-
cairo_t *ctx = measuring_context_create ();
for (int i = layers->GetCount () - 1; i >= 0 && new_input_list->IsEmpty (); i--)
layers->GetValueAt (i)->AsUIElement ()->HitTest (ctx, p, new_input_list);
@@ -1834,41 +1737,39 @@
}
bool
-Surface::FullScreenKeyHandled (GdkEventKey *key)
+Surface::FullScreenKeyHandled (MoonKeyEvent *key)
{
if (!GetFullScreen ())
return false;
// If we're in fullscreen mode no key events are passed through.
// We only handle Esc, to exit fullscreen mode.
- if (key->keyval == GDK_Escape)
- SetFullScreen (false);
-
- switch (key->keyval) {
- case GDK_Down:
- case GDK_Up:
- case GDK_Left:
- case GDK_Right:
- case GDK_KP_Space:
- case GDK_space:
- case GDK_Tab:
- case GDK_Page_Down:
- case GDK_Page_Up:
- case GDK_Home:
- case GDK_End:
- case GDK_Return:
- case GDK_KP_Enter:
+
+ switch (key->GetSilverlightKey()) {
+ case KeyDOWN:
+ case KeyUP:
+ case KeyLEFT:
+ case KeyRIGHT:
+ case KeySPACE:
+ case KeyTAB:
+ case KeyPAGEDOWN:
+ case KeyPAGEUP:
+ case KeyHOME:
+ case KeyEND:
+ case KeyENTER:
return false;
- // Explicitly listing GDK_Escape here as it should never bubble up
- case GDK_Escape:
+ // Explicitly listing KeyESCAPE here as it should never bubble up
+ case KeyESCAPE:
+ SetFullScreen (false);
+ // fall through here
default:
return true;
}
}
gboolean
-Surface::HandleUIFocusIn (GdkEventFocus *event)
+Surface::HandleUIFocusIn (MoonFocusEvent *event)
{
if (IsZombie ())
return false;
@@ -1877,7 +1778,7 @@
if (GetFocusedElement ()) {
List *focus_to_root = ElementPathToRoot (GetFocusedElement ());
- EmitEventOnList (UIElement::GotFocusEvent, focus_to_root, (GdkEvent*)event, -1);
+ EmitEventOnList (UIElement::GotFocusEvent, focus_to_root, event, -1);
delete focus_to_root;
}
@@ -1885,7 +1786,7 @@
}
gboolean
-Surface::HandleUIFocusOut (GdkEventFocus *event)
+Surface::HandleUIFocusOut (MoonFocusEvent *event)
{
if (IsZombie ())
return false;
@@ -1894,7 +1795,7 @@
if (GetFocusedElement ()) {
List *focus_to_root = ElementPathToRoot (GetFocusedElement ());
- EmitEventOnList (UIElement::LostFocusEvent, focus_to_root, (GdkEvent*)event, -1);
+ EmitEventOnList (UIElement::LostFocusEvent, focus_to_root, event, -1);
delete focus_to_root;
}
@@ -1902,22 +1803,22 @@
}
gboolean
-Surface::HandleUIButtonRelease (GdkEventButton *event)
+Surface::HandleUIButtonRelease (MoonButtonEvent *event)
{
time_manager->InvokeTickCalls();
- if (event->button != 1 && event->button != 3) {
+ if (event->GetButton() != 1 && event->GetButton() != 3)
return false;
- }
SetUserInitiatedEvent (true);
- if (mouse_event)
- gdk_event_free (mouse_event);
+ delete mouse_event;
- mouse_event = gdk_event_copy ((GdkEvent *) event);
+ mouse_event = (MoonMouseEvent*)event->Clone ();
- HandleMouseEvent (event->button == 1 ? UIElement::MouseLeftButtonUpEvent : UIElement::MouseRightButtonUpEvent,
+ HandleMouseEvent ((event->GetButton () == 1
+ ? UIElement::MouseLeftButtonUpEvent
+ : UIElement::MouseRightButtonUpEvent),
true, true, true, mouse_event);
UpdateCursorFromInputList ();
@@ -1927,39 +1828,42 @@
if (captured)
PerformReleaseCapture ();
- return !((moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) == 0 && event->button == 3);
+ return !((moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) == 0 && event->GetButton () == 3);
}
gboolean
-Surface::HandleUIButtonPress (GdkEventButton *event)
+Surface::HandleUIButtonPress (MoonButtonEvent *event)
{
bool handled;
int event_id;
active_window->GrabFocus ();
-
- time_manager->InvokeTickCalls();
- if (event->button != 1 && event->button != 3)
+ time_manager->InvokeTickCalls();
+
+ if (event->GetButton () != 1 && event->GetButton() != 3)
return false;
SetUserInitiatedEvent (true);
- if (mouse_event)
- gdk_event_free (mouse_event);
+ delete mouse_event;
- mouse_event = gdk_event_copy ((GdkEvent *) event);
+ mouse_event = (MoonMouseEvent*)event->Clone ();
- switch (event->type) {
- case GDK_3BUTTON_PRESS:
- case GDK_2BUTTON_PRESS:
- if (event->button != 1)
+ switch (event->GetNumberOfClicks ()) {
+ case 3:
+ case 2:
+ if (event->GetButton() != 1)
return false;
handled = HandleMouseEvent (UIElement::MouseLeftButtonMultiClickEvent, false, false, true, mouse_event);
break;
default:
- if (event->button == 1)
+ g_warning ("unhandled number of button clicks %d, treating as a single click",
+ event->GetNumberOfClicks ());
+ // fallthrough
+ case 1:
+ if (event->GetButton() == 1)
event_id = UIElement::MouseLeftButtonDownEvent;
else
event_id = UIElement::MouseRightButtonDownEvent;
@@ -1975,14 +1879,12 @@
}
gboolean
-Surface::HandleUIScroll (GdkEventScroll *event)
+Surface::HandleUIScroll (MoonScrollWheelEvent *event)
{
time_manager->InvokeTickCalls();
- if (mouse_event)
- gdk_event_free (mouse_event);
-
- mouse_event = gdk_event_copy ((GdkEvent *) event);
+ delete mouse_event;
+ mouse_event = (MoonMouseEvent*)event->Clone();
bool handled = false;
@@ -1994,40 +1896,21 @@
}
gboolean
-Surface::HandleUIMotion (GdkEventMotion *event)
+Surface::HandleUIMotion (MoonMotionEvent *event)
{
time_manager->InvokeTickCalls();
- if (mouse_event)
- gdk_event_free (mouse_event);
-
- mouse_event = gdk_event_copy ((GdkEvent *) event);
+ delete mouse_event;
+ mouse_event = (MoonMouseEvent*)event->Clone ();
- bool handled = false;
-
- if (event->is_hint) {
-#if GTK_CHECK_VERSION(2,12,0)
- if (gtk_check_version (2, 12, 0))
- gdk_event_request_motions (event);
- else
-#endif
- {
- int ix, iy;
- GdkModifierType state;
- gdk_window_get_pointer (event->window, &ix, &iy, (GdkModifierType*)&state);
- ((GdkEventMotion *) mouse_event)->x = ix;
- ((GdkEventMotion *) mouse_event)->y = iy;
- }
- }
-
- handled = HandleMouseEvent (UIElement::MouseMoveEvent, true, true, true, mouse_event);
+ bool handled = HandleMouseEvent (UIElement::MouseMoveEvent, true, true, true, mouse_event);
UpdateCursorFromInputList ();
return handled;
}
gboolean
-Surface::HandleUICrossing (GdkEventCrossing *event)
+Surface::HandleUICrossing (MoonCrossingEvent *event)
{
bool handled;
@@ -2043,10 +1926,10 @@
g_object_unref (active_gdk_window);
*/
- if (event->type == GDK_ENTER_NOTIFY) {
- if (mouse_event)
- gdk_event_free (mouse_event);
- mouse_event = gdk_event_copy ((GdkEvent *) event);
+ if (event->IsEnter ()) {
+ delete mouse_event;
+
+ mouse_event = (MoonMouseEvent*)event->Clone ();
handled = HandleMouseEvent (UIElement::MouseMoveEvent, true, true, false, mouse_event);
@@ -2122,12 +2005,12 @@
}
gboolean
-Surface::HandleUIKeyPress (GdkEventKey *event)
+Surface::HandleUIKeyPress (MoonKeyEvent *event)
{
time_manager->InvokeTickCalls();
- Key key = Keyboard::MapKeyValToKey (event->keyval);
-
+ Key key = event->GetSilverlightKey ();
+
if (Keyboard::IsKeyPressed (key)) {
// If we are running an SL 1.0 application, then key repeats are dropped
Deployment *deployment = Deployment::GetCurrent ();
@@ -2139,7 +2022,7 @@
#if DEBUG_MARKER_KEY
static int debug_marker_key_in = 0;
- if (event->keyval == GDK_d || event->keyval == GDK_D) {
+ if (Key == KeyD) {
if (!debug_marker_key_in)
printf ("<--- DEBUG MARKER KEY IN (%f) --->\n", get_now () / 10000000.0);
else
@@ -2156,7 +2039,7 @@
if (focused_element) {
List *focus_to_root = ElementPathToRoot (focused_element);
- handled = EmitEventOnList (UIElement::KeyDownEvent, focus_to_root, (GdkEvent*)event, -1);
+ handled = EmitEventOnList (UIElement::KeyDownEvent, focus_to_root, event, -1);
delete focus_to_root;
}
else if (toplevel){
@@ -2171,7 +2054,7 @@
}
gboolean
-Surface::HandleUIKeyRelease (GdkEventKey *event)
+Surface::HandleUIKeyRelease (MoonKeyEvent *event)
{
time_manager->InvokeTickCalls();
@@ -2181,12 +2064,12 @@
SetUserInitiatedEvent (true);
bool handled = false;
- Key key = Keyboard::MapKeyValToKey (event->keyval);
+ Key key = event->GetSilverlightKey();
Keyboard::OnKeyRelease (key);
if (focused_element) {
List *focus_to_root = ElementPathToRoot (focused_element);
- handled = EmitEventOnList (UIElement::KeyUpEvent, focus_to_root, (GdkEvent*)event, -1);
+ handled = EmitEventOnList (UIElement::KeyUpEvent, focus_to_root, event, -1);
delete focus_to_root;
}
else if (toplevel) {
@@ -2386,11 +2269,6 @@
printf ("*** Proceed at your own risk\n");
}
- if (running_on_nvidia ()) {
- printf ("Moonlight: Forcing client-side rendering because we detected binary drivers which are known to suffer performance problems.\n");
- flags &= ~RUNTIME_INIT_USE_BACKEND_XLIB;
- }
-
// Allow the user to override the flags via his/her environment
flags = get_flags (flags, "MOONLIGHT_OVERRIDES", overrides);
#if DEBUG || LOGGING
@@ -2399,7 +2277,7 @@
#endif
inited = true;
-
+
if (!g_type_inited) {
g_type_inited = true;
g_type_init ();
@@ -2407,6 +2285,14 @@
moonlight_flags = flags;
+ // FIXME add some ifdefs + runtime checks here
+#if PAL_GTK
+ windowing_system = new MoonWindowingSystemGtk ();
+#else
+#error "no PAL backend"
+#endif
+
+
Deployment::Initialize (platform_dir, (flags & RUNTIME_INIT_CREATE_ROOT_DOMAIN) != 0);
xaml_init ();
@@ -2414,6 +2300,12 @@
Media::Initialize ();
}
+MoonWindowingSystem *
+runtime_get_windowing_system ()
+{
+ return windowing_system;
+}
+
void
runtime_shutdown (void)
{
@@ -2423,4 +2315,7 @@
Media::Shutdown ();
inited = false;
+
+ delete windowing_system;
+ windowing_system = NULL;
}
Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/runtime.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -14,7 +14,6 @@
#ifndef __RUNTIME_H__
#define __RUNTIME_H__
-#include <gtk/gtkwidget.h>
#include <cairo.h>
#include "point.h"
@@ -25,7 +24,8 @@
#include "type.h"
#include "list.h"
#include "error.h"
-#include "window.h"
+
+#include "pal.h"
#include "mutex.h"
#define MAXIMUM_CACHE_SIZE 6000000
@@ -74,14 +74,14 @@
RUNTIME_INIT_AUDIO_ALSA = 1 << 18,
RUNTIME_INIT_AUDIO_PULSE = 1 << 19,
RUNTIME_INIT_USE_IDLE_HINT = 1 << 20,
- RUNTIME_INIT_USE_BACKEND_XLIB = 1 << 21,
+ RUNTIME_INIT_USE_BACKEND_IMAGE = 1 << 21,
RUNTIME_INIT_KEEP_MEDIA = 1 << 22,
RUNTIME_INIT_ENABLE_MS_CODECS = 1 << 23,
RUNTIME_INIT_DISABLE_FFMPEG_CODECS = 1 << 24,
RUNTIME_INIT_ALL_IMAGE_FORMATS = 1 << 25,
RUNTIME_INIT_CREATE_ROOT_DOMAIN = 1 << 26,
RUNTIME_INIT_DESKTOP_EXTENSIONS = 1 << 27,
- RUNTIME_INIT_OUT_OF_BROWSER = 1 << 28,
+ RUNTIME_INIT_OUT_OF_BROWSER = 1 << 28
};
extern guint32 moonlight_flags;
@@ -162,6 +162,8 @@
/* @GenerateCBinding,GeneratePInvoke */
void Paint (cairo_t *ctx, int x, int y, int width, int height);
+ void Paint (cairo_t *ctx, Region *region, bool transparent, bool clear_transparent);
+
/* @GenerateCBinding,GeneratePInvoke */
void Attach (UIElement *toplevel);
@@ -216,6 +218,9 @@
const static int LoadEvent;
const static int SourceDownloadProgressChangedEvent;
const static int SourceDownloadCompleteEvent;
+ const static int WindowAvailableEvent;
+ const static int WindowUnavailableEvent;
+
const static int ZoomedEvent;
/* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
@@ -241,7 +246,7 @@
const char* GetSourceLocation ();
void SetSourceLocation (const char *location);
- bool FullScreenKeyHandled (GdkEventKey *key);
+ bool FullScreenKeyHandled (MoonKeyEvent *key);
/* @GenerateCBinding,GeneratePInvoke */
TimeManager *GetTimeManager () { return time_manager; }
@@ -280,18 +285,15 @@
UIElement *debug_selected_element;
#endif
- void PaintToDrawable (GdkDrawable *drawable, GdkVisual *visual, GdkEventExpose *event, int off_x, int off_y, bool transparent, bool clear_transparent);
-
-
- gboolean HandleUIMotion (GdkEventMotion *event);
- gboolean HandleUICrossing (GdkEventCrossing *event);
- gboolean HandleUIKeyPress (GdkEventKey *event);
- gboolean HandleUIKeyRelease (GdkEventKey *event);
- gboolean HandleUIButtonRelease (GdkEventButton *event);
- gboolean HandleUIButtonPress (GdkEventButton *event);
- gboolean HandleUIScroll (GdkEventScroll *event);
- gboolean HandleUIFocusIn (GdkEventFocus *event);
- gboolean HandleUIFocusOut (GdkEventFocus *event);
+ gboolean HandleUIMotion (MoonMotionEvent *event);
+ gboolean HandleUICrossing (MoonCrossingEvent *event);
+ gboolean HandleUIKeyPress (MoonKeyEvent *event);
+ gboolean HandleUIKeyRelease (MoonKeyEvent *event);
+ gboolean HandleUIButtonRelease (MoonButtonEvent *event);
+ gboolean HandleUIButtonPress (MoonButtonEvent *event);
+ gboolean HandleUIScroll (MoonScrollWheelEvent *event);
+ gboolean HandleUIFocusIn (MoonFocusEvent *event);
+ gboolean HandleUIFocusOut (MoonFocusEvent *event);
void HandleUIWindowAllocation (bool emit_resize);
void HandleUIWindowAvailable ();
void HandleUIWindowUnavailable ();
@@ -393,7 +395,7 @@
int frames;
- GdkEvent *mouse_event;
+ MoonMouseEvent *mouse_event;
// Variables for reporting FPS
MoonlightFPSReportFunc fps_report;
@@ -431,18 +433,17 @@
static void render_cb (EventObject *sender, EventArgs *calldata, gpointer closure);
static void update_input_cb (EventObject *sender, EventArgs *calldata, gpointer closure);
- static void widget_destroyed (GtkWidget *w, gpointer data);
- EventArgs* CreateArgsForEvent (int event_id, GdkEvent *event);
+ EventArgs* CreateArgsForEvent (int event_id, MoonEvent *event);
List* ElementPathToRoot (UIElement *source);
void EmitFocusChangeEvents();
static void EmitFocusChangeEventsAsync (EventObject *sender);
void FindFirstCommonElement (List *l1, int *index1, List *l2, int *index2);
- bool EmitEventOnList (int event_id, List *element_list, GdkEvent *event, int end_idx);
+ bool EmitEventOnList (int event_id, List *element_list, MoonEvent *event, int end_idx);
void UpdateCursorFromInputList ();
- bool HandleMouseEvent (int event_id, bool emit_leave, bool emit_enter, bool force_emit, GdkEvent *event);
+ bool HandleMouseEvent (int event_id, bool emit_leave, bool emit_enter, bool force_emit, MoonMouseEvent *event);
void PerformCapture (UIElement *capture);
void PerformReleaseCapture ();
@@ -495,6 +496,9 @@
void runtime_flags_set_show_fps (gboolean flag);
void runtime_flags_set_use_shapecache (gboolean flag);
+/* @GeneratePInvoke */
+MoonWindowingSystem *runtime_get_windowing_system ();
+
void runtime_shutdown (void);
G_END_DECLS
Modified: trunk/moon/src/stylus.h
===================================================================
--- trunk/moon/src/stylus.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/stylus.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -15,21 +15,10 @@
#define __STYLUS_H__
#include <glib.h>
+#include "enums.h"
#include "canvas.h"
#include "collection.h"
-enum TabletDeviceType {
- TabletDeviceTypeMouse,
- TabletDeviceTypeStylus,
- TabletDeviceTypeTouch
-};
-
-enum TouchAction {
- TouchActionDown = 1,
- TouchActionMove = 2,
- TouchActionUp = 3
-};
-
/* @Namespace=System.Windows.Input */
class StylusInfo : public DependencyObject {
protected:
Modified: trunk/moon/src/textbox.cpp
===================================================================
--- trunk/moon/src/textbox.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/textbox.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -12,7 +12,6 @@
#include <config.h>
-#include <gdk/gdkkeysyms.h>
#include <cairo.h>
#include <string.h>
@@ -32,6 +31,8 @@
#include "utils.h"
#include "uri.h"
+#include "window.h"
+
#include "geometry.h"
#include "managedtypeinfo.h"
@@ -524,39 +525,30 @@
#define SELECTION_CHANGED (1 << 0)
#define TEXT_CHANGED (1 << 1)
-#define CONTROL_MASK GDK_CONTROL_MASK
-#define SHIFT_MASK GDK_SHIFT_MASK
-#define ALT_MASK GDK_MOD1_MASK
+#define CONTROL_MASK MoonModifier_Control
+#define SHIFT_MASK MoonModifier_Shift
+#define ALT_MASK MoonModifier_Mod1
#define IsEOL(c) ((c) == '\r' || (c) == '\n')
-static GdkWindow *
-GetGdkWindow (TextBoxBase *textbox)
+static MoonWindow *
+GetWindow (TextBoxBase *textbox)
{
- MoonWindow *window;
-
if (!textbox->IsAttached ())
return NULL;
- if (!(window = textbox->GetDeployment ()->GetSurface ()->GetWindow ()))
- return NULL;
-
- return window->GetGdkWindow ();
+ return textbox->GetDeployment ()->GetSurface ()->GetWindow ();
}
-static GtkClipboard *
-GetClipboard (TextBoxBase *textbox, GdkAtom atom)
+static MoonClipboard *
+GetClipboard (TextBoxBase *textbox, MoonClipboardType clipboardType)
{
- GdkDisplay *display;
- GdkWindow *window;
-
- if (!(window = GetGdkWindow (textbox)))
+ MoonWindow *window = GetWindow(textbox);
+
+ if (!window)
return NULL;
-
- if (!(display = gdk_drawable_get_display ((GdkDrawable *) window)))
- return NULL;
-
- return gtk_clipboard_get_for_display (display, atom);
+
+ return window->GetClipboard (clipboardType);
}
void
@@ -582,14 +574,15 @@
font_source = NULL;
contentElement = NULL;
+
+ MoonWindowingSystem *ws = runtime_get_windowing_system ();
+ im_ctx = ws->CreateIMContext();
+ im_ctx->SetUsePreedit (false);
- im_ctx = gtk_im_multicontext_new ();
- gtk_im_context_set_use_preedit (im_ctx, false);
+ im_ctx->SetRetrieveSurroundingCallback ((MoonCallback)TextBoxBase::retrieve_surrounding, this);
+ im_ctx->SetDeleteSurroundingCallback ((MoonCallback)TextBoxBase::delete_surrounding, this);
+ im_ctx->SetCommitCallback ((MoonCallback)TextBoxBase::commit, this);
- g_signal_connect (im_ctx, "retrieve-surrounding", G_CALLBACK (TextBoxBase::retrieve_surrounding), this);
- g_signal_connect (im_ctx, "delete-surrounding", G_CALLBACK (TextBoxBase::delete_surrounding), this);
- g_signal_connect (im_ctx, "commit", G_CALLBACK (TextBoxBase::commit), this);
-
undo = new TextBoxUndoStack (10);
redo = new TextBoxUndoStack (10);
buffer = new TextBuffer ();
@@ -638,11 +631,35 @@
{
Control::SetIsAttached (value);
- if (value)
- gtk_im_context_set_client_window (im_ctx, GetGdkWindow (this));
+ Surface *surface = GetDeployment ()->GetSurface ();
+
+ if (value) {
+ surface->AddHandler (Surface::WindowAvailableEvent, TextBoxBase::AttachIMClientWindowCallback, this);
+ surface->AddHandler (Surface::WindowUnavailableEvent, TextBoxBase::DetachIMClientWindowCallback, this);
+ }
+ else {
+ if (surface) {
+ surface->RemoveHandler (Surface::WindowAvailableEvent, TextBoxBase::AttachIMClientWindowCallback, this);
+ surface->RemoveHandler (Surface::WindowUnavailableEvent, TextBoxBase::DetachIMClientWindowCallback, this);
+
+ DetachIMClientWindowHandler (NULL, NULL);
+ }
+ }
}
void
+TextBoxBase::AttachIMClientWindowHandler (EventObject *sender, EventArgs *calldata)
+{
+ im_ctx->SetClientWindow (GetDeployment ()->GetSurface ()->GetWindow());
+}
+
+void
+TextBoxBase::DetachIMClientWindowHandler (EventObject *sender, EventArgs *calldata)
+{
+ im_ctx->SetClientWindow (NULL);
+}
+
+void
TextBoxBase::CleanupDownloaders ()
{
Downloader *downloader;
@@ -913,7 +930,7 @@
}
bool
-TextBoxBase::KeyPressBackSpace (GdkModifierType modifiers)
+TextBoxBase::KeyPressBackSpace (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -969,7 +986,7 @@
}
bool
-TextBoxBase::KeyPressDelete (GdkModifierType modifiers)
+TextBoxBase::KeyPressDelete (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1022,7 +1039,7 @@
}
bool
-TextBoxBase::KeyPressPageDown (GdkModifierType modifiers)
+TextBoxBase::KeyPressPageDown (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1054,7 +1071,7 @@
}
bool
-TextBoxBase::KeyPressPageUp (GdkModifierType modifiers)
+TextBoxBase::KeyPressPageUp (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1086,7 +1103,7 @@
}
bool
-TextBoxBase::KeyPressDown (GdkModifierType modifiers)
+TextBoxBase::KeyPressDown (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1120,7 +1137,7 @@
}
bool
-TextBoxBase::KeyPressUp (GdkModifierType modifiers)
+TextBoxBase::KeyPressUp (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1154,7 +1171,7 @@
}
bool
-TextBoxBase::KeyPressHome (GdkModifierType modifiers)
+TextBoxBase::KeyPressHome (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1191,7 +1208,7 @@
}
bool
-TextBoxBase::KeyPressEnd (GdkModifierType modifiers)
+TextBoxBase::KeyPressEnd (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1228,7 +1245,7 @@
}
bool
-TextBoxBase::KeyPressRight (GdkModifierType modifiers)
+TextBoxBase::KeyPressRight (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1270,7 +1287,7 @@
}
bool
-TextBoxBase::KeyPressLeft (GdkModifierType modifiers)
+TextBoxBase::KeyPressLeft (MoonModifier modifiers)
{
int anchor = selection_anchor;
int cursor = selection_cursor;
@@ -1411,7 +1428,7 @@
}
void
-TextBoxBase::Paste (GtkClipboard *clipboard, const char *str)
+TextBoxBase::Paste (MoonClipboard *clipboard, const char *str)
{
int length = abs (selection_cursor - selection_anchor);
int start = MIN (selection_anchor, selection_cursor);
@@ -1477,7 +1494,7 @@
}
void
-TextBoxBase::paste (GtkClipboard *clipboard, const char *text, gpointer closure)
+TextBoxBase::paste (MoonClipboard *clipboard, const char *text, gpointer closure)
{
((TextBoxBase *) closure)->Paste (clipboard, text);
}
@@ -1485,12 +1502,12 @@
void
TextBoxBase::OnKeyDown (KeyEventArgs *args)
{
- GdkModifierType modifiers = (GdkModifierType) args->GetModifiers ();
- guint key = args->GetKeyVal ();
- GtkClipboard *clipboard;
+ MoonModifier modifiers = (MoonModifier) args->GetEvent()->GetModifiers ();
+ Key key = args->GetEvent()->GetSilverlightKey ();
+ MoonClipboard *clipboard;
bool handled = false;
- if (args->IsModifier ())
+ if (args->GetEvent()->IsModifier ())
return;
// set 'emit' to NOTHING_CHANGED so that we can figure out
@@ -1500,22 +1517,22 @@
BatchPush ();
switch (key) {
- case GDK_BackSpace:
+ case KeyBACKSPACE:
if (is_read_only)
break;
handled = KeyPressBackSpace (modifiers);
break;
- case GDK_Delete:
+ case KeyDELETE:
if (is_read_only)
break;
if ((modifiers & (CONTROL_MASK | ALT_MASK | SHIFT_MASK)) == SHIFT_MASK) {
// Shift+Delete => Cut
- if (!secret && (clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if (!secret && (clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
if (selection_cursor != selection_anchor) {
// copy selection to the clipboard and then cut
- gtk_clipboard_set_text (clipboard, GetSelectedText (), -1);
+ clipboard->SetText (GetSelectedText (), -1);
}
}
@@ -1525,122 +1542,108 @@
handled = KeyPressDelete (modifiers);
}
break;
- case GDK_Insert:
+ case KeyINSERT:
if ((modifiers & (CONTROL_MASK | ALT_MASK | SHIFT_MASK)) == SHIFT_MASK) {
// Shift+Insert => Paste
if (is_read_only)
break;
- if ((clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if ((clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
// paste clipboard contents to the buffer
- gtk_clipboard_request_text (clipboard, TextBoxBase::paste, this);
+ clipboard->AsyncGetText (TextBoxBase::paste, this);
}
handled = true;
} else if ((modifiers & (CONTROL_MASK | ALT_MASK | SHIFT_MASK)) == CONTROL_MASK) {
// Control+Insert => Copy
- if (!secret && (clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if (!secret && (clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
if (selection_cursor != selection_anchor) {
// copy selection to the clipboard
- gtk_clipboard_set_text (clipboard, GetSelectedText (), -1);
+ clipboard->SetText (GetSelectedText (), -1);
}
}
handled = true;
}
break;
- case GDK_KP_Page_Down:
- case GDK_Page_Down:
+ case KeyPAGEDOWN:
handled = KeyPressPageDown (modifiers);
break;
- case GDK_KP_Page_Up:
- case GDK_Page_Up:
+ case KeyPAGEUP:
handled = KeyPressPageUp (modifiers);
break;
- case GDK_KP_Home:
- case GDK_Home:
+ case KeyHOME:
handled = KeyPressHome (modifiers);
break;
- case GDK_KP_End:
- case GDK_End:
+ case KeyEND:
handled = KeyPressEnd (modifiers);
break;
- case GDK_KP_Right:
- case GDK_Right:
+ case KeyRIGHT:
handled = KeyPressRight (modifiers);
break;
- case GDK_KP_Left:
- case GDK_Left:
+ case KeyLEFT:
handled = KeyPressLeft (modifiers);
break;
- case GDK_KP_Down:
- case GDK_Down:
+ case KeyDOWN:
handled = KeyPressDown (modifiers);
break;
- case GDK_KP_Up:
- case GDK_Up:
+ case KeyUP:
handled = KeyPressUp (modifiers);
break;
default:
if ((modifiers & (CONTROL_MASK | ALT_MASK | SHIFT_MASK)) == CONTROL_MASK) {
switch (key) {
- case GDK_A:
- case GDK_a:
+ case KeyA:
// Ctrl+A => Select All
handled = true;
SelectAll ();
break;
- case GDK_C:
- case GDK_c:
+ case KeyC:
// Ctrl+C => Copy
- if (!secret && (clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if (!secret && (clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
if (selection_cursor != selection_anchor) {
// copy selection to the clipboard
- gtk_clipboard_set_text (clipboard, GetSelectedText (), -1);
+ clipboard->SetText (GetSelectedText (), -1);
}
}
handled = true;
break;
- case GDK_X:
- case GDK_x:
+ case KeyX:
// Ctrl+X => Cut
if (is_read_only)
break;
- if (!secret && (clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if (!secret && (clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
if (selection_cursor != selection_anchor) {
// copy selection to the clipboard and then cut
- gtk_clipboard_set_text (clipboard, GetSelectedText (), -1);
+ clipboard->SetText (GetSelectedText(), -1);
}
}
SetSelectedText ("");
handled = true;
break;
- case GDK_V:
- case GDK_v:
+ case KeyV:
// Ctrl+V => Paste
if (is_read_only)
break;
- if ((clipboard = GetClipboard (this, GDK_SELECTION_CLIPBOARD))) {
+ if ((clipboard = GetClipboard (this, MoonClipboard_Clipboard))) {
// paste clipboard contents to the buffer
- gtk_clipboard_request_text (clipboard, TextBoxBase::paste, this);
+ clipboard->AsyncGetText (TextBoxBase::paste, this);
}
handled = true;
break;
- case GDK_Y:
- case GDK_y:
+ case KeyY:
// Ctrl+Y => Redo
if (!is_read_only) {
handled = true;
Redo ();
}
break;
- case GDK_Z:
- case GDK_z:
+ case KeyZ:
// Ctrl+Z => Undo
if (!is_read_only) {
handled = true;
@@ -1668,18 +1671,18 @@
void
TextBoxBase::PostOnKeyDown (KeyEventArgs *args)
{
- guint key = args->GetKeyVal ();
+ MoonKeyEvent *event = args->GetEvent();
+ guint key = event->GetPlatformKeyval ();
gunichar c;
// Note: we don't set Handled=true because anything we handle here, we
// want to bubble up.
-
- if (!is_read_only && gtk_im_context_filter_keypress (im_ctx, args->GetEvent ())) {
+ if (!is_read_only && im_ctx->FilterKeyPress (event)) {
need_im_reset = true;
return;
}
- if (is_read_only || args->IsModifier ())
+ if (is_read_only || event->IsModifier ())
return;
// set 'emit' to NOTHING_CHANGED so that we can figure out
@@ -1689,13 +1692,13 @@
BatchPush ();
switch (key) {
- case GDK_Return:
+ case KeyENTER:
KeyPressUnichar ('\r');
break;
default:
- if ((args->GetModifiers () & (CONTROL_MASK | ALT_MASK)) == 0) {
+ if ((event->GetModifiers () & (CONTROL_MASK | ALT_MASK)) == 0) {
// normal character input
- if ((c = args->GetUnicode ()))
+ if ((c = event->GetUnicode ()))
KeyPressUnichar (c);
}
break;
@@ -1710,7 +1713,7 @@
TextBoxBase::OnKeyUp (KeyEventArgs *args)
{
if (!is_read_only) {
- if (gtk_im_context_filter_keypress (im_ctx, args->GetEvent ()))
+ if (im_ctx->FilterKeyPress (args->GetEvent()))
need_im_reset = true;
}
}
@@ -1766,7 +1769,7 @@
}
gboolean
-TextBoxBase::delete_surrounding (GtkIMContext *context, int offset, int n_chars, gpointer user_data)
+TextBoxBase::delete_surrounding (MoonIMContext *context, int offset, int n_chars, gpointer user_data)
{
return ((TextBoxBase *) user_data)->DeleteSurrounding (offset, n_chars);
}
@@ -1777,13 +1780,13 @@
const char *text = GetActualText ();
const char *cursor = g_utf8_offset_to_pointer (text, selection_cursor);
- gtk_im_context_set_surrounding (im_ctx, text, -1, cursor - text);
+ im_ctx->SetSurroundingText (text, -1, cursor - text);
return true;
}
gboolean
-TextBoxBase::retrieve_surrounding (GtkIMContext *context, gpointer user_data)
+TextBoxBase::retrieve_surrounding (MoonIMContext *context, gpointer user_data)
{
return ((TextBoxBase *) user_data)->RetrieveSurrounding ();
}
@@ -1879,7 +1882,7 @@
}
void
-TextBoxBase::commit (GtkIMContext *context, const char *str, gpointer user_data)
+TextBoxBase::commit (MoonIMContext *context, const char *str, gpointer user_data)
{
((TextBoxBase *) user_data)->Commit (str);
}
@@ -1888,7 +1891,7 @@
TextBoxBase::ResetIMContext ()
{
if (need_im_reset) {
- gtk_im_context_reset (im_ctx);
+ im_ctx->Reset ();
need_im_reset = false;
}
}
@@ -1938,7 +1941,7 @@
ResetIMContext ();
- if (args->GetClickCount () == 3) {
+ if (((MoonButtonEvent*)args->GetEvent())->GetNumberOfClicks () == 3) {
// Note: Silverlight doesn't implement this, but to
// be consistent with other TextEntry-type
// widgets in Gtk+, we will.
@@ -1992,7 +1995,7 @@
{
int anchor = selection_anchor;
int cursor = selection_cursor;
- GtkClipboard *clipboard;
+ MoonClipboard *clipboard;
double x, y;
if (selecting) {
@@ -2011,9 +2014,9 @@
SyncAndEmit ();
- if (!secret && (clipboard = GetClipboard (this, GDK_SELECTION_PRIMARY))) {
+ if (!secret && (clipboard = GetClipboard (this, MoonClipboard_Primary))) {
// copy the selection to the primary clipboard
- gtk_clipboard_set_text (clipboard, GetSelectedText (), -1);
+ clipboard->SetText (GetSelectedText (), -1);
}
}
}
@@ -2035,7 +2038,7 @@
view->OnLostFocus ();
if (!is_read_only) {
- gtk_im_context_focus_out (im_ctx);
+ im_ctx->FocusOut ();
need_im_reset = true;
}
}
@@ -2049,7 +2052,7 @@
view->OnGotFocus ();
if (!is_read_only) {
- gtk_im_context_focus_in (im_ctx);
+ im_ctx->FocusIn ();
need_im_reset = true;
}
}
@@ -2546,9 +2549,9 @@
if (focused) {
if (is_read_only) {
ResetIMContext ();
- gtk_im_context_focus_out (im_ctx);
+ im_ctx->FocusOut ();
} else {
- gtk_im_context_focus_in (im_ctx);
+ im_ctx->FocusIn ();
}
}
} else if (args->GetId () == TextBox::MaxLengthProperty) {
@@ -3120,7 +3123,6 @@
// TextBoxView
//
-#define CURSOR_BLINK_TIMEOUT_DEFAULT 900
#define CURSOR_BLINK_ON_MULTIPLIER 2
#define CURSOR_BLINK_OFF_MULTIPLIER 1
#define CURSOR_BLINK_DELAY_MULTIPLIER 3
@@ -3187,30 +3189,15 @@
static guint
GetCursorBlinkTimeout (TextBoxView *view)
{
- GtkSettings *settings;
MoonWindow *window;
- GdkScreen *screen;
- GdkWindow *widget;
- guint timeout;
if (!view->IsAttached ())
return CURSOR_BLINK_TIMEOUT_DEFAULT;
if (!(window = view->GetDeployment ()->GetSurface ()->GetWindow ()))
return CURSOR_BLINK_TIMEOUT_DEFAULT;
-
- if (!(widget = window->GetGdkWindow ()))
- return CURSOR_BLINK_TIMEOUT_DEFAULT;
-
- if (!(screen = gdk_drawable_get_screen ((GdkDrawable *) widget)))
- return CURSOR_BLINK_TIMEOUT_DEFAULT;
-
- if (!(settings = gtk_settings_get_for_screen (screen)))
- return CURSOR_BLINK_TIMEOUT_DEFAULT;
-
- g_object_get (settings, "gtk-cursor-blink-time", &timeout, NULL);
-
- return timeout;
+
+ return runtime_get_windowing_system ()->GetCursorBlinkTimeout (window);
}
void
@@ -3326,7 +3313,6 @@
TextBoxView::UpdateCursor (bool invalidate)
{
int cur = textbox->GetCursor ();
- GdkRectangle area;
Rect rect;
// invalidate current cursor rect
@@ -3338,10 +3324,9 @@
// transform the cursor rect into absolute coordinates for the IM context
rect = cursor.Transform (&absolute_xform);
- area = rect.ToGdkRectangle ();
+
+ textbox->im_ctx->SetCursorLocation (rect);
- gtk_im_context_set_cursor_location (textbox->im_ctx, &area);
-
textbox->EmitCursorPositionChanged (cursor.height, cursor.x, cursor.y);
// invalidate the new cursor rect
Modified: trunk/moon/src/textbox.h
===================================================================
--- trunk/moon/src/textbox.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/textbox.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -13,7 +13,6 @@
#ifndef __TEXTBOX_H__
#define __TEXTBOX_H__
-#include <gtk/gtk.h>
#include <cairo.h>
#include "fontsource.h"
@@ -25,8 +24,8 @@
#include "brush.h"
#include "fonts.h"
#include "size.h"
+#include "pal.h"
-
/* @Namespace=System.Windows.Input */
class InputMethod : public DependencyObject {
protected:
@@ -134,7 +133,7 @@
int selection_anchor;
int selection_cursor;
double cursor_offset;
- GtkIMContext *im_ctx;
+ MoonIMContext *im_ctx;
TextBuffer *buffer;
TextBoxView *view;
int max_length;
@@ -159,17 +158,20 @@
static void mouse_left_button_multi_click (EventObject *sender, EventArgs *args, gpointer closure);
void OnMouseLeftButtonMultiClick (MouseButtonEventArgs *args);
- // GtkIMContext events
- static gboolean delete_surrounding (GtkIMContext *context, int offset, int n_chars, gpointer user_data);
- static gboolean retrieve_surrounding (GtkIMContext *context, gpointer user_data);
- static void commit (GtkIMContext *context, const char *str, gpointer user_data);
+ // MoonIMContext events
+ EVENTHANDLER (TextBoxBase, AttachIMClientWindow, EventObject, EventArgs);
+ EVENTHANDLER (TextBoxBase, DetachIMClientWindow, EventObject, EventArgs);
+
+ static gboolean delete_surrounding (MoonIMContext *context, int offset, int n_chars, gpointer user_data);
+ static gboolean retrieve_surrounding (MoonIMContext *context, gpointer user_data);
+ static void commit (MoonIMContext *context, const char *str, gpointer user_data);
bool DeleteSurrounding (int offset, int n_chars);
void Commit (const char *str);
bool RetrieveSurrounding ();
- // GtkClipboard callbacks
- static void paste (GtkClipboard *clipboard, const char *text, gpointer closure);
- void Paste (GtkClipboard *clipboard, const char *text);
+ // Clipboard callbacks
+ static void paste (MoonClipboard *clipboard, const char *text, gpointer closure);
+ void Paste (MoonClipboard *clipboard, const char *text);
//
// Cursor Navigation
@@ -187,16 +189,16 @@
//
bool KeyPressUnichar (gunichar c);
- bool KeyPressBackSpace (GdkModifierType modifiers);
- bool KeyPressDelete (GdkModifierType modifiers);
- bool KeyPressPageDown (GdkModifierType modifiers);
- bool KeyPressPageUp (GdkModifierType modifiers);
- bool KeyPressHome (GdkModifierType modifiers);
- bool KeyPressEnd (GdkModifierType modifiers);
- bool KeyPressRight (GdkModifierType modifiers);
- bool KeyPressLeft (GdkModifierType modifiers);
- bool KeyPressDown (GdkModifierType modifiers);
- bool KeyPressUp (GdkModifierType modifiers);
+ bool KeyPressBackSpace (MoonModifier modifiers);
+ bool KeyPressDelete (MoonModifier modifiers);
+ bool KeyPressPageDown (MoonModifier modifiers);
+ bool KeyPressPageUp (MoonModifier modifiers);
+ bool KeyPressHome (MoonModifier modifiers);
+ bool KeyPressEnd (MoonModifier modifiers);
+ bool KeyPressRight (MoonModifier modifiers);
+ bool KeyPressLeft (MoonModifier modifiers);
+ bool KeyPressDown (MoonModifier modifiers);
+ bool KeyPressUp (MoonModifier modifiers);
void ResetIMContext ();
Modified: trunk/moon/src/type-generated.cpp
===================================================================
--- trunk/moon/src/type-generated.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/type-generated.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -152,7 +152,9 @@
const int Surface::ResizeEvent = 4;
const int Surface::SourceDownloadCompleteEvent = 5;
const int Surface::SourceDownloadProgressChangedEvent = 6;
-const int Surface::ZoomedEvent = 7;
+const int Surface::WindowAvailableEvent = 7;
+const int Surface::WindowUnavailableEvent = 8;
+const int Surface::ZoomedEvent = 9;
const int TextBox::SelectionChangedEvent = 22;
const int TextBox::TextChangedEvent = 23;
const int TextBoxBase::CursorPositionChangedEvent = 20;
@@ -208,7 +210,7 @@
const char *PLAYLISTROOT_Events [] = { "BufferingProgressChanged", "BufferUnderflow", "CurrentStateChanged", "DownloadProgressChanged", "EntryChanged", "MediaEnded", "MediaError", "OpenCompleted", "Opening", "Pause", "Play", "SeekCompleted", "Seeking", "Stop", NULL };
const char *POPUP_Events [] = { "Closed", "Opened", NULL };
const Type::Kind STRING_Interfaces[] = { Type::ICOMPARABLE, Type::ICOMPARABLE_STRING, Type::ICONVERTIBLE, Type::IEQUATABLE_STRING, Type::IFORMATTABLE };
-const char *SURFACE_Events [] = { "Error", "FullScreenChange", "Load", "Resize", "SourceDownloadComplete", "SourceDownloadProgressChanged", "Zoomed", NULL };
+const char *SURFACE_Events [] = { "Error", "FullScreenChange", "Load", "Resize", "SourceDownloadComplete", "SourceDownloadProgressChanged", "WindowAvailable", "WindowUnavailable", "Zoomed", NULL };
const char *TEXTBOX_Events [] = { "SelectionChanged", "TextChanged", NULL };
const char *TEXTBOXBASE_Events [] = { "CursorPositionChanged", "ModelChanged", NULL };
const char *TIMELINE_Events [] = { "Completed", NULL };
@@ -517,7 +519,7 @@
types [(int) Type::STYLUSINFO] = new Type (deployment, Type::STYLUSINFO, Type::DEPENDENCY_OBJECT, false, false, "StylusInfo", 0, 1, NULL, 0, NULL, false, (create_inst_func *) stylus_info_new, NULL);
types [(int) Type::STYLUSPOINT] = new Type (deployment, Type::STYLUSPOINT, Type::DEPENDENCY_OBJECT, false, false, "StylusPoint", 0, 1, NULL, 0, NULL, true, (create_inst_func *) stylus_point_new, NULL);
types [(int) Type::STYLUSPOINT_COLLECTION] = new Type (deployment, Type::STYLUSPOINT_COLLECTION, Type::DEPENDENCY_OBJECT_COLLECTION, false, false, "StylusPointCollection", 0, 3, NULL, 0, NULL, true, (create_inst_func *) stylus_point_collection_new, NULL);
- types [(int) Type::SURFACE] = new Type (deployment, Type::SURFACE, Type::EVENTOBJECT, false, false, "Surface", 7, 8, SURFACE_Events, 0, NULL, false, NULL, NULL);
+ types [(int) Type::SURFACE] = new Type (deployment, Type::SURFACE, Type::EVENTOBJECT, false, false, "Surface", 9, 10, SURFACE_Events, 0, NULL, false, NULL, NULL);
types [(int) Type::SYSTEMTIMESOURCE] = new Type (deployment, Type::SYSTEMTIMESOURCE, Type::TIMESOURCE, false, false, "SystemTimeSource", 0, 2, NULL, 0, NULL, true, NULL, NULL);
types [(int) Type::TEXTBLOCK] = new Type (deployment, Type::TEXTBLOCK, Type::FRAMEWORKELEMENT, false, false, "TextBlock", 0, 19, NULL, 0, NULL, true, (create_inst_func *) text_block_new, "Inlines");
types [(int) Type::TEXTBOX] = new Type (deployment, Type::TEXTBOX, Type::TEXTBOXBASE, false, false, "TextBox", 2, 24, TEXTBOX_Events, 0, NULL, true, (create_inst_func *) text_box_new, NULL);
Modified: trunk/moon/src/uielement.cpp
===================================================================
--- trunk/moon/src/uielement.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/uielement.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -28,6 +28,7 @@
#include "media.h"
#include "resources.h"
#include "popup.h"
+#include "window.h"
#include "provider.h"
//#define DEBUG_INVALIDATE 0
@@ -1020,13 +1021,13 @@
}
bool
-UIElement::EmitKeyDown (GdkEventKey *event)
+UIElement::EmitKeyDown (MoonKeyEvent *event)
{
return Emit (KeyDownEvent, new KeyEventArgs (event));
}
bool
-UIElement::EmitKeyUp (GdkEventKey *event)
+UIElement::EmitKeyUp (MoonKeyEvent *event)
{
return Emit (KeyUpEvent, new KeyEventArgs (event));
}
Modified: trunk/moon/src/uielement.h
===================================================================
--- trunk/moon/src/uielement.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/uielement.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -333,12 +333,12 @@
//
// EmitKeyDown:
//
- bool EmitKeyDown (GdkEventKey *key);
+ bool EmitKeyDown (MoonKeyEvent *key);
//
// EmitKeyUp:
//
- bool EmitKeyUp (GdkEventKey *key);
+ bool EmitKeyUp (MoonKeyEvent *key);
//
// EmitGotFocus:
Deleted: trunk/moon/src/window-gtk.cpp
===================================================================
--- trunk/moon/src/window-gtk.cpp 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/window-gtk.cpp 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,651 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * window-gtk.cpp: MoonWindow implementation using gtk widgets.
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2007-2008 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#include "window-gtk.h"
-#include "deployment.h"
-#include "timemanager.h"
-
-MoonWindowGtk::MoonWindowGtk (bool fullscreen, int w, int h, MoonWindow *parent, Surface *surface)
- : MoonWindow (w, h, surface)
-{
- this->fullscreen = fullscreen;
-
- if (fullscreen)
- InitializeFullScreen(parent);
- else
- InitializeNormal();
-}
-
-MoonWindowGtk::~MoonWindowGtk ()
-{
- /* gtk_widget_destroy can cause reentry (into another plugin if this destruction causes layout changes) */
- DeploymentStack deployment_push_pop;
- DisableEvents ();
- if (widget != NULL)
- gtk_widget_destroy (widget);
-}
-
-GdkWindow *
-MoonWindowGtk::GetGdkWindow ()
-{
- GdkWindow *parent_window = gtk_widget_get_parent_window (widget);
- if (parent_window == NULL)
- parent_window = widget->window;
-
- g_object_ref (parent_window);
- return parent_window;
-}
-
-void
-MoonWindowGtk::InitializeFullScreen (MoonWindow *parent)
-{
- widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- // only fullscreen on the monitor the plugin is on
- GdkWindow *gdk = parent->GetGdkWindow ();
- int monitor = gdk_screen_get_monitor_at_window (gdk_screen_get_default (), gdk);
- GdkRectangle bounds;
- gdk_screen_get_monitor_geometry (gdk_screen_get_default (), monitor, &bounds);
- width = bounds.width;
- height = bounds.height;
- gtk_window_move (GTK_WINDOW (widget), bounds.x, bounds.y);
-
- gtk_window_fullscreen (GTK_WINDOW (widget));
-
- InitializeCommon ();
-
- Show();
-
- g_object_unref (gdk);
-}
-
-void
-MoonWindowGtk::InitializeNormal ()
-{
- if (width == -1 || height == -1) {
- g_warning ("you must specify width and height when creating a non-fullscreen gtk window");
- width = 0;
- height = 0;
- }
-
- widget = gtk_event_box_new ();
-
- gtk_event_box_set_visible_window (GTK_EVENT_BOX (widget), false);
-
- InitializeCommon ();
-
- Show ();
-}
-
-void
-MoonWindowGtk::InitializeCommon ()
-{
- // don't let gtk clear the window we'll do all the drawing.
- //gtk_widget_set_app_paintable (widget, true);
- gtk_widget_set_double_buffered (widget, false);
- gtk_widget_set_size_request (widget, width, height);
-
- g_signal_connect (widget, "size-allocate", G_CALLBACK (widget_size_allocate), this);
- g_signal_connect (widget, "destroy", G_CALLBACK (widget_destroyed), this);
-
- gtk_widget_add_events (widget,
- GDK_POINTER_MOTION_MASK |
-#if !DEBUG
- GDK_POINTER_MOTION_HINT_MASK |
-#endif
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- ((moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) != 0 ? GDK_SCROLL_MASK : 0) |
- GDK_FOCUS_CHANGE_MASK);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
-}
-
-void
-MoonWindowGtk::Resize (int width, int height)
-{
- gtk_widget_set_size_request (widget, width, height);
- gtk_widget_queue_resize (widget);
-}
-
-/* XPM */
-static const char *dot[] = {
- "18 18 4 1",
- " c None",
- ". c #808080",
- "+ c #303030",
- "@ c #000000",
- ".+. ",
- "@@@ ",
- ".@. ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " "
-};
-
-/* XPM */
-static const char *eraser[] = {
- "20 20 49 1",
- " c None",
- ". c #000000",
- "+ c #858585",
- "@ c #E8E8E8",
- "# c #E9E9E9",
- "$ c #E7E7E7",
- "% c #E2E2E2",
- "& c #D6D6D6",
- "* c #7D7D7D",
- "= c #565656",
- "- c #E1E1E1",
- "; c #E0E0E0",
- "> c #DEDEDE",
- ", c #DFDFDF",
- "' c #474747",
- ") c #6C6C6C",
- "! c #B0B0B0",
- "~ c #E3E3E3",
- "{ c #4E4E4E",
- "] c #636363",
- "^ c #E6E6E6",
- "/ c #505050",
- "( c #4A4A4A",
- "_ c #C7C7C7",
- ": c #272727",
- "< c #797979",
- "[ c #E5E5E5",
- "} c #DDDDDD",
- "| c #9C9C9C",
- "1 c #232323",
- "2 c #E4E4E4",
- "3 c #656565",
- "4 c #313131",
- "5 c #EAEAEA",
- "6 c #ECECEC",
- "7 c #EEEEEE",
- "8 c #EFEFEF",
- "9 c #F0F0F0",
- "0 c #999999",
- "a c #5D5D5D",
- "b c #343434",
- "c c #757575",
- "d c #383838",
- "e c #CECECE",
- "f c #A9A9A9",
- "g c #6F6F6F",
- "h c #B3B3B3",
- "i c #787878",
- "j c #3F3F3F",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ........... ",
- " .+@#@@@$$%&*. ",
- " =-;%>>>>>>>,' ",
- " )!~>>>>>>>>>>{ ",
- " ]^>>>>>>>>>,,/ ",
- " (_;>>>>>>>>,>&: ",
- " <[,}>>>>>>>-,| ",
- " 1[-;>>>>>>>$2,3 ",
- " 45678999998550a ",
- " b~,,,,,,,,,;$c ",
- " de-,,,,,,,,,fg ",
- " bh%%,,;}}}>>ij ",
- " ............ ",
- " "
-};
-
-void
-MoonWindowGtk::SetBackgroundColor (Color *color)
-{
- GdkColor gdk_color;
- gdk_color.red = color->r * 0xffff;
- gdk_color.green = color->g * 0xffff;
- gdk_color.blue = color->b * 0xffff;
-
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &gdk_color);
-
- MoonWindow::SetBackgroundColor (color);
-}
-
-void
-MoonWindowGtk::SetCursor (MouseCursor cursor)
-{
- if (widget->window) {
-
- GdkCursor *c = NULL;
- switch (cursor) {
- case MouseCursorDefault:
- c = NULL;
- break;
- case MouseCursorArrow:
- c = gdk_cursor_new (GDK_LEFT_PTR);
- break;
- case MouseCursorHand:
- c = gdk_cursor_new (GDK_HAND2);
- break;
- case MouseCursorWait:
- c = gdk_cursor_new (GDK_WATCH);
- break;
- case MouseCursorIBeam:
- c = gdk_cursor_new (GDK_XTERM);
- break;
- case MouseCursorStylus:
- c = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), gdk_pixbuf_new_from_xpm_data ((const char**) dot), 0, 0);
- break;
- case MouseCursorEraser:
- c = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), gdk_pixbuf_new_from_xpm_data ((const char**) eraser), 8, 8);
- break;
- case MouseCursorSizeNS:
- c = gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW);
- break;
- case MouseCursorSizeWE:
- c = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW);
- break;
- case MouseCursorNone:
- // Silverlight display no cursor if the enumeration value is invalid (e.g. -1)
- default:
- //from gdk-cursor doc :"To make the cursor invisible, use gdk_cursor_new_from_pixmap() to create a cursor with no pixels in it."
- GdkPixmap *empty = gdk_bitmap_create_from_data (NULL, "0x00", 1, 1);
- GdkColor empty_color = {0, 0, 0, 0};
- c = gdk_cursor_new_from_pixmap (empty, empty, &empty_color, &empty_color, 0, 0);
- g_object_unref (empty);
- break;
- }
-
-
- gdk_window_set_cursor (widget->window, c);
-
- if (c)
- gdk_cursor_unref (c);
- }
-}
-
-void
-MoonWindowGtk::Invalidate (Rect r)
-{
- gtk_widget_queue_draw_area (widget,
- (int) (widget->allocation.x + r.x),
- (int) (widget->allocation.y + r.y),
- (int) r.width, (int)r.height);
-}
-
-void
-MoonWindowGtk::ProcessUpdates ()
-{
- if (widget->window)
- gdk_window_process_updates (widget->window, false);
-}
-
-gboolean
-MoonWindowGtk::HandleEvent (XEvent *event)
-{
- // nothing to do here, since we don't pump events into the gtk
- // window, gtk calls our signal handlers directly.
- return TRUE;
-}
-
-void
-MoonWindowGtk::Show ()
-{
- gtk_widget_show (widget);
-
- // The window has to be realized for this call to work
- gtk_widget_set_extension_events (widget, GDK_EXTENSION_EVENTS_CURSOR);
- /* we need to explicitly enable the devices */
- for (GList *l = gdk_devices_list(); l; l = l->next) {
-#if THIS_NOLONGER_BREAKS_LARRYS_MOUSE
- GdkDevice *device = GDK_DEVICE(l->data);
- //if (!device->has_cursor)
- gdk_device_set_mode (device, GDK_MODE_SCREEN);
-#endif
- }
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
-}
-
-void
-MoonWindowGtk::Hide ()
-{
- gtk_widget_hide (widget);
-}
-
-void
-MoonWindowGtk::EnableEvents (bool first)
-{
- g_signal_connect (widget, "expose-event", G_CALLBACK (expose_event), this);
- g_signal_connect (widget, "motion-notify-event", G_CALLBACK (motion_notify), this);
- g_signal_connect (widget, "enter-notify-event", G_CALLBACK (crossing_notify), this);
- g_signal_connect (widget, "leave-notify-event", G_CALLBACK (crossing_notify), this);
- g_signal_connect (widget, "key-press-event", G_CALLBACK (key_press), this);
- g_signal_connect (widget, "key-release-event", G_CALLBACK (key_release), this);
- g_signal_connect (widget, "button-press-event", G_CALLBACK (button_press), this);
- g_signal_connect (widget, "button-release-event", G_CALLBACK (button_release), this);
- g_signal_connect (widget, "scroll-event", G_CALLBACK (scroll), this);
- g_signal_connect (widget, "focus-in-event", G_CALLBACK (focus_in), this);
- g_signal_connect (widget, "focus-out-event", G_CALLBACK (focus_out), this);
-
- if (first) {
- g_signal_connect (widget, "realize", G_CALLBACK (realized), this);
- g_signal_connect (widget, "unrealize", G_CALLBACK (unrealized), this);
-
- if (GTK_WIDGET_REALIZED (widget))
- realized (widget, this);
- }
-}
-
-void
-MoonWindowGtk::DisableEvents ()
-{
- g_signal_handlers_disconnect_matched (widget, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, this);
-}
-
-void
-MoonWindowGtk::GrabFocus ()
-{
- gtk_widget_grab_focus (widget);
-}
-
-bool
-MoonWindowGtk::HasFocus ()
-{
- return GTK_WIDGET_HAS_FOCUS (widget);
-}
-
-gboolean
-MoonWindowGtk::expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)data;
-
- window->SetCurrentDeployment ();
-
- if (!window->surface)
- return true;
-
- // we draw to a backbuffer pixmap, then transfer the contents
- // to the widget's window.
- GdkPixmap *pixmap = gdk_pixmap_new (widget->window,
- MAX (event->area.width, 1), MAX (event->area.height, 1), -1);
-
- window->surface->PaintToDrawable (pixmap,
- gdk_drawable_get_visual (widget->window),
- event,
- widget->allocation.x,
- widget->allocation.y,
- window->GetTransparent (),
- true);
-
- GdkGC *gc = gdk_gc_new (pixmap);
-
- gdk_gc_set_clip_region (gc, event->region);
-
- gdk_draw_drawable (widget->window, gc, pixmap,
- 0, 0,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
-
- g_object_unref (pixmap);
- g_object_unref (gc);
-
- return true;
-}
-
-gboolean
-MoonWindowGtk::button_press (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)data;
-
- window->SetCurrentDeployment ();
-
- if (event->button != 1 && event->button != 3)
- return false;
-
- if (window->surface)
- window->surface->HandleUIButtonPress (event);
-
- // If we don't support right clicks (i.e. inside the browser)
- // return false here
- if (event->button == 3 && (moonlight_flags & RUNTIME_INIT_DESKTOP_EXTENSIONS) == 0)
- return false;
-
- // ignore HandleUIButtonPress's return value, and always
- // return true here, or it gets bubbled up to firefox.
- return true;
-}
-
-gboolean
-MoonWindowGtk::button_release (GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface)
- window->surface->HandleUIButtonRelease (event);
- // ignore HandleUIButtonRelease's return value, and always
- // return true here, or it gets bubbled up to firefox.
- return true;
-}
-
-gboolean
-MoonWindowGtk::scroll (GtkWidget *widget, GdkEventScroll *event, gpointer data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface)
- window->surface->HandleUIScroll (event);
- // ignore HandleUIScroll's return value, and always
- // return true here, or it gets bubbled up to firefox.
- return true;
-}
-
-gboolean
-MoonWindowGtk::motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface)
- window->surface->HandleUIMotion (event);
- // ignore HandleUIMotion's return value, and always
- // return true here, or it gets bubbled up to firefox.
- return true;
-}
-
-gboolean
-MoonWindowGtk::crossing_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUICrossing (event);
- return true;
- }
-
- return false;
-}
-
-gboolean
-MoonWindowGtk::focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUIFocusIn (event);
- return true;
- }
-
- return false;
-}
-
-gboolean
-MoonWindowGtk::focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUIFocusOut (event);
- return true;
- }
-
- return false;
-}
-
-gboolean
-MoonWindowGtk::key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUIKeyPress (event);
- return true;
- }
-
- return false;
-}
-
-gboolean
-MoonWindowGtk::key_release (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUIKeyRelease (event);
- return true;
- }
-
- return false;
-}
-
-void
-MoonWindowGtk::widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
-{
- MoonWindowGtk *window = (MoonWindowGtk*)data;
-
- window->SetCurrentDeployment ();
-
- //printf ("Surface::size-allocate callback: current = %dx%d; new = %dx%d\n",
- // s->width, s->height, allocation->width, allocation->height);
-
- bool emit_resize = false;
-
- if (window->width != allocation->width || window->height != allocation->height) {
- window->width = allocation->width;
- window->height = allocation->height;
-
- emit_resize = true;
- }
-
- if (window->surface)
- window->surface->HandleUIWindowAllocation (emit_resize);
-}
-
-void
-MoonWindowGtk::widget_destroyed (GtkWidget *widget, gpointer user_data)
-{
- MoonWindowGtk* window = (MoonWindowGtk*)user_data;
-
- window->widget = NULL;
- if (window->surface)
- window->surface->HandleUIWindowDestroyed (window);
-}
-
-gboolean
-MoonWindowGtk::realized (GtkWidget *widget, gpointer user_data)
-{
- MoonWindowGtk* window = (MoonWindowGtk*)user_data;
-
-#ifdef USE_XRANDR
-#if INTEL_DRIVERS_STOP_SUCKING
- // apparently the i965 drivers blank external screens when
- // getting the screen info (um, ugh?). needless to say, this
- // annoyance is worse than not using the monitor's refresh as
- // the upper bound for our fps.
- //
- // http://lists.freedesktop.org/archives/xorg/2007-August/027616.html
- int event_base, error_base;
- GdkWindow *gdk_root = gtk_widget_get_root_window (widget);
- Display *dpy = GDK_WINDOW_XDISPLAY(gdk_root);
- Window root = GDK_WINDOW_XID (gdk_root);
- if (XRRQueryExtension (dpy, &event_base, &error_base)) {
- XRRScreenConfiguration *info = XRRGetScreenInfo (dpy,
- root);
- short rate = XRRConfigCurrentRate (info);
- printf ("screen refresh rate = %d\n", rate);
- if (window->surface)
- window->surface->GetTimeManager()->SetMaximumRefreshRate (rate);
- XRRFreeScreenConfigInfo (info);
- }
-#endif
-#endif
-
- window->SetCurrentDeployment ();
-
- if (window->surface) {
- window->surface->HandleUIWindowUnavailable ();
- window->surface->HandleUIWindowAvailable ();
- }
-
-#if SANITY
- Deployment::SetCurrent (NULL);
-#endif
-
- return true;
-}
-
-gboolean
-MoonWindowGtk::unrealized (GtkWidget *widget, gpointer user_data)
-{
- MoonWindowGtk* window = (MoonWindowGtk*)user_data;
-
- window->SetCurrentDeployment ();
-
- if (window->surface)
- window->surface->HandleUIWindowUnavailable ();
-
-#if SANITY
- Deployment::SetCurrent (NULL);
-#endif
-
- return true;
-}
Deleted: trunk/moon/src/window-gtk.h
===================================================================
--- trunk/moon/src/window-gtk.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/window-gtk.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * window-gtk.h: MoonWindow implementation using gtk widgets.
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2007 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#ifndef __MOON_WINDOW_GTK_H__
-#define __MOON_WINDOW_GTK_H__
-
-#include <glib.h>
-#include <gtk/gtk.h>
-
-#include "window.h"
-#include "runtime.h"
-
-/* @Namespace=System.Windows */
-class MoonWindowGtk : public MoonWindow {
-public:
- /* @GenerateCBinding,GeneratePInvoke */
- MoonWindowGtk (bool fullscreen, int w = -1, int h = -1, MoonWindow* parent = NULL, Surface *surface = NULL);
-
- virtual ~MoonWindowGtk ();
-
- virtual void Resize (int width, int height);
- virtual void SetCursor (MouseCursor cursor);
- virtual void SetBackgroundColor (Color *color);
- virtual void Invalidate (Rect r);
- virtual void ProcessUpdates ();
- virtual gboolean HandleEvent (XEvent *event);
- virtual void Show ();
- virtual void Hide ();
- virtual void EnableEvents (bool first);
- virtual void DisableEvents ();
-
- virtual void GrabFocus ();
- virtual bool HasFocus ();
-
- GtkWidget* GetWidget() { return widget; }
-
- /* @GenerateCBinding,GeneratePInvoke */
- void *GetNativeWidget () { return GetWidget (); } // same as GetWidget, just without bleeding GtkWidget into the cbindings
-
-
- virtual bool IsFullScreen () { return fullscreen; }
-
- virtual GdkWindow* GetGdkWindow ();
-
-private:
- GtkWidget *widget;
- bool fullscreen;
-
- static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data);
- static gboolean motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data);
- static gboolean crossing_notify (GtkWidget *widget, GdkEventCrossing *event, gpointer user_data);
- static gboolean key_press (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
- static gboolean key_release (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
- static gboolean button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
- static gboolean button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
- static gboolean scroll (GtkWidget *widget, GdkEventScroll *event, gpointer user_data);
- static gboolean focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
- static gboolean focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
- static gboolean realized (GtkWidget *widget, gpointer user_data);
- static gboolean unrealized (GtkWidget *widget, gpointer user_data);
-
- static void widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data);
- static void widget_destroyed (GtkWidget *widget, gpointer user_data);
-
- void InitializeFullScreen (MoonWindow *parent);
- void InitializeNormal ();
- void InitializeCommon ();
-};
-
-#endif /* __MOON_WINDOW_GTK_H__ */
Deleted: trunk/moon/src/window.h
===================================================================
--- trunk/moon/src/window.h 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/src/window.h 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * window.h:
- *
- * Contact:
- * Moonlight List (moonlig...@lists.ximian.com)
- *
- * Copyright 2007-2008 Novell, Inc. (http://www.novell.com)
- *
- * See the LICENSE file included with the distribution for details.
- *
- */
-
-#ifndef __MOON_WINDOW__
-#define __MOON_WINDOW__
-
-#include <gtk/gtk.h>
-
-#define Visual _XxVisual
-#define Region _XxRegion
-#include <gdk/gdkx.h>
-#undef Visual
-#undef Region
-
-class MoonWindow;
-
-#include "rect.h"
-#include "enums.h"
-#include "color.h"
-
-class Surface;
-
-/* @Namespace=System.Windows */
-class MoonWindow {
- public:
- MoonWindow (int w, int h, Surface *s = NULL) : width(w), height(h), surface(s), transparent(false) { }
-
- virtual ~MoonWindow () { }
-
- virtual void Resize (int width, int height) = 0;
-
- virtual void SetCursor (MouseCursor cursor) = 0;
- virtual void Invalidate (Rect r) = 0;
- virtual void Invalidate () { Invalidate (Rect (0, 0, width, height)); }
- virtual void ProcessUpdates () = 0;
-
- virtual gboolean HandleEvent (XEvent *event) = 0;
-
- virtual void Show () = 0;
- virtual void Hide () = 0;
-
- virtual void EnableEvents (bool first) = 0;
- virtual void DisableEvents () = 0;
-
- virtual void GrabFocus () = 0;
- virtual bool HasFocus () = 0;
-
- int GetWidth () { return width; }
- int GetHeight () { return height; }
-
- virtual void SetSurface (Surface* s) { surface = s; }
- Surface *GetSurface () { return surface; }
-
- /* @GenerateCBinding,GeneratePInvoke */
- void SetTransparent (bool flag) { if (transparent != flag) Invalidate (); transparent = flag; }
-
- virtual void SetBackgroundColor (Color *color) { Invalidate (); };
-
- /* @GenerateCBinding,GeneratePInvoke */
- bool GetTransparent () { return transparent; }
-
- virtual bool IsFullScreen () = 0;
-
- virtual GdkWindow* GetGdkWindow () = 0;
-
- void SetCurrentDeployment ();
-
- protected:
- int width;
- int height;
- Surface *surface;
- bool transparent;
-};
-
-#endif /* __MOON_WINDOW__ */
Modified: trunk/moon/test/parsertest/Makefile.am
===================================================================
--- trunk/moon/test/parsertest/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/test/parsertest/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -5,5 +5,5 @@
parsertest_LDADD = $(MOON_PROG_LIBS)
-parsertest_CPPFLAGS = $(MOON_PROG_CFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/src/asf
+parsertest_CPPFLAGS = $(MOON_PROG_CFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/src/asf -I$(top_srcdir)/src/pal
Modified: trunk/moon/test/sizes/Makefile.am
===================================================================
--- trunk/moon/test/sizes/Makefile.am 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/test/sizes/Makefile.am 2010-01-06 23:53:29 UTC (rev 149148)
@@ -5,5 +5,5 @@
sizes_LDADD = $(MOON_PROG_LIBS)
-sizes_CPPFLAGS = $(MOON_PROG_CFLAGS) -I$(top_srcdir)/src/ -I$(top_srcdir)/src/asf
+sizes_CPPFLAGS = $(MOON_PROG_CFLAGS) -I$(top_srcdir)/src/ -I$(top_srcdir)/src/asf -I$(top_srcdir)/src/pal
Modified: trunk/moon/tools/generators/Generator.cs
===================================================================
--- trunk/moon/tools/generators/Generator.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/tools/generators/Generator.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -1270,11 +1270,13 @@
{
string srcdir = Path.Combine (Environment.CurrentDirectory, "src");
string plugindir = Path.Combine (Environment.CurrentDirectory, "plugin");
+ string paldir = Path.Combine (srcdir, "pal");
List<string> all_files = new List<string> ();
all_files.AddRange (Directory.GetFiles (srcdir, "*.h"));
all_files.AddRange (Directory.GetFiles (plugindir, "*.h"));
-
+ all_files.AddRange (Directory.GetFiles (paldir, "*.h"));
+
RemoveExcludedSrcFiles (srcdir, all_files);
Tokenizer tokenizer = new Tokenizer (all_files.ToArray ());
@@ -2097,6 +2099,7 @@
header.AppendLine ("#include <glib.h>");
header.AppendLine ("#include <cairo.h>");
header.AppendLine ();
+ header.AppendLine ("#include \"pal.h\"");
header.AppendLine ("#include \"enums.h\"");
header.AppendLine ();
foreach (MemberInfo member in info.Children.Values) {
Modified: trunk/moon/tools/generators/MemberInfo.cs
===================================================================
--- trunk/moon/tools/generators/MemberInfo.cs 2010-01-06 22:07:09 UTC (rev 149147)
+++ trunk/moon/tools/generators/MemberInfo.cs 2010-01-06 23:53:29 UTC (rev 149148)
@@ -88,7 +88,8 @@
if (Header == null || Header == string.Empty)
return false;
- return Path.GetFileName (Path.GetDirectoryName (Header)) == "src";
+ return (Path.GetFileName (Path.GetDirectoryName (Header)) == "src" ||
+ Path.GetFileName (Path.GetDirectoryName (Header)) == "pal");
}
}