Difference between revisions of "AquaPortCocoa/Changelog"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Timers)
(Timers)
Line 157: Line 157:
 
ImplSalStartTimer(): new implementation, using only one parameter ( ULONG nMS).
 
ImplSalStartTimer(): new implementation, using only one parameter ( ULONG nMS).
  
The second parameter bMutex is not used anymore. Now, the test stands on the boolean isNSAppThread(), read in SalData structure (pSalData->mpFirstInstance).
+
The second parameter bMutex is not used anymore.  
 +
Now, the test stands on the boolean isNSAppThread(), read in SalData structure (pSalData->mpFirstInstance).
 +
 
 +
To understand more, there are three ways to create a timer.
 +
Here, ImplSalStartTimer() uses  scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: class methods automatically add the new timer to the
 +
current NSRunLoop object in the default mode (NSDefaultRunLoopMode).
  
To understand more, there are three ways to create a timer. Here, ImplSalStartTimer() uses  scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: class methods automatically add the new timer to the current NSRunLoop object in the default mode (NSDefaultRunLoopMode).
 
 
Important : in the case pSalData->mpFirstInstance->isNSAppThread() is false, we have to post an event, to get in the main thread.  // FIXME: find more infos
 
Important : in the case pSalData->mpFirstInstance->isNSAppThread() is false, we have to post an event, to get in the main thread.  // FIXME: find more infos
  

Revision as of 08:39, 6 August 2007

Comments in the changes ( aquavcl03 cws )

What follows are dev notes relative to Cocoa migration in Open Office.org code ( Aqua version for Mac OS X )

Changes can be divided into several parts. The initial try (not sure it is the best) will describes changes modules by modules

solenv

All changes in this part are made for fix building issues.

In order to use Cocoa framework, objective-C and objective-C++ flags must be passed to the compiler at build time.

Follow some severe build breakers, fixed with the changes described below. Of course, until aquavcl03 reaches an alpha states, we cannot consider the changes below as definitive.

Initial solenv changes were made in AquaPortCocoa

unxmacx.mk-1.18vs.1.18.36.1

Initial changes

unxmacx.mk-1.18.36.1vs.1.18.36.2

Remove CFLAGSCXX+=$(OBJCXXFLAGS) from unxmacx.mk and put them into vcl dedicated makefile instead. The reason is :

when in solenv -> all modules are concerned, and they are breakers

when in vcl only -> no build issue

Drawback: new modified modules using Objective-C++ flags, must be modified separately. We have not enough experience to decide wich exact strategy use yet.

vcl

We'll try to describe and justify every change in vcl. First were build issues, and they will be described first.

An important part about design should complete asap.

The most important changes will be about :

- frames /Windowing : CarbonViewRefs wil be replaced by NSViews, same issue for windows

- events : new event management

- threading issues: a new implementation is mandatory

- timers issues : In OpenOffice.org timers are (unfortunaly) everywhere, and a new implementation is needed

- strings : NSStrings will replace CFStrings

- datas: important system datas are available via SalData class. The old design must be adapted for Cocoa change


TODO : replace Carbon menus with Cocoa menus, create .nib entry and links, new Drag and drop implementation ( Cocoa only)

Build

makefile2.pmk-1.3vs.1.3.638.1

Add objective-C++ flags in a dedicated makefile : makefile2.pmk ( all makefiles in vcl/aqua/source include it )

Events

aquavcltypes.h-1.2 vs. 1.2.4.1.html

#include <premac.h>
#include <Carbon/Carbon.h>
+#import <Cocoa/Cocoa.h>
+#import <AppKit/NSEvent.h>
#include <postmac.h>

-> #import replaces #include, and add only once every needed header file.


NSEvent.h does contain all event types.

e.g. :

	NSLeftMouseDown		= 1,
	NSLeftMouseUp		= 2,
	NSRightMouseDown	= 3,
	NSRightMouseUp		= 4,
	NSMouseMoved		= 5,
	NSLeftMouseDragged	= 6,
	NSRightMouseDragged	= 7,
	NSMouseEntered		= 8,
	NSMouseExited		= 9,
	NSKeyDown		= 10,
	NSKeyUp			= 11,

... etc

SalDatas

saldata.hxx-1.14 vs 1.14.4.1.html

- #include <Carbon/Carbon.h>                                                      
+ #include <Cocoa/Cocoa.h>

Remove every Carbon thing, and use Cocoa definitions instead

- class SalInstance;
+ class AquaSalInstance;

Define AquaSalInstance

 - /*                                                                                                                                                      
 -   * SalTimer related members                                                  
 -   */                                                                         
-   BOOL              mbInTimerProc;     // timer event is currently being dispatched
-    BOOL              mbTimerInstalled;  // timer is in the event loop            
-   ULONG             mnTimerMS;         // Current Time (in MS) of the Timer   
-   ULONG             mnTimerOrgMS;      // Current Original Time (in MS)       
-   EventLoopTimerRef mrTimerRef;                                               
-   EventLoopTimerUPP mrTimerUPP;

-> remove Carbon Timers

means : remove all Carbon timers members in SalData structure


TODO :

- check in the code if old code is remaining

Timers

1) saltimer.h-1.4vs.1.4.4.1

Added: prototype for handleStartTimerEvent(), as static void method in AquaSalTimer class.


2) saltimer.cxx-1.14vs.1.14.4.1

Conditionnal inclusions for saltimer.h, saldata.hxx and salframe.h have been removed

USEMAINTHREAD is not defined anymore (was true before the change),the boolean isNSAppThread() is tested instead in the new implementation.

Added:

implementations+initializations of static methods:

- pRunningTimer, as pointer on NSTimer object type ( NSTimer creates timer objects or, more simply, timers )

Note :  NSTimer is “toll-free bridged” with its Core Foundation counterpart, CFRunLoopTimer.
This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object.
Therefore, in a method where you see an NSTimer * parameter, you can pass a CFRunLoopTimerRef,
and in a function where you see a CFRunLoopTimerRef parameter, you can pass an NSTimer instance
(you cast one type to the other to suppress compiler warnings)

- bDispatchTimer, bTimerInDispatch as booleans

Added TimerCallbackCaller class, inherited from NSObject class.

ImplSalStartTimer(): new implementation, using only one parameter ( ULONG nMS).

The second parameter bMutex is not used anymore. Now, the test stands on the boolean isNSAppThread(), read in SalData structure (pSalData->mpFirstInstance).

To understand more, there are three ways to create a timer. Here, ImplSalStartTimer() uses scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: class methods automatically add the new timer to the current NSRunLoop object in the default mode (NSDefaultRunLoopMode).

Important : in the case pSalData->mpFirstInstance->isNSAppThread() is false, we have to post an event, to get in the main thread. // FIXME: find more infos

ImplSalStopTimer(): simply set bDispatchTimer to false stops the timer.

AquaSalTimer::AquaSalTimer(): removed previous implementation, using a pointer on SalData object.

(mbTimerInstalled, mnTimerMS, mnTimerOrgMS, mrTimerUPP have been removed )

New void AquaSalTimer::handleStartTimerEvent() implementation:

2) saltimer.cxx-1.14.4.1vs.1.14.4.2

Removed all AquaLog() entries

Modified setFireDate for pRunningTimer object: only setFireDate if [pRunningTimer timeInterval] == aTI.

If different, invalidate pRunningTimer, and retry.

Frame

salframe.h- 1.18 vs. 1.18.4.1

New classes for SalFrameWindow and SalFrameView using objective-C syntax + new variables (and associated types):

@interface SalFrameWindow : NSWindow                                            
{                                                                               
    AquaSalFrame*       mpFrame;                                                
}                                                                               
-(id)initWithSalFrame: (AquaSalFrame*)pFrame;                                   
-(void)windowDidBecomeKey: (NSNotification*)pNotification;                      
-(void)windowDidResignKey: (NSNotification*)pNotification;                      
-(void)windowDidChangeScreen: (NSNotification*)pNotification;                   
-(void)windowDidMove: (NSNotification*)pNotification;                           
-(void)windowDidResize: (NSNotification*)pNotification;                         
-(void)windowDidMiniaturize: (NSNotification*)pNotification;                    
-(void)windowDidDeminiaturize: (NSNotification*)pNotification;                  
-(MacOSBOOL)windowShouldClose: (NSNotification*)pNotification;                  
@end                                                                                                                                                  
                                                                                
@interface SalFrameView : NSView                                                
{                                                                               
    AquaSalFrame*       mpFrame;                                                
}                                                                               
-(id)initWithSalFrame: (AquaSalFrame*)pFrame;                                   
-(MacOSBOOL)acceptsFirstResponder;                                              
-(MacOSBOOL)acceptsFirstMouse: (NSEvent *)pEvent;                               
-(MacOSBOOL)isOpaque;                                                           
-(void)drawRect: (NSRect)aRect;                                                 
-(void)mouseDown: (NSEvent*)pEvent;                                             
-(void)mouseDragged: (NSEvent*)pEvent;                                          
-(void)mouseUp: (NSEvent*)pEvent;                                               
-(void)mouseMoved: (NSEvent*)pEvent;                                            
-(void)mouseEntered: (NSEvent*)pEvent;                                          
-(void)mouseExited: (NSEvent*)pEvent;                                           
-(void)rightMouseDown: (NSEvent*)pEvent;                                        
-(void)rightMouseDragged: (NSEvent*)pEvent;                                     
-(void)rightMouseUp: (NSEvent*)pEvent;                                          
-(void)otherMouseDown: (NSEvent*)pEvent;                                        
-(void)otherMouseDragged: (NSEvent*)pEvent;                                     
-(void)otherMouseUp: (NSEvent*)pEvent;                                          
-(void)scrollWheel: (NSEvent*)pEvent;                                           
-(void)keyDown: (NSEvent*)pEvent;                                               
-(void)keyUp: (NSEvent*)pEvent;                                                 
-(void)flagsChanged: (NSEvent*)pEvent;                                          
-(void)sendMouseEventToFrame:(NSEvent*)pEvent button:(USHORT)nButton eventtype:(USHORT)nEvent;
@end

salframe.cxx-1.50vs.1.50.4.1.html

Remove overlay Event Handler ( TODO : reimplement a new one, if needed )

Remove static void ImplSalCalcFullScreenSize() // Note: useless ?


Implemented AquaSalFrame::AquaSalFrame()

members removed : mpInst / mnWidthn mnWeight, mpSalInstance, maTsmDocumentId, mpMenu

Removed : CreateNewSystemWindow(), InstallAndRegisterAllEventHandler(), DeinstallAndUnregisterAllEventHandler(), GetOptimalWindowSize()


Added :

void AquaSalFrame::initWindowAndView(): helps to initialize mirroring parameters, calculates style mask, and initiamize the frame + delegates to mpWindow // FIXME: desccribe better delegates


void AquaSalFrame::CocoaToVCL( NSRect& io_rRect, bool bRelativeToScreen )

void AquaSalFrame::CocoaToVCL( NSPoint& io_rPoint, bool bRelativeToScreen )

-> translates Cocoa rectangle [resp.] point coordinates into VCL one the Cocoa rectangle [resp.] point depending the fact the rectangle [resp.] the point is relative to screen or not


void AquaSalFrame::VCLToCocoa( NSRect& io_rRect, bool bRelativeToScreen )

void AquaSalFrame::VCLToCocoa( NSPoint& io_rPoint, bool bRelativeToScreen )

-> translate VCL rectangle [resp.] point into Cocoa area [resp.] point depending the fact the rectangle [resp.] the point is relative to screen or not


Modified :

void AquaSalFrame::SetTitle(const XubString& rTitle)

-> replace Carbon things using Cocoa things

( CFStringRef -> NSStrings, and CreateCFString -> CreateNSString)

Removed : CarbonViewRef, and Carbon AquaSalGraphics object type, replaced by Cocoa equivalent.

Removed : Carbon Event Queue management, e.g. PostEventToQueue() .. and Co stuff // FIXME : how does it work now ?

Removed assertion about wrWindow

Removed CreateMenu(), SetRootMenu() ..etc // FIXME : manage menus a day


Added : manage top window in a group

-> orderFront (This action method moves the receiver to the front of its level in the screen list, without changing either the key window or the main window.)

-> makeKeyAndOrderFront() (This action method moves the receiver to the front of the screen list, within its level, and makes it the key window.)

Removed : HideWindow


Replaced Carbon methods with Cocoa one :

CGSize -> NSSize


Removed : SetWindowResizeLimits() , replaced by setMaxSize (ew code:[mpWindow setMaxSize: aSize]; )

Replaced Get/SetWindowBounds with setContentSize

Removed ZoomWindow, CollapseWindow ( use isZoomed / isMiniaturized instead )


Replaced Rect aRectState with NSRect aStateRect

To be fixed:

replace by Cocoa calls all SetSystemUIMode() calls ;

use Cocoa pointers instead of use SetThemeCursor(aPointer[ePointerStyle]);

use Cocoa functions in AquaSalFrame::SetPointerPos()

new implementation of Carbon (??) NewTSMDocument() // FIXME : not sure


Modified:

AquaSalFrame::Flush() -> Sync() replaces Flush()

Rect parentContentRect; -> NSRect aParentContentRect;

In AquaSalFrame::ShowFullScreen() , replaced Carbon stuff with frameRectForContentRect

Removed : AquaSalFrame::DrawMenuBar() // FIXME: implement Cocoa way

Modified AquaSalFrame::GetWorkArea() -> Rect are now NSRect

Implemented SalFrameWindow and SalFrameView using objective-C syntax + corresponding members (and associated types) -> see interface in salframe.hxx

salframe.cxx-1.50.4.1vs.1.50.4.2

in AquaSalFrame::ShowFullScreen() , if mbShown true, pass SALEVENT_MOVERESIZE at event kind, and NULL for the event to CallCallback(), whatever value bFullScreen has.


salframe.cxx-1.50vs.1.50.4.1

in AquaSalFrame::initWindowAndView(), add NSTitledWindowMask as mnStyleMask ( or'ed with existing flags)

salgdi.h-1.31vs.1.31.4.1

Removed Carbon refs: CarbonViewRef , CarbonWindowRef, IsScreenCompatible()

Modified: add Cocoa implementations of SetWindowGraphics() and UpdateWindow()

salgdiutils.cxx-1.10vs.1.10.4.1

New AquaSalGraphics::SetWindowGraphics() implementation. pFrame alone replaces mrView, mrWindow, mbScreen ( FIXME : needed in the future ? )

Modified AquaSalGraphics::CheckContext() and AquaSalGraphics::RefreshRect() implementation (): use mpFrame only )

In RefreshRect(), added a workaround for antialiased rendering. The area outside the rect is not refreshed and causes "lines" and alien around an area containing gradients e.g. Add + 2 to the REct size helps.

Partial Cocoa implementation of AquaSalGraphics::UpdateWindow() // FIXME : work completed ?

salinst.h-1.12vs.1.12.4.1

Modifications in class SalYieldMutex

New class AquaSalInstance: added structure SalUserEvent

Removed TimerEvenHandler(), replaced by handleAppDefinedEvent()

New methods: PostUserEvent, isNSAppThread(), CreateNSString()

TO BE CONTINUED

vcldemo

In aquavcl01 cws, the toy we used for experiences and debug was svdem. This time, a new one has been created. It's name is vcldemo.

The progressive changes implemented will be described in this part.

initial try

Draw antialiased lines + red rectangles when clicking somewhere with left mouse button

makefile.mk-1.19vs.1.19.4.1

Build vcldemo instead of svdem at build time.

vcldemo.cxx-1.3vs.1.3.4.1

Added : draw a simple string, using times fonts

Personal tools