OSXOperatingSystem.st
author Claus Gittinger <cg@exept.de>
Tue, 02 Apr 2019 10:50:28 +0200
changeset 24034 ba4c42171801
parent 24028 cda4ff7bb993
child 24047 df6ad32114b1
permissions -rw-r--r--
#BUGFIX by cg class: CharacterArray changed: #, #asDenseUnicodeString
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     1
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     2
 COPYRIGHT (c) 2013 by Claus Gittinger
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
     3
	      All Rights Reserved
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     4
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     5
 This software is furnished under a license and may be used
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     6
 only in accordance with the terms of that license and with the
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
     9
 other person.  No title to or ownership of the software is
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    10
 hereby transferred.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    11
"
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    12
"{ Package: 'stx:libbasic' }"
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    13
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    14
"{ NameSpace: Smalltalk }"
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    16
UnixOperatingSystem subclass:#OSXOperatingSystem
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    17
	instanceVariableNames:''
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
    18
	classVariableNames:'NSApp'
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    19
	poolDictionaries:''
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    20
	category:'OS-Unix'
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    21
!
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
    22
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    23
!OSXOperatingSystem primitiveDefinitions!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    24
%{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    25
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    26
#ifdef __osx__
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    27
// mhm - how could they forget this????
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    28
# ifndef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    29
#  define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(version)
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    30
# endif
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    31
#endif
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    32
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    33
#ifndef __osx__
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    34
# define NO_QUARTZ
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    35
# define NO_COCOA
22959
a88673d40f15 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22833
diff changeset
    36
# define NO_CARBON
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    37
#endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    38
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    39
// #include <mach/clock.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    40
// #include <mach/mach.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    41
// #include <sys/time.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    42
// #include <mach/clock.h>
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
    43
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    44
#ifndef NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    45
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    46
#   undef Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    47
#   undef Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    48
#   undef Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    49
#   undef Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    50
#   undef Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    51
#   undef Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    52
#   undef String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    53
#   undef Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    54
#   undef Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    55
#   undef Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    56
#   undef Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    57
#   undef Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    58
#   undef Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    59
#   undef Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    60
#   undef Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    61
#   undef Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    62
#   undef NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    63
#   undef Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    64
#   undef Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    65
#   undef Class
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    66
#   undef FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    67
#   undef true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    68
#   undef false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    69
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    70
#   undef INT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    71
#   undef UINT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    72
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    73
# include <ApplicationServices/ApplicationServices.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    74
# include <CoreFoundation/CoreFoundation.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    75
// #include <Foundation/Foundation.h>
21595
10b14f01369b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21594
diff changeset
    76
10b14f01369b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21594
diff changeset
    77
// #include <CoreGraphics/CGEventTypes.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    78
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    79
# include <stdlib.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    80
# include <stdio.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    81
# include <IOKit/graphics/IOGraphicsLib.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    82
22491
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    83
# include <objc/runtime.h>
e3e465028518 string.h handling (OSX)
Claus Gittinger <cg@exept.de>
parents: 21731
diff changeset
    84
# include <objc/message.h>
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    85
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    86
#  ifdef __DEF_Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    87
#   define Array __DEF_Array
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    88
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    89
#  ifdef __DEF_Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    90
#   define Number __DEF_Number
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    91
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    92
#  ifdef __DEF_Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    93
#   define Method __DEF_Method
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    94
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    95
#  ifdef __DEF_Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    96
#   define Point __DEF_Point
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    97
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    98
#  ifdef __DEF_Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
    99
#   define Rectangle __DEF_Rectangle
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   100
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   101
#  ifdef __DEF_Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   102
#   define Block __DEF_Block
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   103
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   104
#  ifdef __DEF_String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   105
#   define String __DEF_String
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   106
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   107
#  ifdef __DEF_Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   108
#   define Character __DEF_Character
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   109
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   110
#  ifdef __DEF_Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   111
#   define Message __DEF_Message
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   112
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   113
#  ifdef __DEF_Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   114
#   define Object __DEF_Object
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   115
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   116
#  ifdef __DEF_Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   117
#   define Context __DEF_Context
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   118
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   119
#  ifdef __DEF_Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   120
#   define Date __DEF_Date
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   121
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   122
#  ifdef __DEF_Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   123
#   define Time __DEF_Time
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   124
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   125
#  ifdef __DEF_Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   126
#   define Set __DEF_Set
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   127
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   128
#  ifdef __DEF_Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   129
#   define Signal __DEF_Signal
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   130
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   131
#  ifdef __DEF_Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   132
#   define Delay __DEF_Delay
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   133
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   134
#  ifdef __DEF_NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   135
#   define NameSpace __DEF_NameSpace
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   136
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   137
#  ifdef __DEF_Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   138
#   define Process __DEF_Process
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   139
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   140
#  ifdef __DEF_Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   141
#   define Processor __DEF_Processor
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   142
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   143
#  ifdef __DEF_Class
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   144
#   define STX_Class __DEF_Class
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   145
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   146
#  ifdef __DEF_FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   147
#   define FixedPoint __DEF_FixedPoint
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   148
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   149
#  ifdef __DEF_true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   150
#   undef true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   151
#   define true __DEF_true
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   152
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   153
#  ifdef __DEF_false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   154
#   undef false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   155
#   define false __DEF_false
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   156
#  endif
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   157
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   158
#  define INT STX_INT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   159
#  define UINT STX_UINT
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   160
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   161
typedef struct CMPoint {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   162
	double x;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   163
	double y;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   164
} CMPoint;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   165
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   166
typedef struct CMSize {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   167
	double width;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   168
	double height;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   169
} CMSize;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   170
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   171
typedef struct CMRect {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   172
	CMPoint origin;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   173
	CMSize size;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   174
} CMRect;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   175
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   176
typedef struct AppDel {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   177
	Class isa;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   178
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   179
	// Will be an NSWindow later.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   180
	id window;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   181
} AppDelegate;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   182
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   183
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   184
enum {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   185
	NSBorderlessWindowMask          = 0,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   186
	NSTitledWindowMask                      = 1 << 0,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   187
	NSClosableWindowMask            = 1 << 1,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   188
	NSMiniaturizableWindowMask      = 1 << 2,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   189
	NSResizableWindowMask           = 1 << 3,
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   190
};
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   191
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   192
typedef id(*CMacsSimpleMessage)(id, SEL);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   193
typedef void(*CMacsVoidMessage)(id, SEL);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   194
typedef void(*CMacsVoidMessage1)(id, SEL, void *);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   195
typedef id(*CMacsRectMessage1)(id, SEL, CMRect);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   196
typedef id(*CMacsWindowInitMessage)(id, SEL, CMRect, int, int, bool);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   197
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   198
extern CMacsSimpleMessage cmacs_simple_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   199
extern CMacsVoidMessage cmacs_void_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   200
extern CMacsVoidMessage1 cmacs_void_msgSend1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   201
extern CMacsRectMessage1 cmacs_rect_msgSend1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   202
extern CMacsWindowInitMessage cmacs_window_init_msgSend;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   203
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   204
#endif // NO_COCOA
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   205
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   206
%}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   207
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   208
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   209
!OSXOperatingSystem primitiveFunctions!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   210
%{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   211
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   212
#ifndef NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   213
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   214
CGEventRef
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   215
myCGEventCallback(CGEventTapProxy proxy, CGEventType type,
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   216
		  CGEventRef event, void *refcon)
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   217
{
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   218
    // Paranoid sanity check.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   219
    if ((type != kCGEventKeyDown) && (type != kCGEventKeyUp))
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   220
	return event;
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   221
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   222
    // The incoming keycode.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   223
    CGKeyCode keycode = (CGKeyCode)CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   224
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   225
    //Keypress code goes here.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   226
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   227
    // We must return the event for it to be useful.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   228
    return event;
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   229
}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   230
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   231
BOOL
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   232
AppDel_didFinishLaunching(AppDelegate *self, SEL _cmd, id notification) {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   233
//    self->window = cmacs_simple_msgSend((id)objc_getClass("NSWindow"), sel_getUid("alloc"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   234
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   235
//    /// Create an instance of the window.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   236
//    self->window = cmacs_window_init_msgSend(self->window, sel_getUid("initWithContentRect:styleMask:backing:defer:"), (CMRect){0,0,1024,460}, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   237
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   238
//    /// Create an instance of our view class.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   239
//    ///
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   240
//    /// Relies on the view having declared a constructor that allocates a class pair for it.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   241
//    id view = cmacs_rect_msgSend1(cmacs_simple_msgSend((id)objc_getClass("View"), sel_getUid("alloc")), sel_getUid("initWithFrame:"), (CMRect){ 0, 0, 320, 480 });
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   242
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   243
//    // here we simply add the view to the window.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   244
//    cmacs_void_msgSend1(self->window, sel_getUid("setContentView:"), view);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   245
//    cmacs_simple_msgSend(self->window, sel_getUid("becomeFirstResponder"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   246
//
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   247
//    // Shows our window in the bottom-left hand corner of the screen.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   248
//    cmacs_void_msgSend1(self->window, sel_getUid("makeKeyAndOrderFront:"), self);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   249
    return YES;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   250
}
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   251
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   252
#endif // NO_COCOA
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   253
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   254
%}
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   255
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   256
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   257
!OSXOperatingSystem class methodsFor:'documentation'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   258
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   259
copyright
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   260
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   261
 COPYRIGHT (c) 2013 by Claus Gittinger
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
   262
	      All Rights Reserved
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   263
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   264
 This software is furnished under a license and may be used
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   265
 only in accordance with the terms of that license and with the
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   266
 inclusion of the above copyright notice.   This software may not
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   267
 be provided or otherwise made available to, or used by, any
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   268
 other person.  No title to or ownership of the software is
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   269
 hereby transferred.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   270
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   271
!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   272
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   273
documentation
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   274
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   275
    a small number of OS-X specific redefinitions here.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   276
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   277
    [Author:]
