Date: | 2013-08-16 10:41:16 (10 years 7 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 965340a39c12cd62b3485b4a97c30984c62f6aaf |
Message: | Fixed bug with launch screen and double buffering LinkApp::drawRun() assumes the layers below are already painted when it is called, but this was not the case. With single buffering, the previous frame was still there so it still looked good, but with double buffering the buffer typically contains an outdated screen. Long term I think the launch should happen at the outermost scope, so all destructors get a chance to run. This commit is a small step in that direction, by exiting the main loop before launching. |
Files: |
src/gmenu2x.cpp (5 diffs) src/gmenu2x.h (3 diffs) src/linkapp.cpp (2 diffs) src/linkapp.h (3 diffs) |
Change Details
src/gmenu2x.cpp | ||
---|---|---|
194 | 194 | #endif |
195 | 195 | |
196 | 196 | GMenu2X::GMenu2X() |
197 | : appToLaunch(nullptr) | |
197 | 198 | { |
198 | 199 | usbnet = samba = inet = web = false; |
199 | 200 | useSelectionPng = false; |
... | ... | |
589 | 590 | if (!fileExists(CARD_ROOT)) |
590 | 591 | CARD_ROOT = ""; |
591 | 592 | |
592 | bool quit = false; | |
593 | while (!quit) { | |
593 | appToLaunch = nullptr; | |
594 | ||
595 | while (true) { | |
594 | 596 | // Remove dismissed layers from the stack. |
595 | 597 | for (auto it = layers.begin(); it != layers.end(); ) { |
596 | 598 | if ((*it)->getStatus() == Layer::Status::DISMISSED) { |
... | ... | |
610 | 612 | for (auto layer : layers) { |
611 | 613 | layer->paint(*s); |
612 | 614 | } |
615 | if (appToLaunch) { | |
616 | break; | |
617 | } | |
613 | 618 | s->flip(); |
614 | 619 | |
615 | 620 | // Handle touchscreen events. |
... | ... | |
639 | 644 | } |
640 | 645 | } |
641 | 646 | } |
647 | ||
648 | if (appToLaunch) { | |
649 | appToLaunch->drawRun(); | |
650 | appToLaunch->launch(fileToLaunch); | |
651 | } | |
642 | 652 | } |
643 | 653 | |
644 | 654 | void GMenu2X::explorer() { |
... | ... | |
662 | 672 | } |
663 | 673 | } |
664 | 674 | |
675 | void GMenu2X::queueLaunch(LinkApp *app, const std::string &file) { | |
676 | appToLaunch = app; | |
677 | fileToLaunch = file; | |
678 | } | |
679 | ||
665 | 680 | void GMenu2X::showHelpPopup() { |
666 | 681 | layers.push_back(make_shared<HelpPopup>(*this)); |
667 | 682 | } |
src/gmenu2x.h | ||
---|---|---|
39 | 39 | class HelpPopup; |
40 | 40 | class IconButton; |
41 | 41 | class Layer; |
42 | class LinkApp; | |
42 | 43 | class MediaMonitor; |
43 | 44 | class Menu; |
44 | 45 | class Surface; |
... | ... | |
72 | 73 | std::shared_ptr<Menu> menu; |
73 | 74 | MediaMonitor *monitor; |
74 | 75 | |
76 | LinkApp *appToLaunch; | |
77 | std::string fileToLaunch; | |
78 | ||
75 | 79 | std::vector<std::shared_ptr<Layer>> layers; |
76 | 80 | |
77 | 81 | /*! |
... | ... | |
184 | 188 | |
185 | 189 | void setInputSpeed(); |
186 | 190 | |
191 | /** | |
192 | * Requests that the given application be launched. | |
193 | * The launch won't happen immediately; it will happen after control | |
194 | * returns to the main loop. | |
195 | */ | |
196 | void queueLaunch(LinkApp *app, const std::string &file); | |
187 | 197 | void saveSelection(); |
188 | 198 | void writeConfig(); |
189 | 199 | void writeSkinConfig(); |
src/linkapp.cpp | ||
---|---|---|
372 | 372 | if (!selectordir.empty()) |
373 | 373 | selector(); |
374 | 374 | else |
375 | launch(); | |
375 | gmenu2x->queueLaunch(this, ""); | |
376 | 376 | } |
377 | 377 | |
378 | 378 | void LinkApp::showManual() { |
... | ... | |
547 | 547 | selectordir = selectedDir; |
548 | 548 | } |
549 | 549 | gmenu2x->writeTmp(selection, selectedDir); |
550 | launch(selectedDir + sel.getFile()); | |
550 | gmenu2x->queueLaunch(this, selectedDir + sel.getFile()); | |
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
554 | 554 | void LinkApp::launch(const string &selectedFile) { |
555 | drawRun(); | |
556 | ||
557 | 555 | save(); |
558 | 556 | |
559 | 557 | if (isOpk()) { |
src/linkapp.h | ||
---|---|---|
41 | 41 | int iclock; |
42 | 42 | std::string exec, params, workdir, manual, selectordir, selectorfilter, selectorscreens; |
43 | 43 | bool selectorbrowser, editable; |
44 | void drawRun(); | |
45 | 44 | |
46 | 45 | std::string aliasfile; |
47 | 46 | std::string file; |
... | ... | |
53 | 52 | #endif |
54 | 53 | |
55 | 54 | void start(); |
56 | void launch(const std::string &selectedFile = ""); | |
57 | 55 | |
58 | 56 | protected: |
59 | 57 | virtual const std::string &searchIcon(); |
... | ... | |
107 | 105 | |
108 | 106 | const std::string &getFile() { return file; } |
109 | 107 | void renameFile(const std::string &name); |
108 | ||
109 | void drawRun(); | |
110 | void launch(const std::string &selectedFile); | |
110 | 111 | }; |
111 | 112 | |
112 | 113 | #endif |
Branches:
install_locations
master
opkrun
packages