mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
MacPDF: Add some temporary logging for application restoring
In the end, apparently I had "Close windows when quitting an application" enabled in Desktop & Dock in System Settings. With that turned off, it just worked (...but I still need to serialize the current page in the view). Even with it turned off, cmd-opt-q would "Quit and Keep Windows", so I could've also used that for testing.
This commit is contained in:
parent
751ed5e1ee
commit
d3e8d87672
2 changed files with 38 additions and 0 deletions
|
@ -46,11 +46,38 @@
|
||||||
- (void)windowControllerDidLoadNib:(NSWindowController*)aController
|
- (void)windowControllerDidLoadNib:(NSWindowController*)aController
|
||||||
{
|
{
|
||||||
[super windowControllerDidLoadNib:aController];
|
[super windowControllerDidLoadNib:aController];
|
||||||
|
|
||||||
|
NSLog(@"restorationClass %@", aController.window.restorationClass);
|
||||||
|
NSLog(@"restorable %@", @(aController.window.restorable));
|
||||||
|
NSLog(@"identifier %@", aController.window.identifier);
|
||||||
|
|
||||||
if (_doc) {
|
if (_doc) {
|
||||||
[_pdfView setDocument:_doc->make_weak_ptr()];
|
[_pdfView setDocument:_doc->make_weak_ptr()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSArray<Class>*)allowedClassesForRestorableStateKeyPath:(NSString*)keyPath
|
||||||
|
{
|
||||||
|
auto res = [NSDocument allowedClassesForRestorableStateKeyPath:keyPath];
|
||||||
|
NSLog(@"restore %@", res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)restoreDocumentWindowWithIdentifier:(NSUserInterfaceItemIdentifier)identifier
|
||||||
|
state:(NSCoder*)state
|
||||||
|
completionHandler:(void (^)(NSWindow*, NSError*))completionHandler
|
||||||
|
{
|
||||||
|
NSLog(@"here restoreDocumentWindowWithIdentifier");
|
||||||
|
return [super restoreDocumentWindowWithIdentifier:identifier state:state completionHandler:completionHandler];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)encodeRestorableStateWithCoder:(NSCoder*)coder
|
||||||
|
{
|
||||||
|
// called on switch away from app
|
||||||
|
NSLog(@"here encodeRestorableStateWithCoder");
|
||||||
|
[super encodeRestorableStateWithCoder:coder];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSData*)dataOfType:(NSString*)typeName error:(NSError**)outError
|
- (NSData*)dataOfType:(NSString*)typeName error:(NSError**)outError
|
||||||
{
|
{
|
||||||
// Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error if you return nil.
|
// Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error if you return nil.
|
||||||
|
|
|
@ -73,6 +73,7 @@ static NSBitmapImageRep* ns_from_gfx(NonnullRefPtr<Gfx::Bitmap> bitmap_p)
|
||||||
{
|
{
|
||||||
if (!_doc || _doc->get_page_count() == 0)
|
if (!_doc || _doc->get_page_count() == 0)
|
||||||
return;
|
return;
|
||||||
|
[self invalidateRestorableState];
|
||||||
NSSize pixel_size = [self convertSizeToBacking:self.bounds.size];
|
NSSize pixel_size = [self convertSizeToBacking:self.bounds.size];
|
||||||
if (auto bitmap_or = render(*_doc, _page_index, pixel_size); !bitmap_or.is_error())
|
if (auto bitmap_or = render(*_doc, _page_index, pixel_size); !bitmap_or.is_error())
|
||||||
_rep = ns_from_gfx(bitmap_or.value());
|
_rep = ns_from_gfx(bitmap_or.value());
|
||||||
|
@ -112,4 +113,14 @@ static NSBitmapImageRep* ns_from_gfx(NonnullRefPtr<Gfx::Bitmap> bitmap_p)
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)encodeRestorableStateWithCoder:(NSCoder*)coder
|
||||||
|
{
|
||||||
|
NSLog(@"FIXME encodeRestorableStateWithCoder");
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)restoreStateWithCoder:(NSCoder*)coder
|
||||||
|
{
|
||||||
|
NSLog(@"FIXME restoreStateWithCoder");
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue