Difference between revisions of "Mac OS X Porting - Comparison to Toolkit Ports"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Introduction ==
 +
In addition to OpenOffice.org for Mac OS X porting effort, recently also several significant open source toolkits have been ported to Mac OS X. These include [http://developer.imendio.com/projects/gtk-macosx GTK], [http://wiki.mozilla.org/Mac:Home_Page XUL (Mozilla)], QT and WxWidgets.
  
 +
Each of these ports have chosen somewhat different approaches, due to nature of the original code and the preferences of available Mac OS X (e.g. Cocoa, Carbon) and open source technologies (e.g. Cairo). There are also many similarities also. This page aims to describe how (and possibly why) the ports differ, and in places where OpenOffice.org Mac OS X port code is not yet matured, what potential solutions exist.
 +
 +
=== Resources ===
 +
* [http://developer.imendio.com/files/developer/Porting-Gtk-MacOSX.pdf Anders Carlsson's report on GTK Mac OS X port] (May 2006)
 +
* [http://wiki.mozilla.org/Mac:Home_Page Mozilla Mac Port pages]
 +
* [http://developer.imendio.com/projects/gtk-macosx GTK Mac porting pages]
 +
* [[Mac OS X|OpenOffice.org Mac Porting pages]]
 +
 +
== Explanations ==
 +
In order to understand the different technologies, here's a short introduction to the key parts:
 +
 +
=== Low level APIs ===
 +
CF* = Core Foundation functions - The Mac OS X system layer that operates e.g. the run/event loop. Both Cocoa and Carbon use these functions
 +
 +
CG* = Core Graphics functions i.e. '''Quartz''' The Mac OS X graphics rendering layer. Both Cocoa and Carbon use these functions
 +
 +
ATS = Apple Type Services API - The Mac OS X api for font enumeration (finding available fonts)
 +
 +
ATSUI = Apple Type Services for Unicode Imaging - the Mac OS X API for laying out (shaping) and drawing (rendering) Unicode text in correct manner.
 +
 +
'''Cairo''' - open source, cross-platform PDF-like graphics rendering API. Implementations include X11, Windows, Mac OS X. The Mac OS X implementation uses mainly CG* functions with some other stuff (FIXME: add details).
 +
 +
NOTE: currently (Jan 2007) Cairo includes two Mac OS X backends: cairo-quartz and cairo-nquartz. The cairo-quartz is the older one and used in GTK port. The other nquartz/"Native Quartz" is used by new Mozilla XUL code. It is expected that native quartz backend will replace the older backend and become the default backend for Mac OS X.
 +
 +
=== High level APIs ===
 +
 +
Carbon = C language based API for creating GUI applications in Mac OS X. The Carbon API is closer to Win32 and X11 API than the Cocoa API.
 +
 +
NS* = Cocoa = Objective C based API for creating GUI applications in Mac OS X. This NextStep derived object oriented, and uses messages to pass commands between functions. The API that Mac OS X itself uses for the system and applications.
 +
 +
 +
== Comparison ==
 +
 +
Note: Although OpenOffice.org currently uses exclusively Carbon APIs, and not Cocoa APIs, this is not a hard requirement. Thanks to the use of CFRunLoop, it is possible to use e.g. NSApplication if that is deemed a better approach. Future work will reveal the best choices.
  
 
{| border="1" cellpadding="5" cellspacing="0" align="center"
 
{| border="1" cellpadding="5" cellspacing="0" align="center"
|+'''Comparison between OpenOffice.org and toolkit ports'''
+
|+'''Comparison between OpenOffice.org and toolkit ports to Mac OS X'''
 +
|-
 +
! style="width:100px;" |   !! style="background:#59e;width:200px;" | OpenOffice.org !! style="background:#59e;width:200px;" | GTK !! style="background:#59e;width:200px;" | XUL (Mozilla) 
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Fonts
 +
|-
 +
| '''Enumeration'''<br> ''Getting and showing the list of available fonts to user'' || ATS || NSFontManager<br>''The only way to get identical font (family) listing as in Mac OS X native applications and in Font Book'' || ''not yet implemented?''
 +
|-
 +
| '''Shaping'''<br> ''text strings to glyphs'' || ATSUI<br>''not fully implemented'' || ATSUI via Pango<br>''a pango shaping engine'' || ATSUI?
 +
|-
 +
| '''Rendering'''<br> ''Glyphs to screen/print'' || ATSUI<br>''not fully implemented'' || ATSUI via Cairo<br>''cairo_show_glyphs'' || ATSUI?
 +
|-
 +
| '''Metrics'''<br> ''font analysis and information, also font substitution'' || ?? || ATS via Pango, font substitution not implemented || ??
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Main Loop integration
 +
|-
 +
| ''Toolkit event loop integration'' || CF* and Carbon || CF* and NSApplication (Cocoa)<br>''with custom event sources'' || CF* and NSApplication (Cocoa)
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Drawing (Rendering)
 +
|-
 +
| ''OLD'' || CG* via VCL API<br>''Win32 based API'' || CG* via GDK API<br>''X11 based API'' || ?
 +
|-
 +
| ''NEW'' || CG* via VCL or<br>CG* via Cairo in OOo Canvas || CG* via Cairo in GDK Cairo API || CG* via Cairo in Mozilla Thebes API
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Images
 +
|-
 +
| colspan="4" | X11 has concept of server-side/drawable: '''pixmaps''' (many depths, 1-bit = "Bitmap"), and client-side/non-drawable: '''images''' (no alpha) and '''pixbufs''' (can have alpha)
 +
|-
 +
| ''image handling'' || ''only basics implemented'' || CGImageRef (could be CGLayer for Mac OS X 10.4+) via GdkPixmap, GdkImage and GdkPixbuf || ??
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Windows
 +
|-
 +
| '''Root and top level windows''' || HiView (Carbon) || NSWindow + NSView (Cocoa) || ? (Cocoa)
 +
|-
 +
| '''Child windows'''<br>''Mac OS X does not natively have these'' || ''not implemented'' || NSView with reference to top level NSWindow || ? (Cocoa)
 +
|-
 +
| '''Input-only windows'''<br>''Mac OS X does not natively have these'' || FIXME: needed for OOo? || emulated/custom code || ?
 +
|-
 +
! style="background:#abcdef;" colspan="4" | Cursors
 +
|-
 +
| ''changing cursor depending on the area where it is (e.g. text input cursor, dragging cursor)'' || ''not implemented'' || NSCursor<br>''implements GdkCursor'' || ??
 
|-
 
|-
! style="background:#ffffef;" !! OpenOffice.org !! GTK !! Mozilla  
+
! style="background:#abcdef;" colspan="4" | Events (custom dispatching)
 +
|-
 +
| colspan="4" | OOo and toolkits have their own event system in addition to the platform's own event system
 +
|-
 +
| '''Mouse events'''  || kEventMouseDown et al. (Carbon) || NSLeftMouseDown et al. (Cocoa) || ??
 +
|-
 +
| '''Keyboard Events'''<br>'' || partial implementation || events always sent to top-level window || ??
 +
|-
 +
| '''Crossing Events'''<br>''a X11 feature where windows are notified when mouse leaves/enters the window || FIXME: needed for OOo? || custom code/emulation'' || ??
 +
|-
 +
| '''Resize Events'''<br>''When window size changes'' || FIXME: needed for OOo? || emulated ||??
 
|-
 
|-
! Fonts
+
| '''Mouse/Keyboard grabs'''<br>''a X11 feature where input field can grab the mouse/keyboard even when mouse is moved away from the area. Mac OS X does not natively have these'' || FIXME: needed for OOo? || custom code/emulation || Not Needed
| -
+
|-  
| Enumeration (Getting and showing the list of available fonts to user
+
| -
+
| Shaping (text strings to glyphs)
+
| -
+
| Rendering (Glyphs to screen/print)
+
| -
+
| Metrics (font analysis and information)
+
| -
+
! Main Loop integration
+
| -  
+
  
 
|}
 
|}
Line 24: Line 100:
 
[[Category:MacOSX]]
 
[[Category:MacOSX]]
 
[[Category:Aqua]]
 
[[Category:Aqua]]
 +
[[Category:User Experience]]
 +
[[Category:To-Do]]

Latest revision as of 17:19, 14 September 2007

Introduction

In addition to OpenOffice.org for Mac OS X porting effort, recently also several significant open source toolkits have been ported to Mac OS X. These include GTK, XUL (Mozilla), QT and WxWidgets.

Each of these ports have chosen somewhat different approaches, due to nature of the original code and the preferences of available Mac OS X (e.g. Cocoa, Carbon) and open source technologies (e.g. Cairo). There are also many similarities also. This page aims to describe how (and possibly why) the ports differ, and in places where OpenOffice.org Mac OS X port code is not yet matured, what potential solutions exist.

Resources

Explanations

In order to understand the different technologies, here's a short introduction to the key parts:

Low level APIs

CF* = Core Foundation functions - The Mac OS X system layer that operates e.g. the run/event loop. Both Cocoa and Carbon use these functions

CG* = Core Graphics functions i.e. Quartz The Mac OS X graphics rendering layer. Both Cocoa and Carbon use these functions

ATS = Apple Type Services API - The Mac OS X api for font enumeration (finding available fonts)

ATSUI = Apple Type Services for Unicode Imaging - the Mac OS X API for laying out (shaping) and drawing (rendering) Unicode text in correct manner.

Cairo - open source, cross-platform PDF-like graphics rendering API. Implementations include X11, Windows, Mac OS X. The Mac OS X implementation uses mainly CG* functions with some other stuff (FIXME: add details).

NOTE: currently (Jan 2007) Cairo includes two Mac OS X backends: cairo-quartz and cairo-nquartz. The cairo-quartz is the older one and used in GTK port. The other nquartz/"Native Quartz" is used by new Mozilla XUL code. It is expected that native quartz backend will replace the older backend and become the default backend for Mac OS X.

High level APIs

Carbon = C language based API for creating GUI applications in Mac OS X. The Carbon API is closer to Win32 and X11 API than the Cocoa API.

NS* = Cocoa = Objective C based API for creating GUI applications in Mac OS X. This NextStep derived object oriented, and uses messages to pass commands between functions. The API that Mac OS X itself uses for the system and applications.


Comparison

Note: Although OpenOffice.org currently uses exclusively Carbon APIs, and not Cocoa APIs, this is not a hard requirement. Thanks to the use of CFRunLoop, it is possible to use e.g. NSApplication if that is deemed a better approach. Future work will reveal the best choices.

Comparison between OpenOffice.org and toolkit ports to Mac OS X
  OpenOffice.org GTK XUL (Mozilla)
Fonts
Enumeration
Getting and showing the list of available fonts to user
ATS NSFontManager
The only way to get identical font (family) listing as in Mac OS X native applications and in Font Book
not yet implemented?
Shaping
text strings to glyphs
ATSUI
not fully implemented
ATSUI via Pango
a pango shaping engine
ATSUI?
Rendering
Glyphs to screen/print
ATSUI
not fully implemented
ATSUI via Cairo
cairo_show_glyphs
ATSUI?
Metrics
font analysis and information, also font substitution
 ?? ATS via Pango, font substitution not implemented  ??
Main Loop integration
Toolkit event loop integration CF* and Carbon CF* and NSApplication (Cocoa)
with custom event sources
CF* and NSApplication (Cocoa)
Drawing (Rendering)
OLD CG* via VCL API
Win32 based API
CG* via GDK API
X11 based API
 ?
NEW CG* via VCL or
CG* via Cairo in OOo Canvas
CG* via Cairo in GDK Cairo API CG* via Cairo in Mozilla Thebes API
Images
X11 has concept of server-side/drawable: pixmaps (many depths, 1-bit = "Bitmap"), and client-side/non-drawable: images (no alpha) and pixbufs (can have alpha)
image handling only basics implemented CGImageRef (could be CGLayer for Mac OS X 10.4+) via GdkPixmap, GdkImage and GdkPixbuf  ??
Windows
Root and top level windows HiView (Carbon) NSWindow + NSView (Cocoa)  ? (Cocoa)
Child windows
Mac OS X does not natively have these
not implemented NSView with reference to top level NSWindow  ? (Cocoa)
Input-only windows
Mac OS X does not natively have these
FIXME: needed for OOo? emulated/custom code  ?
Cursors
changing cursor depending on the area where it is (e.g. text input cursor, dragging cursor) not implemented NSCursor
implements GdkCursor
 ??
Events (custom dispatching)
OOo and toolkits have their own event system in addition to the platform's own event system
Mouse events kEventMouseDown et al. (Carbon) NSLeftMouseDown et al. (Cocoa)  ??
Keyboard Events
partial implementation events always sent to top-level window  ??
Crossing Events
a X11 feature where windows are notified when mouse leaves/enters the window
FIXME: needed for OOo? custom code/emulation  ??
Resize Events
When window size changes
FIXME: needed for OOo? emulated ??
Mouse/Keyboard grabs
a X11 feature where input field can grab the mouse/keyboard even when mouse is moved away from the area. Mac OS X does not natively have these
FIXME: needed for OOo? custom code/emulation Not Needed
Personal tools