21455
a657a28cab85 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21452
diff changeset
   278
	Claus Gittinger
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   279
"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   280
! !
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   281
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   282
!OSXOperatingSystem class methodsFor:'initialization'!
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   283
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   284
initializeCodeset
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   285
    super initializeCodeset.
17493
25361a7bc7e7 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17471
diff changeset
   286
    Codeset := #'utf8-mac'.
17494
4734c3c6fe43 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17493
diff changeset
   287
    CodesetEncoder := nil.
17471
98c49f19bae1 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17428
diff changeset
   288
! !
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   290
!OSXOperatingSystem class methodsFor:'cocoa - events'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   291
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   292
finishLaunching
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   293
    "tell the system, that I have finished my startup phase.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   294
     OSX will stop bounding the launch icon then."
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   295
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   296
    NSApp isNil ifTrue:[
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   297
	self getNSApp
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   298
    ].
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   299
%{
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   300
#ifndef NO_COCOA
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   301
    id NSApp = __externalAddressVal(@global(NSApp));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   302
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   303
    objc_msgSend(NSApp, sel_getUid("finishLaunching"));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   304
    RETURN(self);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   305
#endif // NO_COCOA
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   306
%}.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   307
    "/ if compiled without COCOA support (which you should not),
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   308
    "/ the icon will probably continue to bounce...
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   309
    "/ ... but we do not want an error here.
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   310
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   311
    "/ self primitiveFailed
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   312
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   313
    "
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   314
     self finishLaunching
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   315
    "
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   316
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   317
    "Modified: / 28-02-2017 / 10:59:15 / cg"
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   318
!
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   319
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   320
generateButtonEvent:button down:down x:screenX y:screenY
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   321
    "synthesize and send a button event to the screen"
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   322
%{
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   323
#ifndef NO_COCOA
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   324
    if (__bothSmallInteger(screenX, screenY)
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   325
     && __isSmallInteger(button)) {
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   326
	CGPoint pt;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   327
	pt.x = __intVal(screenX);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   328
	pt.y = __intVal(screenY);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   329
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   330
	CGEventType evType;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   331
	CGMouseButton evButton = __intVal(button);
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   332
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   333
	switch (evButton) {
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   334
	    case 1:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   335
		evType = (down == true) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   336
		evButton = 0;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   337
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   338
	    case 2:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   339
		evType = (down == true) ? kCGEventRightMouseDown : kCGEventRightMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   340
		evButton = 1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   341
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   342
	    case 3:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   343
		evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   344
		evButton = 2;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   345
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   346
	    default:
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   347
		evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   348
		evButton = __intVal(button) - 1;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   349
		break;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   350
	}
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   351
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   352
	CGEventRef theEvent = CGEventCreateMouseEvent(NULL, evType, pt, evButton);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   353
	CGEventSetType(theEvent, evType);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   354
	CGEventPost(kCGHIDEventTap, theEvent);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   355
	CFRelease(theEvent);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   356
	RETURN(self);
21584
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   357
    }
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   358
#endif // NO_COCOA
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   359
%}.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   360
    self primitiveFailed
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   361
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   362
    "
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   363
     OperatingSystem generateButtonEvent:1 down:true x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   364
     OperatingSystem generateButtonEvent:1 down:false x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   365
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   366
     OperatingSystem generateButtonEvent:2 down:true x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   367
     OperatingSystem generateButtonEvent:2 down:false x:150 y:150.
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   368
    "
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   369
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   370
    "Created: / 28-02-2017 / 00:15:18 / cg"
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   371
!
6a39bcb8636b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21582
diff changeset
   372
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   373
generateKeyboardEvent:keyCode down:down
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   374
    "synthesize and send a keyboard event to the screen"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   375
