Commit Graph

321 Commits

Author SHA1 Message Date
bors-servo 5481f56375 Auto merge of #135 - burtonageo:master, r=pcwalton
Add NSData and associated constants

Adds:

- NSData
- NSDataReadingOptions
- NSDataBase64EncodingOptions
- NSDataBase64DecodingOptions
- NSDataWritingOptions
- NSDataSearchOptions

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/135)
<!-- Reviewable:end -->
2016-07-06 12:18:48 -07:00
George Burton 3c86fc88bb Add NSData and associated constants 2016-07-03 22:13:58 +01:00
bors-servo c98663a2e0 Auto merge of #134 - burtonageo:master, r=jdm
Add NSPasteboard and associated APIs

Adds:

- NSPasteboard
- NSPasteboardItem
- NSPasteboardReading
- NSPasteboardWriting
- NSPasteboardReadingOptions
- NSPasteboardWritingOptions

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/134)
<!-- Reviewable:end -->
2016-07-03 09:13:35 -07:00
George Burton 6367782ef8 Add NSPasteboard, NSPasteboardItem, NSPasteboardReading, NSPasteboardWriting, NSPasteboardReadingOptions, NSPasteboardWriting options, and various other constants 2016-07-03 15:08:09 +01:00
bors-servo 45fa6dc471 Auto merge of #133 - mitchmindtree:data_type_constants, r=metajack
Add missing "Types for Standard Data" constants.

This adds bindings to cocoa's "Types for Standard Data". I believe these are necessary for registering an `NSDraggingDestination` as a receiver for certain kinds of data types.

Here are the cocoa references for:
- [Types for Standard Data (OS X v10.6 and later)](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/#//apple_ref/doc/constant_group/Types_for_Standard_Data_OS_X_v10.6_and_later_)
- [Types for Standard Data (OS X v10.5 and earlier)](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSPasteboard_Class/#//apple_ref/doc/constant_group/Types_for_Standard_Data_OS_X_v10.5_and_earlier_)

Relevant to tomaka/glutin#496

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/133)
<!-- Reviewable:end -->
2016-06-24 10:20:58 -05:00
mitchmindtree a7b905f263 Add missing cocoa Data Type constants 2016-06-24 15:48:16 +10:00
Patrick Walton daac2c1cc1 0.4.4 2016-06-10 18:41:45 -07:00
bors-servo 78cebf2d68 Auto merge of #132 - pcwalton:runloop, r=metajack
Add bindings for `+[NSRunLoop currentRunLoop]` and `-[NSRunLoop performSelector:target:argument:order:modes:]`

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/132)
<!-- Reviewable:end -->
2016-06-10 20:34:46 -05:00
Patrick Walton 866cdb1ec8 Add bindings for +[NSRunLoop currentRunLoop] and
`-[NSRunLoop performSelector:target:argument:order:modes:]`
2016-06-10 18:34:41 -07:00
Patrick Walton 9c1ae89a9e 0.4.3 2016-06-08 10:30:12 -07:00
bors-servo 8bcff922a3 Auto merge of #131 - pcwalton:fix-nsanyeventmask, r=metajack
appkit: Lengthen `NSAnyEventMask` to (-1 as u64) rather than (-1 as u32), to fix the problem whereby windows don't reappear and don't appear on top on startup.

The window restoration feature in Mac OS X from Lion onward prevents
windows from appearing until restoration is complete and the app is
launched. Internally, the persistent UI restorer detects the app launch
by listening to the Carbon event `kAEOpenApplication`, which, as an
Apple event, has the event class `kEventClassAppleEvent`.

