Patch Launcher Reset to First Page

From WebOS Internals

Jump to: navigation, search


Contents

Introduction

By default, the Launcher maintains the last page opened when you return to it. If you most frequently use apps on the first page of the Launcher, you have to swipe back to the first page if the last app you launched was on another page. This patch resets the Launcher to the first page every time it opens. It also resets the scroll position of all pages, so that when you re-open the Launcher, all pages will be scrolled to the top (previously it only did this if the Reset Scroll Position patch was also installed, I abandoned that idea. Apologies if anyone really wants the reset page behaviour without the reset scroll feature - check out the page history for older versions or adjust the patch accordingly).

Editing Process

  • SSH in.
  • Remount the filesystem as read/write:
sudo rootfs_open -w
  • Load launcher-assistant.js in vi:
sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
  • Locate the beginning of the onDeactivate method around line 170:
	/* clean and hide global search */
	onDeactivate: function(event) {
 
		this.globalSearchAssistant.deactivate();
 
		this.reorderController.cancel();
 
		if (this.appDialog) {
			this.appDialog.mojo.close();
		}
 
		SystemManagerService.showQuickLaunch(true);
 
		delete this.launchRequest;
 
		this.removeLaunchFeedback();
	},
  • Add the following lines at the bottom of the onDeactivate method so that is now looks like this:
	/* clean and hide global search */
	onDeactivate: function(event) {
 
		this.globalSearchAssistant.deactivate();
 
		this.reorderController.cancel();
 
		if (this.appDialog) {
			this.appDialog.mojo.close();
		}
 
		SystemManagerService.showQuickLaunch(true);
 
		delete this.launchRequest;
 
		this.removeLaunchFeedback();
 
		/* Reset launcher to first page */
		$('launcher_root').mojo.setSnapIndex(0, false);
 
		/* Jump scroll position back to top for all pages */
		var numPages=this.pagesModel.getNumPages();
		for (var i=0; i<numPages; i++) {
			var scroller = this.getPageScroller(i);
			if (scroller && scroller.mojo) { scroller.mojo.revealTop(); }
		}
	},
  • Save the file and quit vi.
  • Remount the filesystem as read only - this should reboot your Pre:
sudo rootfs_open -w


Patch Process

The patch is not in the webos-internals gitorious repository yet, but is has been submitted. Until then, you can copy and paste the source below. Visit Applying Patches for info on how to use it. You can also apply it using webOS Quick Install. To apply the patch, follow the instructions above, and after remounting the filesystem as read/write, do the following:

  • Apply the patch (In this example, I have the patch file located in my home directory under patches):
cd /
sudo patch -p0 --backup-if-mismatch < ~/patches/reset-to-first-page.patch
This is what you should see if it ran properly:
patching file /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
  • Remount the filesystem as read only as described above.


Patch Source (reset-to-first-page.patch)

--- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.orig	Sat Dec  5 11:48:12 2009
+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js	Thu Dec  3 19:42:03 2009
@@ -183,6 +183,16 @@
 		delete this.launchRequest;
 
 		this.removeLaunchFeedback();
+	
+		
+		/* Reset launcher to first page */
+		$('launcher_root').mojo.setSnapIndex(0, false);
+		
+		/* Jump scroll position back to top for all pages */
+		var numPages=this.pagesModel.getNumPages();
+		for (var i=0; i<numPages; i++) {
+			var scroller = this.getPageScroller(i);
+			if (scroller && scroller.mojo) { scroller.mojo.revealTop(); }
+		}
 	},
 
 	onResize: function(event) {

Support

The discussion thread at the PreCentral.net forums is the best place to ask any questions.

Personal tools
Google AdSense