Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
a22be47f
Commit
a22be47f
authored
Jan 27, 2013
by
Ken Thomases
Committed by
Alexandre Julliard
Jan 28, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemac: Add infrastructure to convert from Cocoa event time to Wine tick count.
parent
6e59740e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
11 deletions
+44
-11
cocoa_app.h
dlls/winemac.drv/cocoa_app.h
+5
-0
cocoa_app.m
dlls/winemac.drv/cocoa_app.m
+10
-0
cocoa_main.m
dlls/winemac.drv/cocoa_main.m
+27
-9
macdrv_cocoa.h
dlls/winemac.drv/macdrv_cocoa.h
+1
-1
macdrv_main.c
dlls/winemac.drv/macdrv_main.c
+1
-1
No files found.
dlls/winemac.drv/cocoa_app.h
View file @
a22be47f
...
...
@@ -33,6 +33,8 @@
{
NSMutableArray
*
eventQueues
;
NSLock
*
eventQueuesLock
;
NSTimeInterval
eventTimeAdjustment
;
}
-
(
void
)
transformProcessToForeground
;
...
...
@@ -40,6 +42,9 @@
-
(
BOOL
)
registerEventQueue
:(
WineEventQueue
*
)
queue
;
-
(
void
)
unregisterEventQueue
:(
WineEventQueue
*
)
queue
;
-
(
void
)
computeEventTimeAdjustmentFromTicks
:(
unsigned
long
long
)
tickcount
uptime
:(
uint64_t
)
uptime_ns
;
-
(
double
)
ticksForEventTime
:(
NSTimeInterval
)
eventTime
;
@end
void
OnMainThread
(
dispatch_block_t
block
);
...
...
dlls/winemac.drv/cocoa_app.m
View file @
a22be47f
...
...
@@ -108,6 +108,16 @@ int macdrv_err_on;
[
eventQueuesLock
unlock
];
}
-
(
void
)
computeEventTimeAdjustmentFromTicks
:
(
unsigned
long
long
)
tickcount
uptime
:
(
uint64_t
)
uptime_ns
{
eventTimeAdjustment
=
(
tickcount
/
1000
.
0
)
-
(
uptime_ns
/
(
double
)
NSEC_PER_SEC
);
}
-
(
double
)
ticksForEventTime
:
(
NSTimeInterval
)
eventTime
{
return
(
eventTime
+
eventTimeAdjustment
)
*
1000
;
}
@end
/***********************************************************************
...
...
dlls/winemac.drv/cocoa_main.m
View file @
a22be47f
...
...
@@ -19,6 +19,8 @@
*
/
#
import
<
AppKit
/
AppKit
.
h
>
#
include
<
mach
/
mach
.
h
>
#
include
<
mach
/
mach_time
.
h
>
#
include
"
macdrv_cocoa
.
h
"
#
import
"
cocoa_app
.
h
"
...
...
@@ -33,6 +35,13 @@ enum {
};
struct
cocoa_app_startup_info
{
NSConditionLock
*
lock
;
unsigned
long
long
tickcount
;
uint64_t
uptime_ns
;
};
/
***********************************************************************
*
run_cocoa_app
*
...
...
@@ -50,12 +59,14 @@ enum {
*
/
static
void
run_cocoa_app
(
void
*
info
)
{
NSConditionLock
*
lock
=
info
;
struct
cocoa_app_startup_info
*
startup_info
=
info
;
NSConditionLock
*
lock
=
startup_info
->
lock
;
NSAutoreleasePool
*
pool
=
[[
NSAutoreleasePool
alloc
]
init
];
[
WineApplication
sharedApplication
];
[
NSApp
setDelegate
:(
WineApplication
*
)
NSApp
];
[
NSApp
computeEventTimeAdjustmentFromTicks
:
startup_info
->
tickcount
uptime
:
startup_info
->
uptime_ns
];
/
*
Retain
the
lock
while
we
'
re
using
it
,
so
macdrv_start_cocoa_app
()
doesn
'
t
deallocate
it
in
the
middle
of
us
unlocking
it
.
*
/
...
...
@@ -78,11 +89,13 @@ static void run_cocoa_app(void* info)
*
*
Returns
0
on
success
,
non
-
zero
on
failure
.
*
/
int
macdrv_start_cocoa_app
(
void
)
int
macdrv_start_cocoa_app
(
unsigned
long
long
tickcount
)
{
int
ret
=
-
1
;
CFRunLoopSourceRef
source
;
NSConditionLock
*
lock
;
struct
cocoa_app_startup_info
startup_info
;
uint64_t
uptime_mach
=
mach_absolute_time
();
mach_timebase_info_data_t
mach_timebase
;
NSDate
*
timeLimit
;
CFRunLoopSourceContext
source_context
=
{
0
};
...
...
@@ -94,29 +107,34 @@ int macdrv_start_cocoa_app(void)
toTarget
:[
NSThread
class
]
withObject
:
nil
];
lock
=
[[
NSConditionLock
alloc
]
initWithCondition
:
COCOA_APP_NOT_RUNNING
];
startup_info
.
lock
=
[[
NSConditionLock
alloc
]
initWithCondition
:
COCOA_APP_NOT_RUNNING
];
startup_info
.
tickcount
=
tickcount
;
mach_timebase_info
(
&
mach_timebase
);
startup_info
.
uptime_ns
=
uptime_mach
*
mach_timebase
.
numer
/
mach_timebase
.
denom
;
timeLimit
=
[
NSDate
dateWithTimeIntervalSinceNow
:
5
];
source_context
.
info
=
lock
;
source_context
.
info
=
&
startup_info
;
source_context
.
perform
=
run_cocoa_app
;
source
=
CFRunLoopSourceCreate
(
NULL
,
0
,
&
source_context
);
if
(
source
&&
lock
&&
timeLimit
)
if
(
source
&&
startup_info
.
lock
&&
timeLimit
)
{
CFRunLoopAddSource
(
CFRunLoopGetMain
(),
source
,
kCFRunLoopCommonModes
);
CFRunLoopSourceSignal
(
source
);
CFRunLoopWakeUp
(
CFRunLoopGetMain
());
if
([
lock
lockWhenCondition
:
COCOA_APP_RUNNING
beforeDate
:
timeLimit
])
if
([
startup_info
.
lock
lockWhenCondition
:
COCOA_APP_RUNNING
beforeDate
:
timeLimit
])
{
[
lock
unlock
];
[
startup_info
.
lock
unlock
];
ret
=
0
;
}
}
if
(
source
)
CFRelease
(
source
);
[
lock
release
];
[
startup_info
.
lock
release
];
[
pool
release
];
return
ret
;
}
dlls/winemac.drv/macdrv_cocoa.h
View file @
a22be47f
...
...
@@ -112,7 +112,7 @@ struct macdrv_display {
/* main */
extern
int
macdrv_err_on
;
extern
int
macdrv_start_cocoa_app
(
void
)
DECLSPEC_HIDDEN
;
extern
int
macdrv_start_cocoa_app
(
unsigned
long
long
tickcount
)
DECLSPEC_HIDDEN
;
/* display */
...
...
dlls/winemac.drv/macdrv_main.c
View file @
a22be47f
...
...
@@ -40,7 +40,7 @@ static BOOL process_attach(void)
if
((
thread_data_tls_index
=
TlsAlloc
())
==
TLS_OUT_OF_INDEXES
)
return
FALSE
;
macdrv_err_on
=
ERR_ON
(
macdrv
);
if
(
macdrv_start_cocoa_app
())
if
(
macdrv_start_cocoa_app
(
GetTickCount64
()
))
{
ERR
(
"Failed to start Cocoa app main loop
\n
"
);
return
FALSE
;
...
...
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