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