Like `-[NSApplication run]` does, Glutin uses the method
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]` to
pump the application event loop. The event mask provided is an
`NSEventMask`; events that do not match this mask are filtered out. When
pumping the Carbon event loop, the Cocoa framework internally converts
this `NSEventMask` to a Carbon event mask. The logic to perform this
conversion proceeds in two steps:

1. If the provided `NSEventMask` is exactly equal to `NSAnyEventMask`,
then the rest of the logic is skipped and the resulting Carbon event
mask is a null mask--i.e. a mask that matches all events.

2. Otherwise, the framework constructs a blank Carbon mask--that is, a
mask that matches no events at all. The various bits of the
`NSEventMask` are examined, translated to their Carbon equivalents, and
added to the mask. Then that Carbon mask is returned.

In Glutin prior to this patch, our definition of `NSAnyEventMask` was a
mask that effectively matched all events but was not equal to the real
`NSAnyEventMask` that, for example, `-[NSApplication run]` supplies to
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]`. This
means that our code causes the system to take path (2) above, whereas
standard Cocoa apps take path (1). Now it might seem that these paths
are equivalent, but in fact they are very different. This is because
*there are classes of Carbon events that do not correspond to Cocoa
events selectable via `NSEventMask`*. One of these Carbon-only event
types is Apple events.

This fact is what made Glutin apps prior to this patch go wrong. The
Carbon framework would deliver the `kAEOpenApplication` event to the
application, but it was always masked out and ignored because the
`NSEventMask` we supplied to `-[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]` did not translate to a
Carbon event mask that included Apple events. This, in turn, caused the
persistent UI restorer to never notice that the app finished launching.
Thus the flag that inhibited windows from appearing would never be
cleared, and all windows would end up invisible.

This patch fixes the issue by lengthening `NSAnyEventMask` to its true
64-bit value, allowing the expected Carbon event filter to be used
during app startup and enabling the app startup event to be handled
properly.

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/131)
<!-- Reviewable:end -->
2016-06-08 09:00:30 -05:00
Patrick Walton 44d3744515 appkit: Lengthen NSAnyEventMask to (-1 as u64) rather than (-1 as
u32), to fix the problem whereby windows don't reappear and don't appear
on top on startup.

The window restoration feature in Mac OS X from Lion onward prevents
windows from appearing until restoration is complete and the app is
launched. Internally, the persistent UI restorer detects the app launch
by listening to the Carbon event `kAEOpenApplication`, which, as an
Apple event, has the event class `kEventClassAppleEvent`.

Like `-[NSApplication run]` does, Glutin uses the method
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]` to
pump the application event loop. The event mask provided is an
`NSEventMask`; events that do not match this mask are filtered out. When
pumping the Carbon event loop, the Cocoa framework internally converts
this `NSEventMask` to a Carbon event mask. The logic to perform this
conversion proceeds in two steps:

1. If the provided `NSEventMask` is exactly equal to `NSAnyEventMask`,
then the rest of the logic is skipped and the resulting Carbon event
mask is a null mask--i.e. a mask that matches all events.

2. Otherwise, the framework constructs a blank Carbon mask--that is, a
mask that matches no events at all. The various bits of the
`NSEventMask` are examined, translated to their Carbon equivalents, and
added to the mask. Then that Carbon mask is returned.

In Glutin prior to this patch, our definition of `NSAnyEventMask` was a
mask that effectively matched all events but was not equal to the real
`NSAnyEventMask` that, for example, `-[NSApplication run]` supplies to
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]`. This
means that our code causes the system to take path (2) above, whereas
standard Cocoa apps take path (1). Now it might seem that these paths
are equivalent, but in fact they are very different. This is because
*there are classes of Carbon events that do not correspond to Cocoa
events selectable via `NSEventMask`*. One of these Carbon-only event
types is Apple events.

This fact is what made Glutin apps prior to this patch go wrong. The
Carbon framework would deliver the `kAEOpenApplication` event to the
application, but it was always masked out and ignored because the
`NSEventMask` we supplied to `-[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]` did not translate to a
Carbon event mask that included Apple events. This, in turn, caused the
persistent UI restorer to never notice that the app finished launching.
Thus the flag that inhibited windows from appearing would never be
cleared, and all windows would end up invisible.