%{
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   376
#ifndef NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   377
    if (__isSmallInteger(keyCode)) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   378
	int evType;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   379
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   380
	CGEventRef theEvent = CGEventCreateKeyboardEvent(NULL, __intVal(keyCode), (down==true)?1:0);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   381
	CGEventSetType(theEvent, (down==true) ? kCGEventKeyDown:kCGEventKeyUp);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   382
	CGEventPost(kCGHIDEventTap, theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   383
	CFRelease(theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   384
	RETURN(self);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   385
    }
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   386
#endif // NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   387
%}.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   388
    self primitiveFailed
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   389
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   390
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   391
     OperatingSystem generateKeyboardEvent:6 down:true.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   392
     OperatingSystem generateKeyboardEvent:6 down:false.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   393
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   394
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   395
    "Created: / 02-03-2017 / 16:35:04 / cg"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   396
!
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   397
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   398
generateMouseMoveEventX:screenX y:screenY
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   399
    "synthesize and send a mosue move event to the screen"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   400
%{
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   401
#ifndef NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   402
    if (__bothSmallInteger(screenX, screenY)) {
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   403
	CGPoint pt;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   404
	pt.x = __intVal(screenX);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   405
	pt.y = __intVal(screenY);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   406
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   407
	CGEventType evType;
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   408
	CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pt, 0);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   409
	CGEventSetType(theEvent, kCGEventMouseMoved);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   410
	CGEventPost(kCGHIDEventTap, theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   411
	CFRelease(theEvent);
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   412
	RETURN(self);
21621
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   413
    }
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   414
#endif // NO_COCOA
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   415
%}.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   416
    self primitiveFailed
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   417
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   418
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   419
     OperatingSystem generateMouseMoveEventX:150 y:5.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   420
     Delay waitFor:(1 seconds).
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   421
     OperatingSystem generateMouseMoveEventX:1050 y:150.
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   422
    "
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   423
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   424
    "Created: / 02-03-2017 / 20:01:51 / cg"
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   425
!
0712ebc6d6cf #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21598
diff changeset
   426
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   427
getNSApp
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   428
    "get the NSApplication instance and remember in the global named NSApp"
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   429
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   430
%{
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   431
#ifndef NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   432
    Class AppDelClass = NULL;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   433
    id NSApp = NULL;
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   434
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   435
# if 0 /* not needed */
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   436
    Class poolClass = objc_getClass("NSAutoreleasePool");
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   437
    if (poolClass == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   438
	fprintf(stderr, "OSX: Unable to get NSAutoreleasePool\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   439
	RETURN(false);
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   440
    }
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   441
    id pool = objc_msgSend(poolClass, sel_registerName("alloc"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   442
    if (pool == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   443
	fprintf(stderr, "OSX: Unable to create NSAutoreleasePool\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   444
	RETURN(false);
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   445
    }
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   446
    objc_msgSend(pool, sel_registerName("init"));
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   447
# endif
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   448
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   449
# if 0 /* not needed */
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   450
    AppDelClass = objc_allocateClassPair((Class)objc_getClass("NSObject"), "AppDelegate", 0);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   451
    class_addMethod(AppDelClass, sel_getUid("applicationDidFinishLaunching:"), (IMP)AppDel_didFinishLaunching, "i@:@");
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   452
    objc_registerClassPair(AppDelClass);
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   453
# endif
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   454
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   455
    NSApp = objc_msgSend((id)objc_getClass("NSApplication"), sel_getUid("sharedApplication"));
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   456
    if (NSApp == NULL) {
21597
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   457
	fprintf(stderr,"OSX: Failed to initialize NSApplication\n");
4af9c6c70126 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21596
diff changeset
   458
	RETURN(false);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   459
    }
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   460
    @global(NSApp) = __MKEXTERNALADDRESS(NSApp);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   461
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   462
    id req = objc_msgSend(NSApp,sel_getUid("requestUserAttention:"),0);
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   463
    objc_msgSend(NSApp,sel_getUid("cancelUserAttentionRequest:"),req);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   464
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   465
# if 0 /* not needed */
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   466
    id appDelInst = objc_msgSend((id)objc_getClass("AppDelegate"), sel_getUid("alloc"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   467
    objc_msgSend(appDelInst, sel_getUid("init"));
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   468
    objc_msgSend(NSApp, sel_getUid("setDelegate:"), appDelInst);
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   469
# endif
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   470
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   471
# if 0 /* not needed */
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   472
    objc_msgSend(pool, sel_registerName("release"));
21731
81d141fee490 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21627
diff changeset
   473
# endif
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   474
    RETURN(true);
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   475
#endif // NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   476
%}.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   477
    self primitiveFailed
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   478
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   479
    "
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   480
     self getNSApp
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   481
    "
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   482
21594
acb127ad113c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21591
diff changeset
   483
    "Modified: / 28-02-2017 / 13:45:39 / cg"
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   484
!
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   485
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   486
receiveNextEvent
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   487
%{
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   488
#ifndef NO_COCOA
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   489
    CFMachPortRef      eventTap;
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   490
    CGEventMask        eventMask;
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   491
    CFRunLoopSourceRef runLoopSource;
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   492
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   493
    // Create an event tap. We are interested in key presses.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   494
    eventMask = ((1 << kCGEventKeyDown) | (1 << kCGEventKeyUp));
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   495
    eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0,
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   496
				eventMask, NULL, myCGEventCallback);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   497
    if (!eventTap) {
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   498
	fprintf(stderr, "failed to create event tap\n");
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   499
    } else {
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   500
	fprintf(stderr, "ok\n");
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   501
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   502
	// Create a run loop source.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   503
	runLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, eventTap, 0);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   504
	// Enable the event tap.
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   505
	CGEventTapEnable(eventTap, true);
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   506
    }
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   507
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   508
#endif // NO_COCOA
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   509
%}.
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   510
    self primitiveFailed
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   511
21591
c89611bc4b5c #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 21587
diff changeset
   512
    "Modified: / 28-02-2017 / 01:05:04 / cg"
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   513
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   514
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   515
!OSXOperatingSystem class methodsFor:'dummy shell operations'!
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   516
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   517
openApplicationForDocument:aFilenameOrString operation:operationSymbol
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   518
    "open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   519
     This is typically used to present help-files, html documents, pdf documents etc.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   520
     operationSymbol is one of:
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   521
	open
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   522
	edit
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   523
	explore
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   524
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   525
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   526
    |openCmd|
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   527
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   528
    (openCmd := self openApplicationHelperCommand) notNil ifTrue:[
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   529
	(operationSymbol = 'open') ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   530
	    self executeCommand:'open "',aFilenameOrString asFilename pathName,'"'
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   531
	] ifFalse:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   532
	    (operationSymbol = 'explore') ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   533
		self executeCommand:'open -R "',aFilenameOrString asFilename pathName,'"'
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   534
	    ].
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   535
	].
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   536
    ].
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   537
!
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   538
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   539
openApplicationHelperCommand
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   540
    "Return a command line helper to open a default application for file or URL"
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   541
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   542
    (self canExecuteCommand: 'open') ifTrue:[
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   543
	^ 'open'
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   544
    ].
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   545
    ^ nil
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   546
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   547
    "Created: / 13-01-2015 / 09:23:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   548
!
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   549
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   550
openTerminalWithCommand:shellCommand inBackground:inBackground
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   551
    "open a new terminal, which executes a command"
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   552
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   553
    |cmd|
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   554
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   555
    cmd := 'osascript -e ''tell application "Terminal" to do script "%1"''' bindWith:shellCommand.
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   556
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   557
    inBackground ifTrue:[
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   558
	^ self
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   559
	    startProcess:cmd
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   560
	    inputFrom:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   561
	    outputTo:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   562
	    errorTo:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   563
	    auxFrom:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   564
	    environment:nil
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   565
	    inDirectory:nil
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   566
    ] ifFalse:[
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   567
	^ self executeCommand:cmd
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   568
    ].
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   569
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   570
    "
17428
831e25b68d2c class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17427
diff changeset
   571
     OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true
17427
1ee32c4f30e9 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17297
diff changeset
   572
    "
17297
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   573
! !
a56ba300949c Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17179
diff changeset
   574
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
!OSXOperatingSystem class methodsFor:'file queries'!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
caseSensitiveFilenames
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    "return true, if the OS has caseSensitive file naming.
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
     On MSDOS, this will return false;
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   580
     on a real OS, we return true.
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   581
     Be aware, that OSX can be configured to be either.
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
   582
     Also, that it actually depends on the mounted volume"
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   584
    "/ actually, this is wrong and depends on the mounted volume;
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   585
    "/ so we need a query for a particular directory (and/or volume).
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
    ^ false
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    "Modified: / 5.6.1998 / 18:35:18 / cg"
16381
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   589
!
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   590
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   591
defaultPackagePath
20639
3bf77812174f #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20637
diff changeset
   592
    "redefined to add /Application and /Library stuff"
20642
56c52db3521a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20639
diff changeset
   593
    "called by Smalltalk initSystemPath"
56c52db3521a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20639
diff changeset
   594
    "self defaultPackagePath"
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   595
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   596
    |path executablePath executableDir packagesDir
20637
a9b41f05ca91 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 19817
diff changeset
   597
     libDir appDir versionsDir vsnDirName vsnDir|
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   598
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   599
    path := super defaultPackagePath.
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   600
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   601
    executablePath := OperatingSystem pathOfSTXExecutable.
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   602
    executablePath notNil ifTrue:[
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   603
	executableDir := executablePath asFilename directory.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   604
	packagesDir := executableDir directory directory / 'Packages'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   605
	packagesDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   606
	    packagesDir := packagesDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   607
	    (path includes:packagesDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   608
		path add:packagesDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   609
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   610
	].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   611
	libDir := '/Library/Frameworks/SmalltalkX.framework' asFilename.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   612
	libDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   613
	    versionsDir := libDir / 'Versions'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   614
	    versionsDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   615
		vsnDirName := '%1.%2.%3'
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   616
				    bindWith:Smalltalk majorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   617
				    with:Smalltalk minorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   618
				    with:Smalltalk revisionNr.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   619
		vsnDir := versionsDir / vsnDirName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   620
		vsnDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   621
		    vsnDir := vsnDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   622
		    (path includes:vsnDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   623
			path add:vsnDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   624
		    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   625
		].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   626
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   627
	].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   628
	appDir := '/Applications/SmalltalkX/' asFilename.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   629
	appDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   630
	    versionsDir := appDir / 'Versions'.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   631
	    versionsDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   632
		vsnDirName := '%1.%2.%3'
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   633
				    bindWith:Smalltalk majorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   634
				    with:Smalltalk minorVersionNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   635
				    with:Smalltalk revisionNr.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   636
		vsnDir := versionsDir / vsnDirName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   637
		vsnDir exists ifTrue:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   638
		    vsnDir := vsnDir pathName.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   639
		    (path includes:vsnDir) ifFalse:[
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   640
			path add:vsnDir.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   641
		    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   642
		].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   643
	    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   644
	].
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   645
    ].
