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