Patch Launcher Reset Scroll on Page Change

From WebOS Internals
Revision as of 22:52, 21 August 2009 by Bsiegel (talk | contribs) (Initial commit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


Introduction

If you have many apps on a page, you may have to scroll to see some of those. The launcher maintains the scroll state (the amount you have scrolled) on each page, which means when you return to a page, you are still at the location that you last scrolled to. This can be annoying. For example, it can make it difficult to train your muscle memory because, when repeating the same steps, the app you want is not always at the same location on the screen. This patch resets the scroll of each page back to the top when it goes out of view.

Editing Process

  • SSH in.
  • Remount the filesystem as read/write:

<source lang="bash">

sudo rootfs_open -w

</source>

  • Load launcher-assistant.js in vi:

<source lang="bash">

sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js

</source>

  • Locate the onPageChange method around line 157:

<source lang="javascript">

onPageChange: function(event) { this.activePageIndex = event.value; this.updatePageIndicators(); },

</source>

  • Add the four lines below so that onPageChange now looks like the following:

<source lang="javascript">

onPageChange: function(event) { var scroller = this.getPageScroller(); if (scroller && scroller.mojo) { scroller.mojo.revealTop(0); } this.activePageIndex = event.value; this.updatePageIndicators(); },

</source>

  • Save the file and quit vi.
  • Remount the filesystem as read only - this should reboot your Pre:

<source lang="bash">

sudo rootfs_open -w

</source>


Patch Process

The patch should soon be located in the webos-internals gitorious repository. Until then, you can copy and paste the source below. Visit Applying Patches for info on how to use it. 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):

<source lang="bash">

cd / sudo patch -p0 --backup-if-mismatch < ~/patches/reset-scroll.patch

</source>

This is what you should see if it ran properly: <source lang="text"> patching file /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js

</source>

  • Remount the filesystem as read only as described above.


Patch Source (reset-scroll.patch)

<source lang="diff"> --- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.bak 2009-05-22 17:12:34.000000000 -0400 +++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js 2009-08-21 17:19:48.426297000 -0400 @@ -155,6 +155,10 @@

	/* keep track of which page we are on */
	onPageChange: function(event) {

+ var scroller = this.getPageScroller(); + if (scroller && scroller.mojo) { + scroller.mojo.revealTop(0); + }

		this.activePageIndex = event.value;
		this.updatePageIndicators();
	},

</source>