16647
4c196996c402 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 16644
diff changeset
   646
    ^ path
16644
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   647
!
c8e610a071c3 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16381
diff changeset
   648
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   649
getDocumentsDirectory
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   650
    "return your documents directory.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   651
     Under osx, that's the user's 'Documents' folder.
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   652
     The fallback for other OS's may return the user's home directory."
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   653
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   654
    "{ Pragma: +optSpace }"
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   656
    |home documentsFolder|
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   657
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   658
    (home := self getHomeDirectory) notNil ifTrue:[
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   659
	(documentsFolder := home asFilename / 'Documents') exists ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   660
	    ^ documentsFolder pathName
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
   661
	].
22655
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   662
    ].
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   663
    ^ home
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   664
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   665
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   666
     OperatingSystem getDocumentsDirectory
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   667
    "
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   668
!
bf2c170bc0f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22491
diff changeset
   669
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   670
getDriveList
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   671
    "return a list of volumes in the system."
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   672
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   673
    ^ ('/Volumes' asFilename directoryContents)
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   674
      , super getDriveList
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   675
!
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   676
16381
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   677
getTrashDirectory
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   678
    "get the name of a trash folder (if the OS supports it),
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   679
     or nil, if not.
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   680
     Must be redefined to return non nil in concrete operating systems"
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   681
d47eab2e1e10 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15803
diff changeset
   682
    ^ '~/.Trash'
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   683
!
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   684
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   685
pathNameForDrive:driveName
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   686
    "given a drive name, return the pathname to open it as a directory.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   687
     For Windows, this is the driveName itself.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   688
     For OSX, '/Volumes' is prepended.
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   689
     Other OSs might prepent the pount point (i.e. /mnt/)"
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   690
16905
46653de3c189 class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16677
diff changeset
   691
    driveName isNil ifTrue:[^ nil].