This patch fixes the issue by lengthening `NSAnyEventMask` to its true
64-bit value, allowing the expected Carbon event filter to be used
during app startup and enabling the app startup event to be handled
properly.
2016-06-07 22:23:11 -07:00
bors-servo df3d4d1f4c Auto merge of #130 - edunham:readme, r=jdm
add README

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/130)
<!-- Reviewable:end -->
2016-06-07 05:19:06 -05:00
E. Dunham ccf5a63e8c add README 2016-06-06 23:01:19 -07:00
Patrick Walton 32de713f33 0.4.2 2016-06-02 15:29:24 -07:00
bors-servo a103706181 Auto merge of #129 - pcwalton:rect-additions, r=metajack
Add bindings to `NSInsetRect` and `NSRectToCGRect`, and make various geometry types copyable.

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/129)
<!-- Reviewable:end -->
2016-05-27 15:52:41 -05:00
Patrick Walton 37b5ce6113 Add bindings to NSInsetRect and NSRectToCGRect, and make various
geometry types copyable.
2016-05-27 13:25:32 -07:00
Patrick Walton 5fef233f64 0.4.1 2016-05-16 11:24:02 -07:00
bors-servo 24f7593061 Auto merge of #125 - pcwalton:menu-additions, r=larsbergstrom
Add bindings for a few more menu-related functions.

Bindings added include:

* `-[NSApplication mainMenu]`
* `-[NSApplication setWindowsMenu:]`
* `+[NSMenu alloc]`
* `-[NSMenu initWithTitle:]`
* `-[NSMenu itemAtIndex:]`

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/125)
<!-- Reviewable:end -->
2016-05-16 10:05:07 -07:00
bors-servo 06220ff121 Auto merge of #128 - servo:bump, r=Wafflespeanut
Bump to 0.4.0

Version 0.3.4 should be yanked because bitflags >= 0.6 is incompatible with Rust <1.8
and this breaks downstream crates.

Unfortunately, we can't depend on bitflags >=0.5, <0.8 because it doesn't compile with
bitflags 0.5-6 because of https://github.com/rust-lang-nursery/bitflags/issues/39.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/128)
<!-- Reviewable:end -->
2016-05-16 07:17:14 -07:00
Anthony Ramine 127f5ded12 Bump to 0.4.0
Version 0.3.4 should be yanked because bitflags >= 0.6 is incompatible with Rust <1.8
and this breaks downstream crates.

Unfortunately, we can't depend on bitflags >=0.5, <0.8 because it doesn't compile with
bitflags 0.5-6 because of https://github.com/rust-lang-nursery/bitflags/issues/39.
2016-05-16 16:14:34 +02:00
bors-servo e5c69dd609 Auto merge of #127 - servo:bump, r=nox
Bump to 0.3.4

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/127)
<!-- Reviewable:end -->
2016-05-15 03:34:43 -07:00
Anthony Ramine 7094f6bf63 Bump to 0.3.4 2016-05-15 12:34:08 +02:00
bors-servo 48342f557c Auto merge of #126 - servo:bitflags, r=Wafflespeanut
Update bitflags to 0.7

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/126)
<!-- Reviewable:end -->
2016-05-15 03:26:39 -07:00
Anthony Ramine 20b52d82c4 Update bitflags to 0.7 2016-05-15 12:06:35 +02:00
Patrick Walton c33a483f85 0.3.3 2016-05-12 17:04:44 -07:00
Patrick Walton 7aa45dc0a5 Add bindings for a few more menu-related functions.
Bindings added include:

* `-[NSApplication mainMenu]`
* `-[NSApplication setWindowsMenu:]`
* `+[NSMenu alloc]`
* `-[NSMenu initWithTitle:]`
* `-[NSMenu itemAtIndex:]`
2016-05-12 16:37:10 -07:00
bors-servo a7b5f4f3a4 Auto merge of #124 - pcwalton:icon-additions, r=metajack
Add `-[NSApplication setApplicationIconImage:]` and `-[NSImage isValid]`.

These are useful for setting icons.

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/124)
<!-- Reviewable:end -->
2016-05-10 19:11:48 -07:00
Patrick Walton e1ac9a3821 Add -[NSApplication setApplicationIconImage:] and `-[NSImage
isValid]`.

These are useful for setting icons.
2016-05-10 18:05:52 -07:00
bors-servo f545d5bb28 Auto merge of #123 - pcwalton:nsview-additions, r=larsbergstrom
Add autosizing-related methods and constants to `NSView`, and add `NSRectFill`.

