Merge branch 'develop' into glwidget-gtk3

This commit is contained in:
Jarl Gullberg 2017-06-25 13:45:05 +02:00
commit 13494f515c
No known key found for this signature in database
GPG key ID: 750FF6F6BDA72D23
13 changed files with 533 additions and 192 deletions

416
.gitignore vendored
View file

@ -1,31 +1,63 @@
# =============================================
# Visual Studio & Associated technologies
# =============================================
## Ignore Visual Studio temporary files, build results, and ## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons. ## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files # User-specific files
*.suo *.suo
*.user *.user
*.userosscache
*.sln.docstates *.sln.docstates
# Xamarin Studio / monodevelop user-specific # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
*.dll.mdb
*.exe.mdb
# Build results # Build results
[Dd]ebug/ [Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/ [Rr]elease/
[Rr]eleases/
x64/ x64/
build/ x86/
bld/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results # MSTest test Results
[Tt]est[Rr]esult*/ [Tt]est[Rr]esult*/
[Bb]uild[Ll]og.* [Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c *_i.c
*_p.c *_p.c
*_i.h
*.ilk *.ilk
*.meta *.meta
*.obj *.obj
@ -45,24 +77,31 @@ build/
*.vssscc *.vssscc
.builds .builds
*.pidb *.pidb
*.log *.svclog
*.scc *.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files # Visual C++ cache files
ipch/ ipch/
*.aps *.aps
*.ncb *.ncb
*.opendb
*.opensdf *.opensdf
*.sdf *.sdf
*.cachefile *.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler # Visual Studio profiler
*.psess *.psess
*.vsp *.vsp
*.vspx *.vspx
*.sap
# Other Visual Studio data # TFS 2012 Local Workspace
.vs/ $tf/
# Guidance Automation Toolkit # Guidance Automation Toolkit
*.gpState *.gpState
@ -70,6 +109,10 @@ ipch/
# ReSharper is a .NET coding add-in # ReSharper is a .NET coding add-in
_ReSharper*/ _ReSharper*/
*.[Rr]e[Ss]harper *.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in # TeamCity is a build add-in
_TeamCity* _TeamCity*
@ -77,9 +120,21 @@ _TeamCity*
# DotCover is a Code Coverage Tool # DotCover is a Code Coverage Tool
*.dotCover *.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch # NCrunch
*.ncrunch* _NCrunch_*
.*crunch*.local.xml .*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder # Installshield output folder
[Ee]xpress/ [Ee]xpress/
@ -98,57 +153,158 @@ DocProject/Help/html
publish/ publish/
# Publish Web Output # Publish Web Output
*.Publish.xml *.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Enable nuget.exe in the .nuget folder (though normally executables are not tracked) # Microsoft Azure Web App publish settings. Comment the next line if you want to
!.nuget/NuGet.exe # checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# Windows Azure Build Output # NuGet Packages
csx *.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef *.build.csdef
# Windows Store app package directory # Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/ AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others # Others
sql/
*.Cache
ClientBin/ ClientBin/
[Ss]tyle[Cc]op.*
~$* ~$*
*~ *~
*.dbmdl *.dbmdl
*.[Pp]ublish.xml *.dbproj.schemaview
*.jfm
*.pfx *.pfx
*.publishsettings *.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects # RIA/Silverlight projects
Generated_Code/ Generated_Code/
# Backup & report files from converting an old project file to a newer # Backup & report files from converting an old project file
# Visual Studio version. Backup files are not needed, because we have git ;-) # to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/ _UpgradeReport_Files/
Backup*/ Backup*/
UpgradeLog*.XML UpgradeLog*.XML
UpgradeLog*.htm UpgradeLog*.htm
# SQL Server files # SQL Server files
App_Data/*.mdf *.mdf
App_Data/*.ldf *.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
#LightSwitch generated files # Microsoft Fakes
GeneratedArtifacts/ FakesAssemblies/
_Pvt_Extensions/
ModelManifest.xml # GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# ========================= # =========================
# Windows detritus # Windows detritus
# ========================= # =========================
# Windows image file caches # Windows thumbnail cache files
Thumbs.db Thumbs.db
ehthumbs.db ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file # Folder config file
Desktop.ini Desktop.ini
@ -156,8 +312,46 @@ Desktop.ini
# Recycle Bin used on file shares # Recycle Bin used on file shares
$RECYCLE.BIN/ $RECYCLE.BIN/
# Mac desktop service store files # Windows Installer files
.DS_Store *.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# ===========
# Macintosh
# ===========
# General
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# =================================================== # ===================================================
# Exclude F# project specific directories and files # Exclude F# project specific directories and files
@ -189,3 +383,165 @@ docs/content/license.md
docs/content/release-notes.md docs/content/release-notes.md
.fake .fake
docs/tools/FSharp.Formatting.svclog docs/tools/FSharp.Formatting.svclog
# ===========
# Covers JetBrains IDEs: Rider, IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# ===========
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# ============
# MonoDevelop
# ============
#User Specific
*.userprefs
*.usertasks
#Mono Project Files
*.pidb
*.resources
test-results/
# ================
# Linux-specific
# ================
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# ============
# VS Code
# ============
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# ============
# Emacs
# ============
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# ===========
# Vim
# ===========
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags

View file

@ -750,9 +750,6 @@
<Compile Include="Platform\MacOS\CarbonWindowInfo.cs"> <Compile Include="Platform\MacOS\CarbonWindowInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Platform\MacOS\Carbon\CarbonAPI.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Platform\MacOS\Carbon\MacOSKeys.cs"> <Compile Include="Platform\MacOS\Carbon\MacOSKeys.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>

View file

@ -45,9 +45,12 @@ namespace OpenTK.Platform.Linux
{ {
internal const string lib = "libinput"; internal const string lib = "libinput";
[DllImport(lib, EntryPoint = "libinput_udev_create_for_seat", CallingConvention = CallingConvention.Cdecl)] [DllImport(lib, EntryPoint = "libinput_udev_create_context", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CreateContext(InputInterface @interface, public static extern IntPtr CreateContext(InputInterface @interface,
IntPtr user_data, IntPtr udev, string seat_id); IntPtr user_data, IntPtr udev);
[DllImport(lib, EntryPoint = "libinput_udev_assign_seat", CallingConvention = CallingConvention.Cdecl)]
public static extern int AssignSeat(IntPtr libinput, string seat_id);
[DllImport(lib, EntryPoint = "libinput_destroy", CallingConvention = CallingConvention.Cdecl)] [DllImport(lib, EntryPoint = "libinput_destroy", CallingConvention = CallingConvention.Cdecl)]
public static extern void DestroyContext(IntPtr libinput); public static extern void DestroyContext(IntPtr libinput);
@ -192,31 +195,6 @@ namespace OpenTK.Platform.Linux
HorizontalScroll = 1 HorizontalScroll = 1
} }
struct Fixed24
{
internal readonly int Value;
public static implicit operator double(Fixed24 n)
{
long l = ((1023L + 44L) << 52) + (1L << 51) + n.Value;
unsafe
{
double d = *(double*)&l;
return d - (3L << 43);
}
}
public static implicit operator float(Fixed24 n)
{
return (float)(double)n;
}
public static explicit operator int(Fixed24 n)
{
return n.Value >> 8;
}
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
class InputInterface class InputInterface
{ {
@ -275,14 +253,14 @@ namespace OpenTK.Platform.Linux
public EvdevButton Button { get { return (EvdevButton)GetButton(@event); } } public EvdevButton Button { get { return (EvdevButton)GetButton(@event); } }
public uint ButtonCount { get { return GetButtonCount(@event); } } public uint ButtonCount { get { return GetButtonCount(@event); } }
public ButtonState ButtonState { get { return GetButtonState(@event); } } public ButtonState ButtonState { get { return GetButtonState(@event); } }
public PointerAxis Axis { get { return GetAxis(@event); } } public bool HasAxis(PointerAxis axis) { return HasAxis(@event, axis) != 0; }
public Fixed24 AxisValue { get { return GetAxisValue(@event); } } public double AxisValue(PointerAxis axis) { return GetAxisValue(@event, axis); }
public Fixed24 DeltaX { get { return GetDX(@event); } } public double DeltaX { get { return GetDX(@event); } }
public Fixed24 DeltaY { get { return GetDY(@event); } } public double DeltaY { get { return GetDY(@event); } }
public Fixed24 X { get { return GetAbsX(@event); } } public double X { get { return GetAbsX(@event); } }
public Fixed24 Y { get { return GetAbsY(@event); } } public double Y { get { return GetAbsY(@event); } }
public Fixed24 TransformedX(int width) { return GetAbsXTransformed(@event, width); } public double TransformedX(int width) { return GetAbsXTransformed(@event, width); }
public Fixed24 TransformedY(int height) { return GetAbsYTransformed(@event, height); } public double TransformedY(int height) { return GetAbsYTransformed(@event, height); }
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_time", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_time", CallingConvention = CallingConvention.Cdecl)]
static extern uint GetTime(IntPtr @event); static extern uint GetTime(IntPtr @event);
@ -302,29 +280,29 @@ namespace OpenTK.Platform.Linux
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_button_state", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_button_state", CallingConvention = CallingConvention.Cdecl)]
static extern ButtonState GetButtonState(IntPtr @event); static extern ButtonState GetButtonState(IntPtr @event);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_axis", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_has_axis", CallingConvention = CallingConvention.Cdecl)]
static extern PointerAxis GetAxis(IntPtr @event); static extern int HasAxis(IntPtr @event, PointerAxis axis);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_axis_value", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_axis_value", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetAxisValue(IntPtr @event); static extern double GetAxisValue(IntPtr @event, PointerAxis axis);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_dx", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_dx", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetDX(IntPtr @event); static extern double GetDX(IntPtr @event);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_dy", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_dy", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetDY(IntPtr @event); static extern double GetDY(IntPtr @event);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_x", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_x", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetAbsX(IntPtr @event); static extern double GetAbsX(IntPtr @event);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_y", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_y", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetAbsY(IntPtr @event); static extern double GetAbsY(IntPtr @event);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_x_transformed", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_x_transformed", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetAbsXTransformed(IntPtr @event, int width); static extern double GetAbsXTransformed(IntPtr @event, int width);
[DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_y_transformed", CallingConvention = CallingConvention.Cdecl)] [DllImport(LibInput.lib, EntryPoint = "libinput_event_pointer_get_absolute_y_transformed", CallingConvention = CallingConvention.Cdecl)]
static extern Fixed24 GetAbsYTransformed(IntPtr @event, int height); static extern double GetAbsYTransformed(IntPtr @event, int height);
} }
} }

View file

@ -67,9 +67,6 @@ namespace OpenTK.Platform.Linux
{ {
base.SwapBuffers(); base.SwapBuffers();
bo_next = LockSurface();
int fb = GetFramebuffer(bo_next);
if (is_flip_queued) if (is_flip_queued)
{ {
// Todo: if we don't wait for the page flip, // Todo: if we don't wait for the page flip,
@ -84,6 +81,8 @@ namespace OpenTK.Platform.Linux
} }
} }
bo_next = LockSurface();
int fb = GetFramebuffer(bo_next);
QueueFlip(fb); QueueFlip(fb);
} }

View file

@ -314,7 +314,7 @@ namespace OpenTK.Platform.Linux
} }
Debug.Print("[Input] Udev.New() = {0:x}", udev); Debug.Print("[Input] Udev.New() = {0:x}", udev);
input_context = LibInput.CreateContext(input_interface, IntPtr.Zero, udev, "seat0"); input_context = LibInput.CreateContext(input_interface, IntPtr.Zero, udev);
if (input_context == IntPtr.Zero) if (input_context == IntPtr.Zero)
{ {
Debug.Print("[Input] LibInput.CreateContext({0:x}) failed.", udev); Debug.Print("[Input] LibInput.CreateContext({0:x}) failed.", udev);
@ -323,6 +323,16 @@ namespace OpenTK.Platform.Linux
} }
Debug.Print("[Input] LibInput.CreateContext({0:x}) = {1:x}", udev, input_context); Debug.Print("[Input] LibInput.CreateContext({0:x}) = {1:x}", udev, input_context);
string seat_id = "seat0";
int seat_assignment = LibInput.AssignSeat(input_context, seat_id);
if (seat_assignment == -1)
{
Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1} failed.", input_context, seat_id);
Interlocked.Increment(ref exit);
return;
}
Debug.Print("[Input] LibInput.AssignSeat({0:x}) = {1}", input_context, seat_id);
fd = LibInput.GetFD(input_context); fd = LibInput.GetFD(input_context);
if (fd < 0) if (fd < 0)
{ {
@ -475,21 +485,13 @@ namespace OpenTK.Platform.Linux
{ {
mouse.State.SetIsConnected(true); mouse.State.SetIsConnected(true);
double value = e.AxisValue; if (e.HasAxis(PointerAxis.HorizontalScroll))
PointerAxis axis = e.Axis;
switch (axis)
{ {
case PointerAxis.HorizontalScroll: mouse.State.SetScrollRelative((float)e.AxisValue(PointerAxis.HorizontalScroll), 0);
mouse.State.SetScrollRelative((float)value, 0); }
break; if (e.HasAxis(PointerAxis.VerticalScroll))
{
case PointerAxis.VerticalScroll: mouse.State.SetScrollRelative(0, (float)e.AxisValue(PointerAxis.VerticalScroll));
mouse.State.SetScrollRelative(0, (float)value);
break;
default:
Debug.Print("[Input] Unknown scroll axis {0}.", axis);
break;
} }
} }
} }
@ -508,7 +510,7 @@ namespace OpenTK.Platform.Linux
void HandlePointerMotion(MouseDevice mouse, PointerEvent e) void HandlePointerMotion(MouseDevice mouse, PointerEvent e)
{ {
Vector2 delta = new Vector2((float)e.X, (float)e.Y); Vector2 delta = new Vector2((float)e.DeltaX, (float)e.DeltaY);
if (mouse != null) if (mouse != null)
{ {
mouse.State.SetIsConnected(true); mouse.State.SetIsConnected(true);
@ -526,12 +528,12 @@ namespace OpenTK.Platform.Linux
if (mouse != null) if (mouse != null)
{ {
mouse.State.SetIsConnected(true); mouse.State.SetIsConnected(true);
mouse.State.Position = new Vector2(e.X, e.Y); mouse.State.Position = new Vector2((float)e.X, (float)e.Y);
} }
CursorPosition = new Vector2( CursorPosition = new Vector2(
e.TransformedX(bounds.Width), (float)e.TransformedX(bounds.Width),
e.TransformedY(bounds.Height)); (float)e.TransformedY(bounds.Height));
UpdateCursor(); UpdateCursor();
} }

View file

@ -366,6 +366,7 @@ namespace OpenTK.Platform.Linux
if (disposing) if (disposing)
{ {
Debug.Print("[KMS] Destroying window {0}.", window.Handle); Debug.Print("[KMS] Destroying window {0}.", window.Handle);
Drm.SetCursor(window.FD, window.DisplayDevice.Id, 0, 0, 0, 0, 0);
window.Dispose(); window.Dispose();
Gbm.DestroySurface(window.Handle); Gbm.DestroySurface(window.Handle);
} }

View file

@ -1,78 +0,0 @@
#region License
//
// The Open Toolkit Library License
//
// Copyright (c) 2006 - 2010 the Open Toolkit library.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
#endregion
// Created by Erik Ylvisaker on 3/17/08.
using System;
using System.Runtime.InteropServices;
namespace OpenTK.Platform.MacOS.Carbon
{
#region --- Types defined in HIGeometry.h ---
[StructLayout(LayoutKind.Sequential)]
internal struct HIPoint
{
public float X;
public float Y;
public HIPoint(float x, float y)
{
X = x;
Y = y;
}
public HIPoint(double x, double y)
: this((float)x, (float)y)
{ }
}
[StructLayout(LayoutKind.Sequential)]
internal struct HISize
{
public float Width;
public float Height;
}
[StructLayout(LayoutKind.Sequential)]
internal struct HIRect
{
public HIPoint Origin;
public HISize Size;
public override string ToString()
{
return string.Format(
"Rect: [{0}, {1}, {2}, {3}]", Origin.X, Origin.Y, Size.Width, Size.Height);
}
}
#endregion
}

View file

@ -160,7 +160,32 @@ namespace OpenTK.Platform.MacOS
// Not the _stret version, perhaps because a NSPoint fits in one register? // Not the _stret version, perhaps because a NSPoint fits in one register?
// thefiddler: gcc is indeed using objc_msgSend for NSPoint on i386 // thefiddler: gcc is indeed using objc_msgSend for NSPoint on i386
[DllImport (LibObjC, EntryPoint="objc_msgSend")] [DllImport (LibObjC, EntryPoint="objc_msgSend")]
public extern static NSPoint SendPoint(IntPtr receiver, IntPtr selector); public extern static NSPointF SendPointF(IntPtr receiver, IntPtr selector);
[DllImport (LibObjC, EntryPoint="objc_msgSend")]
public extern static NSPointD SendPointD(IntPtr receiver, IntPtr selector);
public static NSPoint SendPoint(IntPtr receiver, IntPtr selector)
{
NSPoint r = new NSPoint();
unsafe
{
if (IntPtr.Size == 4)
{
NSPointF pf = SendPointF(receiver, selector);
r.X.Value = *(IntPtr *)&pf.X;
r.Y.Value = *(IntPtr *)&pf.Y;
}
else
{
NSPointD pd = SendPointD(receiver, selector);
r.X.Value = *(IntPtr *)&pd.X;
r.Y.Value = *(IntPtr *)&pd.Y;
}
}
return r;
}
[DllImport (LibObjC, EntryPoint="objc_msgSend_stret")] [DllImport (LibObjC, EntryPoint="objc_msgSend_stret")]
extern static void SendRect(out NSRect retval, IntPtr receiver, IntPtr selector); extern static void SendRect(out NSRect retval, IntPtr receiver, IntPtr selector);

View file

@ -45,6 +45,18 @@ namespace OpenTK.Platform.MacOS
{ {
IntPtr value; IntPtr value;
public IntPtr Value
{
get
{
return value;
}
set
{
this.value = value;
}
}
public static implicit operator NSFloat(float v) public static implicit operator NSFloat(float v)
{ {
NSFloat f; NSFloat f;
@ -106,7 +118,7 @@ namespace OpenTK.Platform.MacOS
} }
else else
{ {
return *(float*)&f.value; return *(double*)&f.value;
} }
} }
} }
@ -179,5 +191,21 @@ namespace OpenTK.Platform.MacOS
return new RectangleF(s.Location, s.Size); return new RectangleF(s.Location, s.Size);
} }
} }
}
// Using IntPtr in NSFloat cause that if imported function
// return struct that consist of them you will get wrong data
// This types are used for such function.
[StructLayout(LayoutKind.Sequential)]
struct NSPointF
{
public float X;
public float Y;
}
[StructLayout(LayoutKind.Sequential)]
struct NSPointD
{
public double X;
public double Y;
}
}

View file

@ -273,7 +273,7 @@ namespace OpenTK.Platform.MacOS
case CGEventType.RightMouseDragged: case CGEventType.RightMouseDragged:
case CGEventType.OtherMouseDragged: case CGEventType.OtherMouseDragged:
{ {
Carbon.HIPoint p = CG.EventGetLocation(@event); NSPoint p = CG.EventGetLocation(@event);
CursorState.X = (int)Math.Round(p.X); CursorState.X = (int)Math.Round(p.X);
CursorState.Y = (int)Math.Round(p.Y); CursorState.Y = (int)Math.Round(p.Y);
} }
@ -1045,7 +1045,15 @@ namespace OpenTK.Platform.MacOS
void IMouseDriver2.SetPosition(double x, double y) void IMouseDriver2.SetPosition(double x, double y)
{ {
CG.SetLocalEventsSuppressionInterval(0.0); CG.SetLocalEventsSuppressionInterval(0.0);
CG.WarpMouseCursorPosition(new Carbon.HIPoint(x, y));
NSPoint p = new NSPoint();
unsafe
{
p.X.Value = *(IntPtr *)&x;
p.Y.Value = *(IntPtr *)&y;
}
CG.WarpMouseCursorPosition(p);
} }
#endregion #endregion

View file

@ -60,9 +60,9 @@ namespace OpenTK.Platform.MacOS
{ {
const string lib = "/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices"; const string lib = "/System/Library/Frameworks/ApplicationServices.framework/Versions/Current/ApplicationServices";
// CGPoint -> HIPoint // CGPoint -> NSPoint
// CGSize -> HISize // CGSize -> NSSize
// CGRect -> HIRect // CGRect -> NSRect
[DllImport(lib,EntryPoint="CGGetActiveDisplayList")] [DllImport(lib,EntryPoint="CGGetActiveDisplayList")]
internal unsafe static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr* activeDspys, out int dspyCnt); internal unsafe static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr* activeDspys, out int dspyCnt);
@ -75,15 +75,15 @@ namespace OpenTK.Platform.MacOS
// first parameter slot. This is normally handled automatically // first parameter slot. This is normally handled automatically
// by gcc/clang, but here we have to do it ourselves. // by gcc/clang, but here we have to do it ourselves.
// See "Listing 4" on https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW3 // See "Listing 4" on https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/LowLevelABI/130-IA-32_Function_Calling_Conventions/IA32.html#//apple_ref/doc/uid/TP40002492-SW3
internal unsafe static HIRect DisplayBounds(IntPtr display) internal unsafe static NSRect DisplayBounds(IntPtr display)
{ {
HIRect rect; NSRect rect;
DisplayBounds(out rect, display); DisplayBounds(out rect, display);
return rect; return rect;
} }
[DllImport(lib, EntryPoint = "CGDisplayBounds")] [DllImport(lib, EntryPoint = "CGDisplayBounds")]
unsafe static extern void DisplayBounds(out HIRect rect, IntPtr display); unsafe static extern void DisplayBounds(out NSRect rect, IntPtr display);
[DllImport(lib,EntryPoint="CGDisplayPixelsWide")] [DllImport(lib,EntryPoint="CGDisplayPixelsWide")]
internal static extern int DisplayPixelsWide(IntPtr display); internal static extern int DisplayPixelsWide(IntPtr display);
@ -116,7 +116,7 @@ namespace OpenTK.Platform.MacOS
internal static extern IntPtr DisplaySwitchToMode(IntPtr display, IntPtr displayMode); internal static extern IntPtr DisplaySwitchToMode(IntPtr display, IntPtr displayMode);
[DllImport(lib, EntryPoint = "CGWarpMouseCursorPosition")] [DllImport(lib, EntryPoint = "CGWarpMouseCursorPosition")]
internal static extern CGError WarpMouseCursorPosition(HIPoint newCursorPosition); internal static extern CGError WarpMouseCursorPosition(NSPoint newCursorPosition);
[DllImport(lib, EntryPoint = "CGCursorIsVisible")] [DllImport(lib, EntryPoint = "CGCursorIsVisible")]
internal static extern bool CursorIsVisible(); internal static extern bool CursorIsVisible();

View file

@ -66,7 +66,32 @@ namespace OpenTK.Platform.MacOS
CGEventField field); CGEventField field);
[DllImport(lib, EntryPoint = "CGEventGetLocation")] [DllImport(lib, EntryPoint = "CGEventGetLocation")]
internal static extern Carbon.HIPoint EventGetLocation(CGEventRef @event); internal static extern NSPointF EventGetLocationF(CGEventRef @event);
[DllImport(lib, EntryPoint = "CGEventGetLocation")]
internal static extern NSPointD EventGetLocationD(CGEventRef @event);
internal static NSPoint EventGetLocation(CGEventRef @event)
{
NSPoint r = new NSPoint();
unsafe {
if (IntPtr.Size == 4)
{
NSPointF pf = EventGetLocationF(@event);
r.X.Value = *(IntPtr *)&pf.X;
r.Y.Value = *(IntPtr *)&pf.Y;
}
else
{
NSPointD pd = EventGetLocationD(@event);
r.X.Value = *(IntPtr *)&pd.X;
r.Y.Value = *(IntPtr *)&pd.Y;
}
}
return r;
}
} }
enum CGEventTapLocation enum CGEventTapLocation

View file

@ -109,8 +109,8 @@ namespace OpenTK.Platform.MacOS
} }
HIRect bounds = CG.DisplayBounds(currentDisplay); NSRect bounds = CG.DisplayBounds(currentDisplay);
Rectangle newRect = new Rectangle((int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height); Rectangle newRect = new Rectangle((int)bounds.Location.X, (int)bounds.Location.Y, (int)bounds.Size.Width, (int)bounds.Size.Height);
Debug.Print("Display {0} bounds: {1}", i, newRect); Debug.Print("Display {0} bounds: {1}", i, newRect);