16677
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   692
    driveName asFilename isAbsolute ifTrue:[^ driveName].
0f22d24efe9f class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16647
diff changeset
   693
    ^ '/Volumes/',driveName
17177
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   694
!
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   695
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   696
supportsVolumes
18279
6d7174763909 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 17494
diff changeset
   697
    "return true if the os support a list of drives/volumes
17179
d12edae8391b class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 17177
diff changeset
   698
     (here we can return a list of mounted drives in /Volumes)"
17177
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   699
28ebbb908d3e class: OSXOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 16905
diff changeset
   700
    ^ true
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
! !
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   703
!OSXOperatingSystem class methodsFor:'quartz - screen'!
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   704
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   705
getFrameBufferImage:displayNr
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   706
    "returns the framebuffer as an image object"
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   707
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   708
    ^ self getFrameBufferImage:displayNr in:nil
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   709
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   710
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   711
     self getFrameBufferImage:0
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   712
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   713
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   714
    "Modified: / 25-02-2017 / 10:57:17 / cg"
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   715
!
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   716
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   717
getFrameBufferImage:displayNr in:aRectangleOrNil
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   718
    "returns the frameBuffer (if rect-arg is nil)
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   719
     or part of the framebuffer (if non-nil) as an image object"
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   720
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   721
    |rx ry rwidth rheight bytesPerPixel bytesPerRow address pixels depth pad img ok|
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   722
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   723
    aRectangleOrNil notNil ifTrue:[
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   724
        rx := aRectangleOrNil left.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   725
        ry := aRectangleOrNil top.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   726
        rwidth := aRectangleOrNil width.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   727
        rheight := aRectangleOrNil height.
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   728
    ].
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   729
%{
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   730
#ifndef NO_COCOA
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   731
    CGImageRef image_ref;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   732
    CGDirectDisplayID displayID = CGMainDisplayID();
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   733
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   734
    ok = false;
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   735
    if (rx == nil) {
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   736
        image_ref  = CGDisplayCreateImage(displayID);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   737
    } else {
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   738
        CGRect rect;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   739
        rect.origin.x = (CGFloat)__intVal(rx);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   740
        rect.origin.y = (CGFloat)__intVal(ry);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   741
        rect.size.width = (CGFloat)__intVal(rwidth);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   742
        rect.size.height = (CGFloat)__intVal(rheight);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   743
        image_ref  = CGDisplayCreateImageForRect(displayID, rect);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   744
    }
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   745
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   746
    if (image_ref != NULL) {
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   747
        CGDataProviderRef provider = CGImageGetDataProvider(image_ref);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   748
        CFDataRef dataref = CGDataProviderCopyData(provider);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   749
        size_t c_width = CGImageGetWidth(image_ref);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   750
        size_t c_height = CGImageGetHeight(image_ref);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   751
        size_t c_bytesPerRow = CGImageGetBytesPerRow(image_ref);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   752
        size_t c_bytesPerPixel = CGImageGetBitsPerPixel(image_ref) / 8;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   753
        unsigned char *c_pixels = (unsigned char *)CFDataGetBytePtr(dataref);
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   754
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   755
        if (c_bytesPerPixel == 4) {
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   756
            int row;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   757
            pixels = __BYTEARRAY_UNINITIALIZED_NEW_INT(c_width * c_height * 3);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   758
            unsigned char *srcRowPtr = c_pixels;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   759
            unsigned char *dstRowPtr = __byteArrayVal(pixels);
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   760
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   761
            for (row=c_height; row>0; row--) {
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   762
                int col = c_width;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   763
                unsigned int *pixSrcPtr = (int*)srcRowPtr;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   764
                unsigned char *pixDstPtr = dstRowPtr;
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   765
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   766
                // convert abgr to rgb
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   767
#if (__POINTER_SIZE__ == 8) && defined(__LSBFIRST__)
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   768
                for (; col > 2; col -= 2) {
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   769
                    // pick 2 pixels
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   770
                    unsigned INT pix12 = ((unsigned INT*)pixSrcPtr)[0];
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   771
                    pixSrcPtr += 2;
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   772
                    // a2 r2 g2 b2 a1 r1 g1 b1 => r1..g1..b1..r2..g2..b2
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   773
                    pixDstPtr[0] = (pix12 >> 16) & 0xFF;
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   774
                    pixDstPtr[1] = (pix12 >> 8) & 0xFF;
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   775
                    pixDstPtr[2] = pix12 & 0xFF;
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   776
                    pixDstPtr[3] = (pix12 >> 48) & 0xFF;
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   777
                    pixDstPtr[4] = (pix12 >> 40) & 0xFF;
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   778
                    pixDstPtr[5] = (pix12 >> 32) & 0xFF;
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   779
                    pixDstPtr += 6;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   780
                }
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   781
#endif
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   782
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   783
                for (; col>0;col--) {
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   784
                    unsigned int pix = *pixSrcPtr++;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   785
#if 0
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   786
                    pix = ((pix >> 16) & 0x0000FF)|((pix << 16) & 0xFF0000)|(pix & 0x00FF00);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   787
                    pixDstPtr[0] = (pix >> 0);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   788
                    pixDstPtr[1] = (pix >> 8);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   789
                    pixDstPtr[2] = (pix >> 16);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   790
#else
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   791
                    pixDstPtr[0] = (pix >> 16) & 0xFF;
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   792
                    pixDstPtr[1] = (pix >> 8) & 0xFF;
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   793
                    pixDstPtr[2] = pix & 0xFF;
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   794
#endif
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   795
                    pixDstPtr += 3;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   796
                }
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   797
                dstRowPtr += c_width * 3;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   798
                srcRowPtr += c_bytesPerRow;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   799
            }
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   800
            bytesPerPixel = __MKSMALLINT(3);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   801
            bytesPerRow = __MKSMALLINT( c_width*3 );
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   802
            ok = true;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   803
        } else {
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   804
            // to be determined what we get...
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   805
            ok = false;
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   806
        }
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   807
        CFRelease(dataref);
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   808
        CGImageRelease(image_ref);
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   809
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   810
        rwidth = __MKUINT( c_width );
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   811
        rheight = __MKUINT( c_height );
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   812
    }
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   813
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   814
    // the following is no longer supported by apple
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   815
    // CGDisplayBaseAddress is deprecated
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   816
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   817
    //    uint32_t rowBytes, rowUInt32s, *screen;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   818
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   819
    //    CGDirectDisplayID targetDisplay = 0;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   820
    //
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   821
    //    screen = (uint32_t *)CGDisplayBaseAddress(targetDisplay);
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   822
    //    rowBytes = CGDisplayBytesPerRow(targetDisplay);
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   823
    //    rowUInt32s = rowBytes / 4;
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   824
    //    rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) );
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   825
    //    rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) );
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   826
    //
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   827
21596
ce0a09d20d18 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21595
diff changeset
   828
#endif // NO_COCOA
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   829
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   830
%}.
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   831
    (ok not or:[rwidth isNil]) ifTrue:[
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   832
        ^ self primitiveFailed
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   833
    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   834
    depth := bytesPerPixel * 8.
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   835
21587
3ac571f08fbf hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents: 21585
diff changeset
   836
    "/ Transcript printf:'w:%d h:%d bpp:%d depth:%d bpr: %d\n'
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   837
    "/            withAll:{ rwidth . rheight . bytesPerPixel . depth . bytesPerRow}.
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   838
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   839
    ( #(24) includes:depth) ifFalse:[
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   840
        "/ check what we get here...
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   841
        ^ self primitiveFailed:'unsupported depth'
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   842
    ].
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   843
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   844
    img := Image extent:(rwidth @ rheight) depth:depth bits:pixels.
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   845
    depth == 24 ifTrue:[
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   846
        img bitsPerSample:#[8 8 8].
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   847
        img samplesPerPixel:3.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   848
        img photometric:#rgb.
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   849
    ] ifFalse:[
23954
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   850
        depth == 16 ifTrue:[
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   851
            "/ to be determined...
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   852
            img bitsPerSample:#[5 5 5].
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   853
            img samplesPerPixel:3.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   854
            img photometric:#rgb.
e28c9c96d726 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 23314
diff changeset
   855
        ].
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   856
    ].
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   857
    ^ img
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   858
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   859
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   860
     self getFrameBufferImage:0 in:nil
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   861
     self getFrameBufferImage:0 in:(100@100 corner:301@303)
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   862
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   863
     Delay waitFor:3 seconds. self getFrameBufferImage:0 in:nil
21580
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   864
    "
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   865
b0c093983502 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21455
diff changeset
   866
    "Created: / 25-02-2017 / 09:49:07 / cg"
21598
4eb1335fe937 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 21597
diff changeset
   867
    "Modified (comment): / 28-02-2017 / 15:22:17 / cg"
24028
cda4ff7bb993 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 23954
diff changeset
   868
    "Modified: / 01-04-2019 / 00:39:22 / Claus Gittinger"
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   869
!
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   870
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   871
getScreenBounds:displayNr
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   872
    "returns the bounds of the screen.
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   873
     This is needed, because the dimension of the XQuartz screen does not include the dock."
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   874
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   875
    |rx ry rwidth rheight|
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   876
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   877
%{
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   878
#ifndef NO_COCOA
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   879
    CGDirectDisplayID targetDisplay = 0;
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   880
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   881
    rx = ry = __MKSMALLINT(0);
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   882
    rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) );
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   883
    rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) );
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   884
#endif // NO_COCOA
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   885
%}.
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   886
    (rwidth isNil) ifTrue:[
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   887
	^ self primitiveFailed
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   888
    ].
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   889
    ^ rx@ry extent:(rwidth@rheight)
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   890
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   891
    "
