Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
1ee93853
Commit
1ee93853
authored
Apr 03, 2013
by
Ken Thomases
Committed by
Alexandre Julliard
Apr 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemac: Make macdrv_event structs heap-allocated and reference-counted.
parent
b55d7aae
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
206 additions
and
172 deletions
+206
-172
cocoa_app.m
dlls/winemac.drv/cocoa_app.m
+27
-29
cocoa_event.h
dlls/winemac.drv/cocoa_event.h
+7
-1
cocoa_event.m
dlls/winemac.drv/cocoa_event.m
+86
-60
cocoa_status_item.m
dlls/winemac.drv/cocoa_status_item.m
+6
-6
cocoa_window.m
dlls/winemac.drv/cocoa_window.m
+72
-69
event.c
dlls/winemac.drv/event.c
+4
-4
macdrv_cocoa.h
dlls/winemac.drv/macdrv_cocoa.h
+4
-3
No files found.
dlls/winemac.drv/cocoa_app.m
View file @
1ee93853
...
@@ -243,18 +243,18 @@ int macdrv_err_on;
...
@@ -243,18 +243,18 @@ int macdrv_err_on;
-
(
void
)
windowGotFocus
:
(
WineWindow
*
)
window
-
(
void
)
windowGotFocus
:
(
WineWindow
*
)
window
{
{
macdrv_event
event
;
macdrv_event
*
event
;
[
NSApp
invalidateGotFocusEvents
];
[
NSApp
invalidateGotFocusEvents
];
event
.
type
=
WINDOW_GOT_FOCUS
;
event
=
macdrv_create_event
(
WINDOW_GOT_FOCUS
,
window
);
event
.
window
=
(
macdrv_window
)[
window
retain
];
event
->
window_got_focus
.
serial
=
windowFocusSerial
;
event
.
window_got_focus
.
serial
=
windowFocusSerial
;
if
(
triedWindows
)
if
(
triedWindows
)
event
.
window_got_focus
.
tried_windows
=
[
triedWindows
retain
];
event
->
window_got_focus
.
tried_windows
=
[
triedWindows
retain
];
else
else
event
.
window_got_focus
.
tried_windows
=
[[
NSMutableSet
alloc
]
init
];
event
->
window_got_focus
.
tried_windows
=
[[
NSMutableSet
alloc
]
init
];
[
window
.
queue
postEvent
:
&
event
];
[
window
.
queue
postEvent
:
event
];
macdrv_release_event
(
event
);
}
}
-
(
void
)
windowRejectedFocusEvent
:
(
const
macdrv_event
*
)
event
-
(
void
)
windowRejectedFocusEvent
:
(
const
macdrv_event
*
)
event
...
@@ -287,29 +287,25 @@ int macdrv_err_on;
...
@@ -287,29 +287,25 @@ int macdrv_err_on;
kTISPropertyUnicodeKeyLayoutData
);
kTISPropertyUnicodeKeyLayoutData
);
if
(
uchr
)
if
(
uchr
)
{
{
macdrv_event
event
;
macdrv_event
*
event
;
WineEventQueue
*
queue
;
WineEventQueue
*
queue
;
event
.
type
=
KEYBOARD_CHANGED
;
event
=
macdrv_create_event
(
KEYBOARD_CHANGED
,
nil
);
event
.
window
=
NULL
;
event
->
keyboard_changed
.
keyboard_type
=
self
.
keyboardType
;
event
.
keyboard_changed
.
keyboard_type
=
self
.
keyboardType
;
event
->
keyboard_changed
.
iso_keyboard
=
(
KBGetLayoutType
(
self
.
keyboardType
)
==
kKeyboardISO
);
event
.
keyboard_changed
.
iso_keyboard
=
(
KBGetLayoutType
(
self
.
keyboardType
)
==
kKeyboardISO
);
event
->
keyboard_changed
.
uchr
=
CFDataCreateCopy
(
NULL
,
uchr
);
event
.
keyboard_changed
.
uchr
=
CFDataCreateCopy
(
NULL
,
uchr
);
if
(
event
.
keyboard_changed
.
uchr
)
if
(
event
->
keyboard_changed
.
uchr
)
{
{
[
eventQueuesLock
lock
];
[
eventQueuesLock
lock
];
for
(
queue
in
eventQueues
)
for
(
queue
in
eventQueues
)
{
[
queue
postEvent
:
event
];
CFRetain
(
event
.
keyboard_changed
.
uchr
);
[
queue
postEvent
:
&
event
];
}
[
eventQueuesLock
unlock
];
[
eventQueuesLock
unlock
];
CFRelease
(
event
.
keyboard_changed
.
uchr
);
}
}
macdrv_release_event
(
event
);
}
}
CFRelease
(
inputSource
);
CFRelease
(
inputSource
);
...
@@ -410,17 +406,18 @@ int macdrv_err_on;
...
@@ -410,17 +406,18 @@ int macdrv_err_on;
-
(
void
)
sendDisplaysChanged
:
(
BOOL
)
activating
-
(
void
)
sendDisplaysChanged
:
(
BOOL
)
activating
{
{
macdrv_event
event
;
macdrv_event
*
event
;
WineEventQueue
*
queue
;
WineEventQueue
*
queue
;
event
.
type
=
DISPLAYS_CHANGED
;
event
=
macdrv_create_event
(
DISPLAYS_CHANGED
,
nil
);
event
.
window
=
NULL
;
event
->
displays_changed
.
activating
=
activating
;
event
.
displays_changed
.
activating
=
activating
;
[
eventQueuesLock
lock
];
[
eventQueuesLock
lock
];
for
(
queue
in
eventQueues
)
for
(
queue
in
eventQueues
)
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
[
eventQueuesLock
unlock
];
[
eventQueuesLock
unlock
];
macdrv_release_event
(
event
);
}
}
// We can compare two modes directly using CFEqual, but that may require that
// We can compare two modes directly using CFEqual, but that may require that
...
@@ -1187,18 +1184,19 @@ int macdrv_err_on;
...
@@ -1187,18 +1184,19 @@ int macdrv_err_on;
-
(
void
)
applicationDidResignActive
:
(
NSNotification
*
)
notification
-
(
void
)
applicationDidResignActive
:
(
NSNotification
*
)
notification
{
{
macdrv_event
event
;
macdrv_event
*
event
;
WineEventQueue
*
queue
;
WineEventQueue
*
queue
;
[
self
invalidateGotFocusEvents
];
[
self
invalidateGotFocusEvents
];
event
.
type
=
APP_DEACTIVATED
;
event
=
macdrv_create_event
(
APP_DEACTIVATED
,
nil
);
event
.
window
=
NULL
;
[
eventQueuesLock
lock
];
[
eventQueuesLock
lock
];
for
(
queue
in
eventQueues
)
for
(
queue
in
eventQueues
)
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
[
eventQueuesLock
unlock
];
[
eventQueuesLock
unlock
];
macdrv_release_event
(
event
);
}
}
-
(
void
)
applicationWillFinishLaunching
:
(
NSNotification
*
)
notification
-
(
void
)
applicationWillFinishLaunching
:
(
NSNotification
*
)
notification
...
...
dlls/winemac.drv/cocoa_event.h
View file @
1ee93853
...
@@ -22,6 +22,9 @@
...
@@ -22,6 +22,9 @@
#include "macdrv_cocoa.h"
#include "macdrv_cocoa.h"
@class
WineWindow
;
@interface
WineEventQueue
:
NSObject
@interface
WineEventQueue
:
NSObject
{
{
NSMutableArray
*
events
;
NSMutableArray
*
events
;
...
@@ -33,7 +36,7 @@
...
@@ -33,7 +36,7 @@
macdrv_event_handler
event_handler
;
macdrv_event_handler
event_handler
;
}
}
-
(
void
)
postEvent
:
(
const
macdrv_event
*
)
inEvent
;
-
(
void
)
postEvent
:
(
macdrv_event
*
)
inEvent
;
-
(
void
)
discardEventsMatchingMask
:(
macdrv_event_mask
)
mask
forWindow
:(
NSWindow
*
)
window
;
-
(
void
)
discardEventsMatchingMask
:(
macdrv_event_mask
)
mask
forWindow
:(
NSWindow
*
)
window
;
-
(
BOOL
)
query
:(
macdrv_query
*
)
query
timeout
:(
NSTimeInterval
)
timeout
processEvents
:(
BOOL
)
processEvents
;
-
(
BOOL
)
query
:(
macdrv_query
*
)
query
timeout
:(
NSTimeInterval
)
timeout
processEvents
:(
BOOL
)
processEvents
;
...
@@ -42,3 +45,6 @@
...
@@ -42,3 +45,6 @@
@end
@end
void
OnMainThread
(
dispatch_block_t
block
);
void
OnMainThread
(
dispatch_block_t
block
);
macdrv_event
*
macdrv_create_event
(
int
type
,
WineWindow
*
window
)
DECLSPEC_HIDDEN
;
macdrv_event
*
macdrv_retain_event
(
macdrv_event
*
event
)
DECLSPEC_HIDDEN
;
dlls/winemac.drv/cocoa_event.m
View file @
1ee93853
...
@@ -35,25 +35,31 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -35,25 +35,31 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
@interface
MacDrvEvent
:
NSObject
@interface
MacDrvEvent
:
NSObject
{
{
@public
@public
macdrv_event
event
;
macdrv_event
*
event
;
}
}
-
(
id
)
initWithEvent
:
(
const
macdrv_event
*
)
event
;
-
(
id
)
initWithEvent
:
(
macdrv_event
*
)
event
;
@end
@end
@implementation
MacDrvEvent
@implementation
MacDrvEvent
-
(
id
)
initWithEvent
:(
const
macdrv_event
*
)
inEvent
-
(
id
)
initWithEvent
:(
macdrv_event
*
)
inEvent
{
{
self
=
[
super
init
];
self
=
[
super
init
];
if
(
self
)
if
(
self
)
{
{
event
=
*
inEvent
;
event
=
macdrv_retain_event
(
inEvent
)
;
}
}
return
self
;
return
self
;
}
}
-
(
void
)
dealloc
{
if
(
event
)
macdrv_release_event
(
event
);
[
super
dealloc
];
}
@end
@end
...
@@ -151,28 +157,26 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -151,28 +157,26 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
[
eventsLock
lock
];
[
eventsLock
lock
];
if
((
event
->
event
.
type
==
MOUSE_MOVED
||
if
((
event
->
event
->
type
==
MOUSE_MOVED
||
event
->
event
.
type
==
MOUSE_MOVED_ABSOLUTE
)
&&
event
->
event
->
type
==
MOUSE_MOVED_ABSOLUTE
)
&&
(
lastEvent
=
[
events
lastObject
])
&&
(
lastEvent
=
[
events
lastObject
])
&&
(
lastEvent
->
event
.
type
==
MOUSE_MOVED
||
(
lastEvent
->
event
->
type
==
MOUSE_MOVED
||
lastEvent
->
event
.
type
==
MOUSE_MOVED_ABSOLUTE
)
&&
lastEvent
->
event
->
type
==
MOUSE_MOVED_ABSOLUTE
)
&&
lastEvent
->
event
.
window
==
event
->
event
.
window
)
lastEvent
->
event
->
window
==
event
->
event
->
window
)
{
{
if
(
event
->
event
.
type
==
MOUSE_MOVED
)
if
(
event
->
event
->
type
==
MOUSE_MOVED
)
{
{
lastEvent
->
event
.
mouse_moved
.
x
+=
event
->
event
.
mouse_moved
.
x
;
lastEvent
->
event
->
mouse_moved
.
x
+=
event
->
event
->
mouse_moved
.
x
;
lastEvent
->
event
.
mouse_moved
.
y
+=
event
->
event
.
mouse_moved
.
y
;
lastEvent
->
event
->
mouse_moved
.
y
+=
event
->
event
->
mouse_moved
.
y
;
}
}
else
else
{
{
lastEvent
->
event
.
type
=
MOUSE_MOVED_ABSOLUTE
;
lastEvent
->
event
->
type
=
MOUSE_MOVED_ABSOLUTE
;
lastEvent
->
event
.
mouse_moved
.
x
=
event
->
event
.
mouse_moved
.
x
;
lastEvent
->
event
->
mouse_moved
.
x
=
event
->
event
->
mouse_moved
.
x
;
lastEvent
->
event
.
mouse_moved
.
y
=
event
->
event
.
mouse_moved
.
y
;
lastEvent
->
event
->
mouse_moved
.
y
=
event
->
event
->
mouse_moved
.
y
;
}
}
lastEvent
->
event
.
mouse_moved
.
time_ms
=
event
->
event
.
mouse_moved
.
time_ms
;
lastEvent
->
event
->
mouse_moved
.
time_ms
=
event
->
event
->
mouse_moved
.
time_ms
;
macdrv_cleanup_event
(
&
event
->
event
);
}
}
else
else
[
events
addObject
:
event
];
[
events
addObject
:
event
];
...
@@ -182,7 +186,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -182,7 +186,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
[
self
signalEventAvailable
];
[
self
signalEventAvailable
];
}
}
-
(
void
)
postEvent
:
(
const
macdrv_event
*
)
inEvent
-
(
void
)
postEvent
:
(
macdrv_event
*
)
inEvent
{
{
MacDrvEvent
*
event
=
[[
MacDrvEvent
alloc
]
initWithEvent
:
inEvent
];
MacDrvEvent
*
event
=
[[
MacDrvEvent
alloc
]
initWithEvent
:
inEvent
];
[
self
postEventObject
:
event
];
[
self
postEventObject
:
event
];
...
@@ -215,7 +219,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -215,7 +219,7 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
index
=
0
;
index
=
0
;
for
(
event
in
events
)
for
(
event
in
events
)
{
{
if
(
event_mask_for_type
(
event
->
event
.
type
)
&
mask
)
if
(
event_mask_for_type
(
event
->
event
->
type
)
&
mask
)
break
;
break
;
index
++
;
index
++
;
...
@@ -233,18 +237,14 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -233,18 +237,14 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
-
(
void
)
discardEventsMatchingMask
:
(
macdrv_event_mask
)
mask
forWindow
:
(
NSWindow
*
)
window
-
(
void
)
discardEventsMatchingMask
:
(
macdrv_event_mask
)
mask
forWindow
:
(
NSWindow
*
)
window
{
{
NS
MutableIndexSet
*
indexes
=
[[[
NSMutableIndexSet
alloc
]
init
]
autorelease
]
;
NS
IndexSet
*
indexes
;
[
eventsLock
lock
];
[
eventsLock
lock
];
[
events
enumerateObjectsUsingBlock
:
^
(
id
obj
,
NSUInteger
idx
,
BOOL
*
stop
){
indexes
=
[
events
indexesOfObjectsPassingTest
:
^
BOOL
(
id
obj
,
NSUInteger
idx
,
BOOL
*
stop
){
MacDrvEvent
*
event
=
obj
;
MacDrvEvent
*
event
=
obj
;
if
((
event_mask_for_type
(
event
->
event
.
type
)
&
mask
)
&&
return
((
event_mask_for_type
(
event
->
event
->
type
)
&
mask
)
&&
(
!
window
||
event
->
event
.
window
==
(
macdrv_window
)
window
))
(
!
window
||
event
->
event
->
window
==
(
macdrv_window
)
window
));
{
macdrv_cleanup_event
(
&
event
->
event
);
[
indexes
addIndex
:
idx
];
}
}];
}];
[
events
removeObjectsAtIndexes
:
indexes
];
[
events
removeObjectsAtIndexes
:
indexes
];
...
@@ -254,16 +254,16 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
...
@@ -254,16 +254,16 @@ static NSString* const WineEventQueueThreadDictionaryKey = @"WineEventQueueThrea
-
(
BOOL
)
query
:
(
macdrv_query
*
)
query
timeout
:
(
NSTimeInterval
)
timeout
processEvents
:
(
BOOL
)
processEvents
-
(
BOOL
)
query
:
(
macdrv_query
*
)
query
timeout
:
(
NSTimeInterval
)
timeout
processEvents
:
(
BOOL
)
processEvents
{
{
macdrv_event
event
;
macdrv_event
*
event
;
NSDate
*
timeoutDate
=
[
NSDate
dateWithTimeIntervalSinceNow
:
timeout
];
NSDate
*
timeoutDate
=
[
NSDate
dateWithTimeIntervalSinceNow
:
timeout
];
BOOL
timedout
;
BOOL
timedout
;
event
.
type
=
QUERY_EVENT
;
event
=
macdrv_create_event
(
QUERY_EVENT
,
(
WineWindow
*
)
query
->
window
);
event
.
window
=
(
macdrv_window
)[(
WineWindow
*
)
query
->
window
retain
];
event
->
query_event
.
query
=
macdrv_retain_query
(
query
);
event
.
query_event
.
query
=
macdrv_retain_query
(
query
);
query
->
done
=
FALSE
;
query
->
done
=
FALSE
;
[
self
postEvent
:
&
event
];
[
self
postEvent
:
event
];
macdrv_release_event
(
event
);
timedout
=
!
[
NSApp
waitUntilQueryDone
:
&
query
->
done
timeout
:
timeoutDate
processEvents
:
processEvents
];
timedout
=
!
[
NSApp
waitUntilQueryDone
:
&
query
->
done
timeout
:
timeoutDate
processEvents
:
processEvents
];
return
!
timedout
&&
query
->
status
;
return
!
timedout
&&
query
->
status
;
}
}
...
@@ -309,8 +309,7 @@ void OnMainThread(dispatch_block_t block)
...
@@ -309,8 +309,7 @@ void OnMainThread(dispatch_block_t block)
while
(
!
finished
&&
while
(
!
finished
&&
(
macDrvEvent
=
[
queue
getEventMatchingMask
:
event_mask_for_type
(
QUERY_EVENT
)]))
(
macDrvEvent
=
[
queue
getEventMatchingMask
:
event_mask_for_type
(
QUERY_EVENT
)]))
{
{
queue
->
event_handler
(
&
macDrvEvent
->
event
);
queue
->
event_handler
(
macDrvEvent
->
event
);
macdrv_cleanup_event
(
&
macDrvEvent
->
event
);
}
}
if
(
!
finished
)
if
(
!
finished
)
...
@@ -385,56 +384,83 @@ int macdrv_get_event_queue_fd(macdrv_event_queue queue)
...
@@ -385,56 +384,83 @@ int macdrv_get_event_queue_fd(macdrv_event_queue queue)
}
}
/***********************************************************************
/***********************************************************************
* macdrv_
get
_event_from_queue
* macdrv_
copy
_event_from_queue
*
*
* Pull an event matching the event mask from the event queue and store
* Pull an event matching the event mask from the event queue and store
* it in the event record pointed to by the event parameter. If a
* it in the event record pointed to by the event parameter. If a
* matching event was found, return non-zero; otherwise, return 0.
* matching event was found, return non-zero; otherwise, return 0.
*
*
* The caller is responsible for calling macdrv_
cleanup
_event on any
* The caller is responsible for calling macdrv_
release
_event on any
* event returned by this function.
* event returned by this function.
*/
*/
int
macdrv_
get
_event_from_queue
(
macdrv_event_queue
queue
,
int
macdrv_
copy
_event_from_queue
(
macdrv_event_queue
queue
,
macdrv_event_mask
mask
,
macdrv_event
*
event
)
macdrv_event_mask
mask
,
macdrv_event
*
*
event
)
{
{
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
WineEventQueue
*
q
=
(
WineEventQueue
*
)
queue
;
WineEventQueue
*
q
=
(
WineEventQueue
*
)
queue
;
MacDrvEvent
*
macDrvEvent
=
[
q
getEventMatchingMask
:
mask
];
MacDrvEvent
*
macDrvEvent
=
[
q
getEventMatchingMask
:
mask
];
if
(
macDrvEvent
)
if
(
macDrvEvent
)
*
event
=
mac
DrvEvent
->
event
;
*
event
=
mac
drv_retain_event
(
macDrvEvent
->
event
)
;
[
pool
release
];
[
pool
release
];
return
(
macDrvEvent
!=
nil
);
return
(
macDrvEvent
!=
nil
);
}
}
/***********************************************************************
/***********************************************************************
* macdrv_cleanup_event
* macdrv_create_event
*
* Performs cleanup of an event. For event types which carry resources
* such as allocated memory or retained objects, frees/releases those
* resources.
*/
*/
void
macdrv_cleanup_event
(
macdrv_event
*
event
)
macdrv_event
*
macdrv_create_event
(
int
type
,
WineWindow
*
window
)
{
{
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
macdrv_event
*
event
;
event
=
calloc
(
1
,
sizeof
(
*
event
));
event
->
refs
=
1
;
event
->
type
=
type
;
event
->
window
=
(
macdrv_window
)[
window
retain
];
return
event
;
}
switch
(
event
->
type
)
/***********************************************************************
* macdrv_retain_event
*/
macdrv_event
*
macdrv_retain_event
(
macdrv_event
*
event
)
{
OSAtomicIncrement32Barrier
(
&
event
->
refs
);
return
event
;
}
/***********************************************************************
* macdrv_release_event
*
* Decrements the reference count of an event. If the count falls to
* zero, cleans up any resources, such as allocated memory or retained
* objects, held by the event and deallocates it
*/
void
macdrv_release_event
(
macdrv_event
*
event
)
{
if
(
OSAtomicDecrement32Barrier
(
&
event
->
refs
)
<=
0
)
{
{
case
KEYBOARD_CHANGED
:
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
CFRelease
(
event
->
keyboard_changed
.
uchr
);
break
;
case
QUERY_EVENT
:
macdrv_release_query
(
event
->
query_event
.
query
);
break
;
case
WINDOW_GOT_FOCUS
:
[(
NSMutableSet
*
)
event
->
window_got_focus
.
tried_windows
release
];
break
;
}
[(
WineWindow
*
)
event
->
window
release
];
switch
(
event
->
type
)
{
case
KEYBOARD_CHANGED
:
CFRelease
(
event
->
keyboard_changed
.
uchr
);
break
;
case
QUERY_EVENT
:
macdrv_release_query
(
event
->
query_event
.
query
);
break
;
case
WINDOW_GOT_FOCUS
:
[(
NSMutableSet
*
)
event
->
window_got_focus
.
tried_windows
release
];
break
;
}
[
pool
release
];
[(
WineWindow
*
)
event
->
window
release
];
free
(
event
);
[
pool
release
];
}
}
}
/***********************************************************************
/***********************************************************************
...
...
dlls/winemac.drv/cocoa_status_item.m
View file @
1ee93853
...
@@ -79,12 +79,12 @@
...
@@ -79,12 +79,12 @@
-
(
void
)
postClickedEventWithCount
:
(
int
)
count
-
(
void
)
postClickedEventWithCount
:
(
int
)
count
{
{
macdrv_event
event
;
macdrv_event
*
event
;
event
.
type
=
STATUS_ITEM_CLICKED
;
event
=
macdrv_create_event
(
STATUS_ITEM_CLICKED
,
nil
)
;
event
.
window
=
NULL
;
event
->
status_item_clicked
.
item
=
(
macdrv_status_item
)
self
;
event
.
status_item_clicked
.
item
=
(
macdrv_status_item
)
self
;
event
->
status_item_clicked
.
count
=
count
;
event
.
status_item_clicked
.
count
=
count
;
[
queue
postEvent
:
event
]
;
[
queue
postEvent
:
&
event
]
;
macdrv_release_event
(
event
)
;
}
}
-
(
void
)
clicked
:
(
id
)
sender
-
(
void
)
clicked
:
(
id
)
sender
...
...
dlls/winemac.drv/cocoa_window.m
View file @
1ee93853
...
@@ -678,17 +678,18 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -678,17 +678,18 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
-
(
void
)
postMouseButtonEvent
:
(
NSEvent
*
)
theEvent
pressed
:
(
int
)
pressed
-
(
void
)
postMouseButtonEvent
:
(
NSEvent
*
)
theEvent
pressed
:
(
int
)
pressed
{
{
CGPoint
pt
=
CGEventGetLocation
([
theEvent
CGEvent
]);
CGPoint
pt
=
CGEventGetLocation
([
theEvent
CGEvent
]);
macdrv_event
event
;
macdrv_event
*
event
;
event
.
type
=
MOUSE_BUTTON
;
event
=
macdrv_create_event
(
MOUSE_BUTTON
,
self
);
event
.
window
=
(
macdrv_window
)[
self
retain
];
event
->
mouse_button
.
button
=
[
theEvent
buttonNumber
];
event
.
mouse_button
.
button
=
[
theEvent
buttonNumber
];
event
->
mouse_button
.
pressed
=
pressed
;
event
.
mouse_button
.
pressed
=
pressed
;
event
->
mouse_button
.
x
=
pt
.
x
;
event
.
mouse_button
.
x
=
pt
.
x
;
event
->
mouse_button
.
y
=
pt
.
y
;
event
.
mouse_button
.
y
=
pt
.
y
;
event
->
mouse_button
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
event
.
mouse_button
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
macdrv_release_event
(
event
);
}
}
-
(
void
)
makeFocused
-
(
void
)
makeFocused
...
@@ -750,15 +751,14 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -750,15 +751,14 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
modifiers
:
(
NSUInteger
)
modifiers
modifiers
:
(
NSUInteger
)
modifiers
event
:
(
NSEvent
*
)
theEvent
event
:
(
NSEvent
*
)
theEvent
{
{
macdrv_event
event
;
macdrv_event
*
event
;
CGEventRef
cgevent
;
CGEventRef
cgevent
;
WineApplication
*
app
=
(
WineApplication
*
)
NSApp
;
WineApplication
*
app
=
(
WineApplication
*
)
NSApp
;
event
.
type
=
pressed
?
KEY_PRESS
:
KEY_RELEASE
;
event
=
macdrv_create_event
(
pressed
?
KEY_PRESS
:
KEY_RELEASE
,
self
);
event
.
window
=
(
macdrv_window
)[
self
retain
];
event
->
key
.
keycode
=
keyCode
;
event
.
key
.
keycode
=
keyCode
;
event
->
key
.
modifiers
=
modifiers
;
event
.
key
.
modifiers
=
modifiers
;
event
->
key
.
time_ms
=
[
app
ticksForEventTime
:[
theEvent
timestamp
]];
event
.
key
.
time_ms
=
[
app
ticksForEventTime
:[
theEvent
timestamp
]];
if
((
cgevent
=
[
theEvent
CGEvent
]))
if
((
cgevent
=
[
theEvent
CGEvent
]))
{
{
...
@@ -771,7 +771,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -771,7 +771,9 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
}
}
}
}
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
macdrv_release_event
(
event
);
}
}
-
(
void
)
postKeyEvent
:
(
NSEvent
*
)
theEvent
-
(
void
)
postKeyEvent
:
(
NSEvent
*
)
theEvent
...
@@ -785,15 +787,15 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -785,15 +787,15 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
-
(
void
)
postMouseMovedEvent
:
(
NSEvent
*
)
theEvent
absolute
:
(
BOOL
)
absolute
-
(
void
)
postMouseMovedEvent
:
(
NSEvent
*
)
theEvent
absolute
:
(
BOOL
)
absolute
{
{
macdrv_event
event
;
macdrv_event
*
event
;
if
(
absolute
)
if
(
absolute
)
{
{
CGPoint
point
=
CGEventGetLocation
([
theEvent
CGEvent
]);
CGPoint
point
=
CGEventGetLocation
([
theEvent
CGEvent
]);
event
.
type
=
MOUSE_MOVED_ABSOLUTE
;
event
=
macdrv_create_event
(
MOUSE_MOVED_ABSOLUTE
,
self
)
;
event
.
mouse_moved
.
x
=
point
.
x
;
event
->
mouse_moved
.
x
=
point
.
x
;
event
.
mouse_moved
.
y
=
point
.
y
;
event
->
mouse_moved
.
y
=
point
.
y
;
mouseMoveDeltaX
=
0
;
mouseMoveDeltaX
=
0
;
mouseMoveDeltaY
=
0
;
mouseMoveDeltaY
=
0
;
...
@@ -805,22 +807,23 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -805,22 +807,23 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
mouseMoveDeltaX
+=
[
theEvent
deltaX
];
mouseMoveDeltaX
+=
[
theEvent
deltaX
];
mouseMoveDeltaY
+=
[
theEvent
deltaY
];
mouseMoveDeltaY
+=
[
theEvent
deltaY
];
event
.
type
=
MOUSE_MOVED
;
event
=
macdrv_create_event
(
MOUSE_MOVED
,
self
)
;
event
.
mouse_moved
.
x
=
mouseMoveDeltaX
;
event
->
mouse_moved
.
x
=
mouseMoveDeltaX
;
event
.
mouse_moved
.
y
=
mouseMoveDeltaY
;
event
->
mouse_moved
.
y
=
mouseMoveDeltaY
;
/* Keep the remainder after integer truncation. */
/* Keep the remainder after integer truncation. */
mouseMoveDeltaX
-=
event
.
mouse_moved
.
x
;
mouseMoveDeltaX
-=
event
->
mouse_moved
.
x
;
mouseMoveDeltaY
-=
event
.
mouse_moved
.
y
;
mouseMoveDeltaY
-=
event
->
mouse_moved
.
y
;
}
}
if
(
event
.
type
==
MOUSE_MOVED_ABSOLUTE
||
event
.
mouse_moved
.
x
||
event
.
mouse_moved
.
y
)
if
(
event
->
type
==
MOUSE_MOVED_ABSOLUTE
||
event
->
mouse_moved
.
x
||
event
->
mouse_moved
.
y
)
{
{
event
.
window
=
(
macdrv_window
)[
self
retain
];
event
->
mouse_moved
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
event
.
mouse_moved
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
}
}
macdrv_release_event
(
event
);
}
}
-
(
void
)
setLevelWhenActive
:
(
NSInteger
)
level
-
(
void
)
setLevelWhenActive
:
(
NSInteger
)
level
...
@@ -1006,7 +1009,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1006,7 +1009,7 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
-
(
void
)
scrollWheel
:
(
NSEvent
*
)
theEvent
-
(
void
)
scrollWheel
:
(
NSEvent
*
)
theEvent
{
{
CGPoint
pt
;
CGPoint
pt
;
macdrv_event
event
;
macdrv_event
*
event
;
CGEventRef
cgevent
;
CGEventRef
cgevent
;
CGFloat
x
,
y
;
CGFloat
x
,
y
;
BOOL
continuous
=
FALSE
;
BOOL
continuous
=
FALSE
;
...
@@ -1014,11 +1017,10 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1014,11 +1017,10 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
cgevent
=
[
theEvent
CGEvent
];
cgevent
=
[
theEvent
CGEvent
];
pt
=
CGEventGetLocation
(
cgevent
);
pt
=
CGEventGetLocation
(
cgevent
);
event
.
type
=
MOUSE_SCROLL
;
event
=
macdrv_create_event
(
MOUSE_SCROLL
,
self
);
event
.
window
=
(
macdrv_window
)[
self
retain
];
event
->
mouse_scroll
.
x
=
pt
.
x
;
event
.
mouse_scroll
.
x
=
pt
.
x
;
event
->
mouse_scroll
.
y
=
pt
.
y
;
event
.
mouse_scroll
.
y
=
pt
.
y
;
event
->
mouse_scroll
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
event
.
mouse_scroll
.
time_ms
=
[
NSApp
ticksForEventTime
:[
theEvent
timestamp
]];
if
(
CGEventGetIntegerValueField
(
cgevent
,
kCGScrollWheelEventIsContinuous
))
if
(
CGEventGetIntegerValueField
(
cgevent
,
kCGScrollWheelEventIsContinuous
))
{
{
...
@@ -1055,8 +1057,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1055,8 +1057,8 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
/* The x,y values so far are in pixels. Win32 expects to receive some
/* The x,y values so far are in pixels. Win32 expects to receive some
fraction of WHEEL_DELTA == 120. By my estimation, that's roughly
fraction of WHEEL_DELTA == 120. By my estimation, that's roughly
6 times the pixel value. */
6 times the pixel value. */
event
.
mouse_scroll
.
x_scroll
=
6
*
x
;
event
->
mouse_scroll
.
x_scroll
=
6
*
x
;
event
.
mouse_scroll
.
y_scroll
=
6
*
y
;
event
->
mouse_scroll
.
y_scroll
=
6
*
y
;
if
(
!
continuous
)
if
(
!
continuous
)
{
{
...
@@ -1066,19 +1068,21 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1066,19 +1068,21 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
scroll distance, the user is sure to get some action out of each click.
scroll distance, the user is sure to get some action out of each click.
For example, this is important for rotating though weapons in a
For example, this is important for rotating though weapons in a
first-person shooter. */
first-person shooter. */
if
(
0
<
event
.
mouse_scroll
.
x_scroll
&&
event
.
mouse_scroll
.
x_scroll
<
120
)
if
(
0
<
event
->
mouse_scroll
.
x_scroll
&&
event
->
mouse_scroll
.
x_scroll
<
120
)
event
.
mouse_scroll
.
x_scroll
=
120
;
event
->
mouse_scroll
.
x_scroll
=
120
;
else
if
(
-
120
<
event
.
mouse_scroll
.
x_scroll
&&
event
.
mouse_scroll
.
x_scroll
<
0
)
else
if
(
-
120
<
event
->
mouse_scroll
.
x_scroll
&&
event
->
mouse_scroll
.
x_scroll
<
0
)
event
.
mouse_scroll
.
x_scroll
=
-
120
;
event
->
mouse_scroll
.
x_scroll
=
-
120
;
if
(
0
<
event
.
mouse_scroll
.
y_scroll
&&
event
.
mouse_scroll
.
y_scroll
<
120
)
if
(
0
<
event
->
mouse_scroll
.
y_scroll
&&
event
->
mouse_scroll
.
y_scroll
<
120
)
event
.
mouse_scroll
.
y_scroll
=
120
;
event
->
mouse_scroll
.
y_scroll
=
120
;
else
if
(
-
120
<
event
.
mouse_scroll
.
y_scroll
&&
event
.
mouse_scroll
.
y_scroll
<
0
)
else
if
(
-
120
<
event
->
mouse_scroll
.
y_scroll
&&
event
->
mouse_scroll
.
y_scroll
<
0
)
event
.
mouse_scroll
.
y_scroll
=
-
120
;
event
->
mouse_scroll
.
y_scroll
=
-
120
;
}
}
if
(
event
.
mouse_scroll
.
x_scroll
||
event
.
mouse_scroll
.
y_scroll
)
if
(
event
->
mouse_scroll
.
x_scroll
||
event
->
mouse_scroll
.
y_scroll
)
[
queue
postEvent
:
&
event
];
[
queue
postEvent
:
event
];
macdrv_release_event
(
event
);
}
}
...
@@ -1100,16 +1104,16 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1100,16 +1104,16 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
{
{
if
(
!
ignore_windowDeminiaturize
)
if
(
!
ignore_windowDeminiaturize
)
{
{
macdrv_event
event
;
macdrv_event
*
event
;
/* Coalesce events by discarding any previous ones still in the queue. */
/* Coalesce events by discarding any previous ones still in the queue. */
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_DID_MINIMIZE
)
|
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_DID_MINIMIZE
)
|
event_mask_for_type
(
WINDOW_DID_UNMINIMIZE
)
event_mask_for_type
(
WINDOW_DID_UNMINIMIZE
)
forWindow
:
self
];
forWindow
:
self
];
event
.
type
=
WINDOW_DID_UNMINIMIZE
;
event
=
macdrv_create_event
(
WINDOW_DID_UNMINIMIZE
,
self
)
;
event
.
window
=
(
macdrv_window
)[
self
retain
];
[
queue
postEvent
:
event
];
[
queue
postEvent
:
&
event
]
;
macdrv_release_event
(
event
)
;
}
}
ignore_windowDeminiaturize
=
FALSE
;
ignore_windowDeminiaturize
=
FALSE
;
...
@@ -1131,18 +1135,18 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1131,18 +1135,18 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
-
(
void
)
windowDidResignKey
:
(
NSNotification
*
)
notification
-
(
void
)
windowDidResignKey
:
(
NSNotification
*
)
notification
{
{
macdrv_event
event
;
macdrv_event
*
event
;
if
(
causing_becomeKeyWindow
)
return
;
if
(
causing_becomeKeyWindow
)
return
;
event
.
type
=
WINDOW_LOST_FOCUS
;
event
=
macdrv_create_event
(
WINDOW_LOST_FOCUS
,
self
)
;
event
.
window
=
(
macdrv_window
)[
self
retain
];
[
queue
postEvent
:
event
];
[
queue
postEvent
:
&
event
]
;
macdrv_release_event
(
event
)
;
}
}
-
(
void
)
windowDidResize
:
(
NSNotification
*
)
notification
-
(
void
)
windowDidResize
:
(
NSNotification
*
)
notification
{
{
macdrv_event
event
;
macdrv_event
*
event
;
NSRect
frame
=
[
self
contentRectForFrameRect
:[
self
frame
]];
NSRect
frame
=
[
self
contentRectForFrameRect
:[
self
frame
]];
[
NSApp
flipRect
:
&
frame
];
[
NSApp
flipRect
:
&
frame
];
...
@@ -1151,18 +1155,17 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1151,18 +1155,17 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_FRAME_CHANGED
)
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_FRAME_CHANGED
)
forWindow
:
self
];
forWindow
:
self
];
event
.
type
=
WINDOW_FRAME_CHANGED
;
event
=
macdrv_create_event
(
WINDOW_FRAME_CHANGED
,
self
)
;
event
.
window
=
(
macdrv_window
)[
self
retain
]
;
event
->
window_frame_changed
.
frame
=
NSRectToCGRect
(
frame
)
;
event
.
window_frame_changed
.
frame
=
NSRectToCGRect
(
frame
)
;
[
queue
postEvent
:
event
]
;
[
queue
postEvent
:
&
event
]
;
macdrv_release_event
(
event
)
;
}
}
-
(
BOOL
)
windowShouldClose
:
(
id
)
sender
-
(
BOOL
)
windowShouldClose
:
(
id
)
sender
{
{
macdrv_event
event
;
macdrv_event
*
event
=
macdrv_create_event
(
WINDOW_CLOSE_REQUESTED
,
self
);
event
.
type
=
WINDOW_CLOSE_REQUESTED
;
[
queue
postEvent
:
event
];
event
.
window
=
(
macdrv_window
)[
self
retain
];
macdrv_release_event
(
event
);
[
queue
postEvent
:
&
event
];
return
NO
;
return
NO
;
}
}
...
@@ -1170,16 +1173,16 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
...
@@ -1170,16 +1173,16 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
{
{
if
(
!
ignore_windowMiniaturize
)
if
(
!
ignore_windowMiniaturize
)
{
{
macdrv_event
event
;
macdrv_event
*
event
;
/* Coalesce events by discarding any previous ones still in the queue. */
/* Coalesce events by discarding any previous ones still in the queue. */
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_DID_MINIMIZE
)
|
[
queue
discardEventsMatchingMask
:
event_mask_for_type
(
WINDOW_DID_MINIMIZE
)
|
event_mask_for_type
(
WINDOW_DID_UNMINIMIZE
)
event_mask_for_type
(
WINDOW_DID_UNMINIMIZE
)
forWindow
:
self
];
forWindow
:
self
];
event
.
type
=
WINDOW_DID_MINIMIZE
;
event
=
macdrv_create_event
(
WINDOW_DID_MINIMIZE
,
self
)
;
event
.
window
=
(
macdrv_window
)[
self
retain
];
[
queue
postEvent
:
event
];
[
queue
postEvent
:
&
event
]
;
macdrv_release_event
(
event
)
;
}
}
ignore_windowMiniaturize
=
FALSE
;
ignore_windowMiniaturize
=
FALSE
;
...
...
dlls/winemac.drv/event.c
View file @
1ee93853
...
@@ -223,14 +223,14 @@ void macdrv_handle_event(const macdrv_event *event)
...
@@ -223,14 +223,14 @@ void macdrv_handle_event(const macdrv_event *event)
*/
*/
static
int
process_events
(
macdrv_event_queue
queue
,
macdrv_event_mask
mask
)
static
int
process_events
(
macdrv_event_queue
queue
,
macdrv_event_mask
mask
)
{
{
macdrv_event
event
;
macdrv_event
*
event
;
int
count
=
0
;
int
count
=
0
;
while
(
macdrv_
get
_event_from_queue
(
queue
,
mask
,
&
event
))
while
(
macdrv_
copy
_event_from_queue
(
queue
,
mask
,
&
event
))
{
{
count
++
;
count
++
;
macdrv_handle_event
(
&
event
);
macdrv_handle_event
(
event
);
macdrv_
cleanup_event
(
&
event
);
macdrv_
release_event
(
event
);
}
}
if
(
count
)
TRACE
(
"processed %d events
\n
"
,
count
);
if
(
count
)
TRACE
(
"processed %d events
\n
"
,
count
);
return
count
;
return
count
;
...
...
dlls/winemac.drv/macdrv_cocoa.h
View file @
1ee93853
...
@@ -175,6 +175,7 @@ enum {
...
@@ -175,6 +175,7 @@ enum {
typedef
uint32_t
macdrv_event_mask
;
typedef
uint32_t
macdrv_event_mask
;
typedef
struct
macdrv_event
{
typedef
struct
macdrv_event
{
int
refs
;
int
type
;
int
type
;
macdrv_window
window
;
macdrv_window
window
;
union
{
union
{
...
@@ -272,9 +273,9 @@ extern macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler
...
@@ -272,9 +273,9 @@ extern macdrv_event_queue macdrv_create_event_queue(macdrv_event_handler handler
extern
void
macdrv_destroy_event_queue
(
macdrv_event_queue
queue
)
DECLSPEC_HIDDEN
;
extern
void
macdrv_destroy_event_queue
(
macdrv_event_queue
queue
)
DECLSPEC_HIDDEN
;
extern
int
macdrv_get_event_queue_fd
(
macdrv_event_queue
queue
)
DECLSPEC_HIDDEN
;
extern
int
macdrv_get_event_queue_fd
(
macdrv_event_queue
queue
)
DECLSPEC_HIDDEN
;
extern
int
macdrv_
get
_event_from_queue
(
macdrv_event_queue
queue
,
extern
int
macdrv_
copy
_event_from_queue
(
macdrv_event_queue
queue
,
macdrv_event_mask
mask
,
macdrv_event
*
event
)
DECLSPEC_HIDDEN
;
macdrv_event_mask
mask
,
macdrv_event
*
*
event
)
DECLSPEC_HIDDEN
;
extern
void
macdrv_
cleanup
_event
(
macdrv_event
*
event
)
DECLSPEC_HIDDEN
;
extern
void
macdrv_
release
_event
(
macdrv_event
*
event
)
DECLSPEC_HIDDEN
;
extern
macdrv_query
*
macdrv_create_query
(
void
)
DECLSPEC_HIDDEN
;
extern
macdrv_query
*
macdrv_create_query
(
void
)
DECLSPEC_HIDDEN
;
extern
macdrv_query
*
macdrv_retain_query
(
macdrv_query
*
query
)
DECLSPEC_HIDDEN
;
extern
macdrv_query
*
macdrv_retain_query
(
macdrv_query
*
query
)
DECLSPEC_HIDDEN
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment