Permalink
Browse files

cleaned up for merge

  • Loading branch information...
1 parent 3d72dcc commit 89d1f8d10dc51f0d4e4c2aa24682a2e09b5ace4e @monkeyiq monkeyiq committed Apr 6, 2013
View
@@ -301,10 +301,18 @@ extern void SCCopyLookupData(SplineChar *sc);
extern void PasteRemoveSFAnchors(SplineFont *);
extern void PasteAnchorClassMerge(SplineFont *sf,AnchorClass *into,AnchorClass *from);
extern void PasteRemoveAnchorClass(SplineFont *sf,AnchorClass *dying);
+
/**
- * Convert the undo into a string. You must free() the returned string.
+ * Serialize and undo into a string.
+ * You must free() the returned string.
*/
extern char* UndoToString( SplineChar* sc, Undoes *undo );
+
+/**
+ * Dump a list of undos for a splinechar starting at the given 'undo'.
+ * msg is used as a header message so that a dump at a particular time stands
+ * out from one that occurs later in the code.
+ */
extern void dumpUndoChain( char* msg, SplineChar* sc, Undoes *undo );
extern void ClipboardClear(void);
View
@@ -4030,6 +4030,9 @@ return;
if( lastSel.lastselpt != fs.p->sp
|| lastSel.lastselcp != fs.p->spiro )
{
+ // If we are in a collab session, we might like to preserve here
+ // so that we can send a change of selected points to other members
+ // of the group
if( collabclient_inSession( cv ) )
{
CVPreserveState(&cv->b);
@@ -6893,24 +6896,24 @@ static void CVUndo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e))
Undoes *undo = cv->b.layerheads[cv->b.drawmode]->undoes;
- printf("CVUndo() undo:%p u->next:%p\n", undo, ( undo ? undo->next : 0 ) );
+// printf("CVUndo() undo:%p u->next:%p\n", undo, ( undo ? undo->next : 0 ) );
if( undo )
{
- printf("undo:\n%s\n", UndoToString( cv->b.sc, undo ) );
- {
- int len = 0;
- Undoes *p = undo;
- for( ; p; p = p->next )
- len++;
- printf("u.len:%d\n", len );
- }
- {
- int len = 0;
- Undoes *p = cv->b.layerheads[cv->b.drawmode]->redoes;
- for( ; p; p = p->next )
- len++;
- printf("r.len:%d\n", len );
- }
+ /* printf("undo:\n%s\n", UndoToString( cv->b.sc, undo ) ); */
+ /* { */
+ /* int len = 0; */
+ /* Undoes *p = undo; */
+ /* for( ; p; p = p->next ) */
+ /* len++; */
+ /* printf("u.len:%d\n", len ); */
+ /* } */
+ /* { */
+ /* int len = 0; */
+ /* Undoes *p = cv->b.layerheads[cv->b.drawmode]->redoes; */
+ /* for( ; p; p = p->next ) */
+ /* len++; */
+ /* printf("r.len:%d\n", len ); */
+ /* } */
if( collabclient_inSession( cv ) )
{
@@ -8089,8 +8092,6 @@ static void transfunc(void *d,real transform[6],int otype,BVTFunc *bvts,
CharView *cv = (CharView *) d;
int anya, l, cvlayer = CVLayer((CharViewBase *) cv);
- printf("transfunc() cv:%p\n", cv );
-
if ( cv->b.layerheads[cv->b.drawmode]->undoes!=NULL &&
cv->b.layerheads[cv->b.drawmode]->undoes->undotype==ut_tstate )
CVDoUndo(&cv->b);
View
@@ -59,6 +59,10 @@ int pref_collab_roundTripTimerMS = 2000;
#define MSG_TYPE_SFD "msg_type_sfd"
#define MSG_TYPE_UNDO "msg_type_undo"
+//
+// Set to true if you want to see the raw SFD undo fragments which
+// are moving to/from the server.
+//
#define DEBUG_SHOW_SFD_CHUNKS 0
@@ -709,6 +713,9 @@ FontViewBase* collabclient_sessionJoin( void* ccvp, FontView *fv )
cc->sequence = 0;
zstr_sendm (cc->snapshot, "ICANHAZ?");
zstr_send (cc->snapshot, SUBTREE);
+
+ // if we wait for timeoutMS millisec then we assume failure
+ // timeWaitedMS is used to keep track of how long we have waited
kvmsg_t* lastSFD = 0;
int timeWaitedMS = 0;
int timeoutMS = pref_collab_sessionJoinTimeoutMS;
View
@@ -210,6 +210,12 @@ extern void collabclient_closeLocalServer( FontViewBase* fv );
extern void collabclient_setGeneratingUndoForWire( int v );
+/**
+ * Every message send from the server has a monotonically increasing
+ * SequenceNumber. This function gets what that value is right now and
+ * can be used to check if any messages have been received from the
+ * server by calling again and comparing the return value.
+ */
extern int64_t collabclient_getCurrentSequenceNumber(void* ccvp);
#endif
View
@@ -980,6 +980,10 @@ static real GGadgetToReal(GGadget *g)
return val;
}
+/**
+ * If we are in a collab session then send the redo through to the
+ * server to update other clients to our state.
+ */
static void MV_handle_collabclient_sendRedo( MetricsView *mv, SplineChar *sc )
{
if( collabclient_inSessionFV( mv->fv ) )
@@ -1012,7 +1016,7 @@ return( true );
if (!isValidInt(end))
GDrawBeep(NULL);
else if ( !mv->vertical && val!=sc->width ) {
- dumpUndoChain( "before SCPreserveWidth...", sc, &sc->layers[ly_fore].undoes );
+// dumpUndoChain( "before SCPreserveWidth...", sc, &sc->layers[ly_fore].undoes );
SCPreserveWidth(sc);
if( collabclient_inSessionFV( mv->fv ) )
{
@@ -1080,16 +1084,19 @@ return( true );
if (!isValidInt(end))
GDrawBeep(NULL);
else if ( !mv->vertical && val!=bb.minx ) {
- int dohints = 0;
- SCPreserveState( sc, dohints );
+ if( collabclient_inSessionFV( mv->fv ) )
+ {
+ int dohints = 0;
+ SCPreserveState( sc, dohints );
+ }
real transform[6];
transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[5] = 0;
transform[4] = val-bb.minx;
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0 | fvt_alllayers );
- dumpUndoChain( "LBearing Changed...e", sc, &sc->layers[ly_fore].undoes );
+// dumpUndoChain( "LBearing Changed...e", sc, &sc->layers[ly_fore].undoes );
MV_handle_collabclient_sendRedo( mv, sc );
} else if ( mv->vertical && val!=sc->parent->ascent-bb.maxy ) {
@@ -1135,21 +1142,22 @@ return( true );
/* Width is an integer. Adjust the lbearing so that the rbearing */
/* remains what was just typed in */
if ( newwidth!=bb.maxx+val ) {
- int dohints = 0;
- SCPreserveState( sc, dohints );
+ if( collabclient_inSessionFV( mv->fv ) )
+ {
+ int dohints = 0;
+ SCPreserveState( sc, dohints );
+ }
- printf("RBearing Changed... transform!\n");
real transform[6];
transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[5] = 0;
transform[4] = newwidth-val-bb.maxx;
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth);
}
- dumpUndoChain( "RBearing Changed...2", sc, &sc->layers[ly_fore].undoes );
SCSynchronizeWidth(sc,newwidth,sc->width,NULL);
- dumpUndoChain( "RBearing Changed...3", sc, &sc->layers[ly_fore].undoes );
SCCharChangedUpdate(sc,ly_none);
- dumpUndoChain( "RBearing Changed...e", sc, &sc->layers[ly_fore].undoes );
+
+// dumpUndoChain( "RBearing Changed...2", sc, &sc->layers[ly_fore].undoes );
MV_handle_collabclient_sendRedo( mv, sc );
} else if ( mv->vertical && val!=sc->vwidth-(sc->parent->ascent-bb.miny) ) {
double vw = val+(sc->parent->ascent-bb.miny);
@@ -1201,23 +1209,6 @@ static int MV_ChangeKerning(MetricsView *mv, int which, int offset, int is_diff)
kc = mv->glyphs[which-1].kc;
index = mv->glyphs[which-1].kc_index;
- printf("MV_ChangeKerning(top)\n");
- printf("MV_ChangeKerning() kp:%p\n", kp );
- printf("MV_ChangeKerning() kc:%p\n", kc );
- // FIXME: MIQ:
- {
- SplineFont *sf = mv->sf;
- int lookup_type = gpos_pair;
- char* str = SFDCreateUndoForLookup( sf, lookup_type );
- GFileWriteAll( "/tmp/mv-old-lookup-table.sfd", str );
- printf("MV_ChangeKerning() sf->kerns:%p\n", sf->kerns );
- if( sf->kerns )
- {
- printf("MV_ChangeKerning() first_cnt:%d\n", sf->kerns->first_cnt );
- printf("MV_ChangeKerning() second_cnt:%d\n", sf->kerns->second_cnt );
- }
- }
-
if ( kc!=NULL ) {
if ( index==-1 )
kc = NULL;
@@ -4555,8 +4546,13 @@ return;
}
mv->pressed_x = event->u.mouse.x;
} else if ( event->type == et_mousemove && mv->pressed ) {
- printf("move & pressed pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly));
- for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i );
+// printf("move & pressed pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly));
+
+ for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i )
+ {
+ // nothing
+ }
+
if ( mv->pressedwidth ) {
int ow = mv->perchar[i].dwidth;
if ( mv->right_to_left ) diff = -diff;
@@ -4607,9 +4603,11 @@ return;
if ( mv->showgrid==mv_hidemovinggrid )
GDrawRequestExpose(mv->v,NULL,false);
} else if ( event->type == et_mouseup && mv->pressed ) {
- printf("mouse up!\n");
- printf("pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly));
- for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i );
+ for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i )
+ {
+ // nothing
+ }
+
mv->pressed = false;
mv->activeoff = 0;
sc = mv->glyphs[i].sc;
@@ -4622,7 +4620,6 @@ return;
SCSynchronizeWidth(sc,sc->width+diff,sc->width,NULL);
SCCharChangedUpdate(sc,ly_none);
MV_handle_collabclient_sendRedo( mv, sc );
- // FIXME: MIQ: collab send redo call
}
} else if ( mv->pressedkern ) {
mv->pressedkern = false;
View
@@ -890,6 +890,11 @@ extern void PI_ShowHints(SplineChar *sc, GGadget *list, int set);
extern GTextInfo *SCHintList(SplineChar *sc,HintMask *);
extern void CVResize(CharView *cv );
extern CharView *CharViewCreate(SplineChar *sc,FontView *fv,int enc);
+
+/**
+ * Extended version of CharViewCreate() which allows a window to be created but
+ * not displayed.
+ */
extern CharView *CharViewCreateExtended(SplineChar *sc, FontView *fv,int enc, int show );
extern void CharViewFree(CharView *cv);
extern int CVValid(SplineFont *sf, SplineChar *sc, CharView *cv);
Oops, something went wrong.

0 comments on commit 89d1f8d

Please sign in to comment.