The Inbox: Morphic-ct.1716.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Morphic-ct.1716.mcz

commits-2
Christoph Thiede uploaded a new version of Morphic to project The Inbox:
http://source.squeak.org/inbox/Morphic-ct.1716.mcz

==================== Summary ====================

Name: Morphic-ct.1716
Author: ct
Time: 6 December 2020, 6:03:02.43962 pm
UUID: b5046c96-a83e-2543-b9e2-4b56a3e99a1a
Ancestors: Morphic-mt.1713

Re-enables handling of #launchDrop events when the VM is configured as a singleton and has been invoked again, though currently only handled with a rudimentary fallback implementation.

See http://forum.world.st/Changeset-Enhanced-integration-of-drag-n-drop-from-host-tp5123857p5124332.html. Thanks to Jakob (jr) for the feedback!

Reuploaded as replacement for Morphic-ct.1715. Thanks also to Marcel for the feedback! :-)

=============== Diff against Morphic-mt.1713 ===============

Item was changed:
  ----- Method: HandMorph>>generateDropFilesEvent: (in category 'private events') -----
  generateDropFilesEvent: evtBuf
  "Generate the appropriate mouse event for the given raw event buffer."
 
  | position buttons modifiers stamp numFiles dragType |
  stamp := evtBuf second.
  stamp = 0 ifTrue: [stamp := Time eventMillisecondClock].
  dragType := evtBuf third.
  position := evtBuf fourth @ evtBuf fifth.
  buttons := MouseEvent redButton. "hacked because necessary for correct mouseMoveDragging handling"
  modifiers := evtBuf sixth.
  buttons := buttons bitOr: (modifiers bitShift: 3).
  numFiles := evtBuf seventh.
 
  dragType caseOf: {
  [1] -> [ "dragEnter"
  externalDropMorph := TransferMorph new
  dragTransferType: #filesAndDirectories;
  source: self;
  passenger: (numFiles = 0 "Usually, numFiles and drop paths are delivered on dragDrop only. Still reserving this possibility for able host implementations."
  ifTrue: [self flag: #vmCapabilityMissing. 'Unknown host content' translated]
  ifFalse: [self collectDropFilesAndDirectories: numFiles]);
  yourself.
 
  "During the drag operation, the host system is responsible for displaying the cursor."
  self grabMorph: externalDropMorph.
  self showTemporaryCursor: Cursor blank.
  externalDropMorph bottomRight: self topLeft. "Southeast area of the cursor is blocked by drawings from the source application. Display our drop morph at the opposite corner of the cursor." ].
  [2] -> [ "dragMove"
  ^ MouseMoveEvent new
  setType: #mouseMove
  startPoint: self position
  endPoint: position
  trail: "{self position. position}"(self mouseDragTrailFrom: evtBuf)
  buttons: buttons
  hand: self
  stamp: stamp ].
  [3]  -> [ "dragLeave"
  externalDropMorph ifNotNil: #abandon.
  externalDropMorph := nil.
  self showTemporaryCursor: nil ].
  [4] -> [ "dragDrop"
+ | oldButtons event |
+ oldButtons := lastEventBuffer fifth
+ bitOr: (lastEventBuffer sixth bitShift: 3).
+ event := MouseButtonEvent new
+ setType: #mouseUp
+ position: position
+ which: (oldButtons bitXor: buttons)
+ buttons: buttons
+ nClicks: 0
+ hand: self
+ stamp: stamp.
+
- | oldButtons |
  externalDropMorph ifNil: [
+ "dragDrop has been sent without prior dragging. This happens when the VM is configured as singleton application and has been invoked again with a new image file (aka #launchDrop, runAsSingleInstance on Unix, or RunSingleApp on Windows)."
+ self flag: #forLater. "ct: When we decouple event generation from Morphic, we will probably need to introduce a separate SystemLaunchEvent class for this event. See http://forum.world.st/Changeset-Enhanced-integration-of-drag-n-drop-from-host-tp5123857p5124332.html."
+ Project current
+ launchSystemFiles: (self collectDropFilesAndDirectories: numFiles)
+ event: event.
+ ^ nil].
- "dragDrop has been sent without prior dragging. This happens when the VM is configured as singleton application and has been called again (aka #launchDrop)."
- ^ self error: 'Launch drop for singleton Squeak not yet implemented.'].
 
  self showTemporaryCursor: nil.
  externalDropMorph passenger isString ifTrue: [
  self flag: #vmCapabilityMissing. "See above."
  externalDropMorph passenger: (self collectDropFilesAndDirectories: numFiles)].
  externalDropMorph := nil.
 
  (Smalltalk classNamed: #DropFilesEvent) ifNotNil: [:eventClass |
  | classicEvent |
  "Generate classic DropFilesEvent, providing backward compatibility."
  classicEvent := eventClass new
  setPosition: position
  contents: numFiles
  hand: self.
  self processEvent: classicEvent.
  classicEvent wasHandled ifTrue: [^ nil]].
 
+ ^ event ].
- oldButtons := lastEventBuffer fifth
- bitOr: (lastEventBuffer sixth bitShift: 3).
- ^ MouseButtonEvent new
- setType: #mouseUp
- position: position
- which: (oldButtons bitXor: buttons)
- buttons: buttons
- nClicks: 0
- hand: self
- stamp: stamp ].
  [5] -> [ "drag request"
  "For dnd out. Not properly implemented at the moment."
  self shouldBeImplemented] }.
  ^ nil!

Item was added:
+ ----- Method: MorphicProject>>launchSystemFiles:event: (in category 'utilities') -----
+ launchSystemFiles: fileStreams event: genericMorphicEvent
+ "Handle a number of files the singleton VM was invoked with again."
+
+ self flag: #todo. "Do something more useful with the image here, e. g. tell the VM to load it."
+ self inform: ('Cannot start a second instance of Squeak\with the image "{1}"\because the VM is configured as singleton application.' withCRs translated format: {fileStreams first localName}).!