21627
213250371878 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 21625
diff changeset
   892
     self getScreenBounds:0
21625
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   893
    "
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   894
026eecef148d #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 21621
diff changeset
   895
    "Created: / 05-03-2017 / 11:10:08 / cg"
21452
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   896
! !
3435141db80f #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20642
diff changeset
   897
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   898
!OSXOperatingSystem class methodsFor:'sound & voice'!
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   899
23314
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   900
canPlaySound
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   901
    ^ true
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   902
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   903
    "Created: / 29-08-2018 / 09:35:52 / Claus Gittinger"
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   904
!
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   905
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   906
canSpeak
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   907
    ^ true
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   908
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   909
    "Created: / 29-08-2018 / 09:45:16 / Claus Gittinger"
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   910
!
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   911
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   912
playSound:soundFile
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   913
    "use 'say ...'"
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   914
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   915
    ^ self executeCommand:('afplay "%1"' bindWith:soundFile asFilename pathName)
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   916
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   917
    "
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   918
     self speak:'hello world'
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   919
    "
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   920
!
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   921
22970
ff49ded84d3a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22966
diff changeset
   922
voiceCommandSpec
ff49ded84d3a #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22966
diff changeset
   923
    ^ #(
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   924
	"/ triples are:
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   925
	"/      -command
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   926
	"/      -commandline for default voice
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   927
	"/      -commandline for specific voice
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   928
	(
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   929
	    'say'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   930
		'say "%2"'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   931
		'say -v "%1" "%2"'
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   932
	)
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   933
    )
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   934
!
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   935
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   936
voiceInfo
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   937
    "return a list of available voices plus info:
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   938
     for each available voice, a triple is returned, containing:
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   939
	voiceName language_territory comment/description
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   940
    "
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   941
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   942
    ^ (PipeStream outputFromCommand:'say -v ?')