r? @larsbergstrom

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/123)
<!-- Reviewable:end -->
2016-05-09 11:29:20 -07:00
Patrick Walton 2028cee801 Add the venerable NSRectFill. 2016-05-09 11:02:38 -07:00
Patrick Walton f461b65eda Add autosizing-related methods and constants to NSView. 2016-05-09 11:01:02 -07:00
bors-servo ac2eaf8348 Auto merge of #122 - servo:derive-appkit, r=mbrubeck
Derive common traits for AppKit integer repr enums.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/122)
<!-- Reviewable:end -->
2016-04-28 16:21:27 -07:00
Corey Farwell 976e6dbc70 Derive common traits for AppKit integer repr enums. 2016-04-28 19:15:23 -04:00
bors-servo 7241894cd5 Auto merge of #121 - servo:activation-policy-prohibited, r=larsbergstrom
Add `NSApplicationActivationPolicyProhibited`.

https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSRunningApplication_Class/#//apple_ref/c/tdef/NSApplicationActivationPolicy

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/121)
<!-- Reviewable:end -->
2016-04-28 08:25:53 -07:00
Corey Farwell f037498244 Add NSApplicationActivationPolicyProhibited.
https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSRunningApplication_Class/#//apple_ref/c/tdef/NSApplicationActivationPolicy
2016-04-28 10:35:50 -04:00
bors-servo 139eb8fa12 Auto merge of #119 - conradev:nsfastenumeration, r=jdm
Added basic NSFastEnumeration implementation

This allows you to turn any Foundation collection into an `Iterator`. The basic implementation is derived from @mikeash's [blog post](https://www.mikeash.com/pyblog/friday-qa-2010-04-16-implementing-fast-enumeration.html) on the subject.

Let me know what you think!

I have not yet decided how best to handle a change in the mutation pointer – that still remains to be implemented.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/119)
<!-- Reviewable:end -->
2016-04-01 01:45:56 +05:30
Conrad Kramer d874e1d9d8 Added basic NSFastEnumeration implementation 2016-03-31 13:08:05 -07:00
bors-servo 0686ec3ca1 Auto merge of #120 - SSheldon:objc2, r=Ms2ger
Update objc dependency to 0.2

I just published version 0.2 of the objc crate, changelog here: https://github.com/SSheldon/rust-objc/blob/master/CHANGELOG.md#020

Main differences are gnustep support, (optionally) more type checking, removed the libc dependency, and fixed a bug in the space reserved for ivars when declaring classes.

No changes required to cocoa, but since it exports a lot of objc types this update is a breaking change and requires a version bump to 0.3.

Testing done: verified everything compiles, tests pass, hello_world example still works, and also tested glutin against objc 0.2.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/120)
<!-- Reviewable:end -->
2016-03-21 13:39:01 +05:30
Steven Sheldon 18fd63a576 Update objc to 0.2 and bump cocoa to 0.3. 2016-03-20 15:44:59 -07:00
bors-servo 98aceab548 Auto merge of #118 - servo:core-graphics, r=Ms2ger
Allow core-graphics 0.3

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/118)
<!-- Reviewable:end -->
2016-03-09 21:27:50 +05:30
Anthony Ramine 26d7978a13 Allow core-graphics 0.3 2016-03-09 16:54:43 +01:00
Josh Matthews 768538d630 Merge pull request #116 from fkaa/foundation-nsrange
Add NSRange
2016-02-27 16:48:30 -05:00
Josh Matthews 2d30ae808a Merge pull request #115 from fkaa/window-funcs
Add NSView functions
2016-02-27 16:47:36 -05:00
Felix Kaaman ff18c50631 Add NSRange 2016-02-27 22:12:50 +01:00
Felix Kaaman e403c78fee Add NSView functions 2016-02-27 22:02:09 +01:00
bors-servo 9933690479 Auto merge of #114 - servo:sudo-false, r=Ms2ger
Remove now default 'sudo: false'

`sudo: false` is now default on Travis CI

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/114)
<!-- Reviewable:end -->
2016-02-27 21:30:50 +05:30
Corey Farwell f10177fcb2 Remove now default 'sudo: false'
`sudo: false` is now default on Travis CI
2016-02-27 10:59:41 -05:00
bors-servo 8ba637e5ef Auto merge of #113 - paulrouget:versionBump, r=frewsxcv
version bump

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/113)
<!-- Reviewable:end -->
2016-02-17 09:14:06 +05:30
Paul Rouget d9cf770a3c version bump 2016-02-17 04:42:29 +01:00