23114
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   943
	asCollectionOfLines
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   944
	    collect:[:l |
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   945
		|s name lang comment|
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   946
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   947
		s := l readStream.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   948
		"/ skip forward for two separators
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   949
		[
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   950
		    [s next isLetterOrDigit] whileTrue:[].
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   951
		    s peek isLetterOrDigit
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   952
		] whileTrue.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   953
		name := l copyFrom:1 to:s position - 1.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   954
		s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   955
		lang := s upToSeparator.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   956
		s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   957
		s next == $# ifTrue:[
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   958
		    s skipSeparators.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   959
		    comment := s upToEnd utf8Decoded.
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   960
		].
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   961
		{ name . lang . comment }
21306b85ca30 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22970
diff changeset
   962
	    ]
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   963
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   964
    "
22966
57d20ca389c1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22962
diff changeset
   965
     OperatingSystem voiceInfo
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
   966
    "
23314
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   967
!
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   968
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   969
voiceMapping
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   970
    "return a mapping from common (OS-independent) voice names
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   971
     to OS-specific names or IDs.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   972
     The speak:voiceName interface will recognize both.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   973
     For portable programs, always use the OS-independent name and
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   974
     let every OS xlate to its internal name."
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   975
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   976
    |info map v|
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   977
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   978
    VoiceMapping notNil ifTrue:[^ VoiceMapping].
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   979
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   980
    info := self voiceInfo.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   981
    map := OrderedCollection new.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   982
    v := info detect:[:entry | #('Tom' 'Alex' 'Fred' 'Bruce' 'Ralph' 'Daniel') includes:entry first] ifNone:nil.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   983
    map add:( 'male' -> (v ? #(nil)) first ).
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   984
    v := info detect:[:entry | #('Samantha' 'Fiona' 'Karen' 'Moira') includes:entry first] ifNone:nil.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   985
    map add:( 'female' -> (v ? #(nil)) first ).
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   986
    v := info detect:[:entry | #('Zarvox') includes:entry first] ifNone:nil.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   987
    map add:( 'computer' -> (v ? #(nil)) first ).
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   988
    map add:( 'default' -> nil ).
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   989
    VoiceMapping := map.
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   990
    ^ VoiceMapping
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   991
    
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   992
    "on OSX, this could be:
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   993
        ^ {
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   994
            'male' -> 'Alex' .
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   995
            'female' -> 'Fiona' .
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   996
            'computer' -> 'Zarvox' .
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   997
            'default' -> 'Fiona'
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   998
        }
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
   999
    "
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1000
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1001
    "
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1002
     OperatingSystem voiceMapping
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1003
    "
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1004
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1005
    "Created: / 29-08-2018 / 09:55:00 / Claus Gittinger"
22962
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
  1006
! !
4352599df059 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 22959
diff changeset
  1007
22833
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1008
!OSXOperatingSystem class methodsFor:'time and date'!
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1009
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1010
getOSTimeWithNanos
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1011
    "This returns the OS time as a 2-element vector with milliseconds (as before)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1012
     plus nanoseconds.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1013
     The base of the returned value is not consistent across
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1014
     different OS's - some return the number of nanoseconds since jan, 1st 1970;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1015
     others since 1900. The Time classes are prepared for this, and
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1016
     convert as appropriate (by using my fromOSTime: conversion methods).
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1017
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1018
     Don't use this method in application code since it is an internal (private)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1019
     interface. For compatibility use instances of Time, Date or Timestamp to work with."
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1020
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1021
    |seconds millis nanos|
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1022
%{
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1023
// all of the experiments below only return 1us resolution
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1024
// on my machine. Not sure if that has to do with the OSX version (high sierra)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1025
// therefore, it is disabled, and we fall back to the inherited method,
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1026
// which returns microsecond resolution nanos anyway.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1027
#if 0
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1028
    unsigned long _secs, _millis, _nanos;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1029
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1030
# if defined(CLOCK_REALTIME) && !defined(NO_CLOCK_GETTIME)
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1031
    struct timespec ts;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1032
    static int has_clock_gettime = 1;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1033
    unsigned long _secs, _millis, _nanos;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1034
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1035
    if (has_clock_gettime) {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1036
	if (clock_gettime(CLOCK_REALTIME, &ts) != -1) {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1037
	    _secs = ts.tv_sec;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1038
	    _millis = ts.tv_nsec / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1039
	    _nanos = ts.tv_nsec % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1040
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1041
	    seconds = __MKUINT(_secs);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1042
	    millis = __MKUINT(_millis);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1043
	    nanos = __MKUINT(_nanos);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1044
	} else {
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1045
	    /*
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1046
	     * clock_gettime is not implemented in the kernel
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1047
	     * fall through to alternative implementation
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1048
	     */
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1049
	    has_clock_gettime = 0;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1050
	}
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1051
    }
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1052
# else
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1053
#  if 0
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1054
    // althoug documented, my osx doesn't have it...
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1055
    uint32_t secpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1056
    uint32_t nsecpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1057
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1058
    clock_get_calendar_nanotime(&secpart, &nsecpart);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1059
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1060
    _secs = secpart;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1061
    _millis = nsecpart / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1062
    _nanos = nsecpart % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1063
#  else
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1064
    // OS X does not have clock_gettime, use host_get_clock_service
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1065
    clock_serv_t cclock;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1066
    mach_timespec_t mts;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1067
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1068
    clock_get_time(cclock, &mts);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1069
    mach_port_deallocate(mach_task_self(), cclock);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1070
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1071
    _secs = mts.tv_sec;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1072
    _millis = mts.tv_nsec / 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1073
    _nanos = mts.tv_nsec % 1000000;
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1074
#  endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1075
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1076
    seconds = __MKUINT(_secs);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1077
    millis = __MKUINT(_millis);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1078
    nanos = __MKUINT(_nanos);
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1079
# endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1080
#endif
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1081
%}.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1082
    seconds notNil ifTrue:[
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1083
	^ { ((seconds * 1000) + millis) . nanos }
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1084
    ].
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1085
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1086
    ^ super getOSTimeWithNanos.
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1087
! !
60d71a4c5600 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 22655
diff changeset
  1088
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
!OSXOperatingSystem class methodsFor:'documentation'!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
version
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
  1092
    ^ '$Header$'
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
!
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
version_CVS
19817
b2aaa648f81d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 18279
diff changeset
  1096
    ^ '$Header$'
14819
ff6be3d27a81 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
! !
23314
1f3913819f30 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 23114
diff changeset
  1098