Difference between revisions of "Patch Launcher Reset to First Page"

From WebOS Internals
Jump to: navigation, search
(Copied from Patch Launcher Reset Scroll on Page Change and edited accordingly.)
 
m (Updated patch, no real functional change but now it works like the reset to middle page patch.)
Line 17: Line 17:
 
sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
 
sudo vi /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js
 
</source></blockquote>
 
</source></blockquote>
* Locate the text 'this.removeLaunchFeedback();' in the onDeactivate method around line 185 (onDeactivate begins at line 171 in webOS 1.3.1, 'this.removeLaunchFeedback();' is the last line of that method):
+
* Locate the 'Mojo.listen' handlers in the setup method around line 70 (setup begins at line 67 in webOS 1.3.1):
 +
<blockquote><source lang="javascript">
 +
setup: function() {
 +
 +
Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this));
 +
Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));
 +
</source></blockquote>
 +
* Insert a new listener in between the existing two so that it now looks like this:
 +
<blockquote><source lang="javascript">
 +
setup: function() {
 +
 +
Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this));
 +
Mojo.listen(this.controller.document, Mojo.Event.activate, this.onActivate.bindAsEventListener(this));
 +
Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));
 +
</source></blockquote>
 +
* Locate the beginning of the onDeactivate method around line 170 (onDeactivate begins at line 171 in webOS 1.3.1):
 
<blockquote><source lang="javascript">
 
<blockquote><source lang="javascript">
 
/* clean and hide global search */
 
/* clean and hide global search */
 
onDeactivate: function(event) {
 
onDeactivate: function(event) {
 
this.globalSearchAssistant.deactivate();
 
 
this.reorderController.cancel();
 
 
if (this.appDialog) {
 
this.appDialog.mojo.close();
 
}
 
 
SystemManagerService.showQuickLaunch(true);
 
 
delete this.launchRequest;
 
 
this.removeLaunchFeedback();
 
},
 
 
</source></blockquote>
 
</source></blockquote>
* Add the following lines below so that onDeactivate now looks like this:
+
* Add the following lines before onDeactivate so that is now looks like this:
 
<blockquote><source lang="javascript">
 
<blockquote><source lang="javascript">
/* clean and hide global search */
+
/* set launcher page to override last used page */
onDeactivate: function(event) {
+
onActivate: function(event) {
+
// set launcher to first page
this.globalSearchAssistant.deactivate();
+
$('launcher_root').mojo.setSnapIndex(0, false);
 
this.reorderController.cancel();
 
 
 
if (this.appDialog) {
+
/**  
this.appDialog.mojo.close();
 
}
 
 
SystemManagerService.showQuickLaunch(true);
 
 
delete this.launchRequest;
 
 
this.removeLaunchFeedback();
 
 
/* Reset launcher to first page for next time */
 
$('launcher_root').mojo.setSnapIndex(0, true);
 
 
/*  
 
 
* If Bsiegel's 'Reset Scroll Position' patch is installed
 
* If Bsiegel's 'Reset Scroll Position' patch is installed
* then this does what it says on the tin for the first page.
+
* then this does what it says on the tin for the middle page.
 
*/
 
*/
event.value = 0; /* fudge this because onPageChange expects a
+
event.value = 0; /* Fudge this because onPageChange expects a
  * mojo-property-change event but it's actually
+
* mojo-property-change event but it's actually
  * getting mojo-event-deactivate.
+
* getting mojo-event-deactivate.
  */
+
*/
 
this.onPageChange(event);
 
this.onPageChange(event);
 
 
},
 
},
 +
 +
/* clean and hide global search */
 +
onDeactivate: function(event) {
 
</source></blockquote>
 
</source></blockquote>
 
* Save the file and quit vi.
 
* Save the file and quit vi.
Line 80: Line 67:
 
==Patch Process==
 
==Patch Process==
  
The patch is not in the webos-internals gitorious repository - if anybody can help with uploading that, it would be much appreciated (it's my first patch!). 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:
+
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'''):
 
* Apply the patch (In this example, I have the patch file located in my home directory under '''patches'''):
Line 98: Line 85:
  
 
<source lang="diff">
 
<source lang="diff">
--- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.webosinternals.orig Fri Nov 27 08:29:40 2009
+
--- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.webosinternals.orig Sat Nov 28 01:54:57 2009
+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Fri Nov 27 08:31:23 2009
+
+++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Mon Nov 30 03:15:43 2009
@@ -183,6 +183,20 @@
+
@@ -67,6 +67,7 @@
delete this.launchRequest;
+
setup: function() {
 
 
 
 
  this.removeLaunchFeedback();
+
  Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this));
 +
+ Mojo.listen(this.controller.document, Mojo.Event.activate, this.onActivate.bindAsEventListener(this));
 +
Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));
 +
 +
this.pagesModel = new LauncherPages({
 +
@@ -167,6 +168,22 @@
 +
this.updatePageIndicators();
 +
},
 +
 +
+ /* set launcher page to override last used page */
 +
+ onActivate: function(event) {
 +
+ // set launcher to first page
 +
+ $('launcher_root').mojo.setSnapIndex(0, false);
 
+
 
+
+ /* Reset launcher to first page for next time */
+
+ /**  
+ $('launcher_root').mojo.setSnapIndex(0, true);
 
+
 
+ /*  
 
 
+ * If Bsiegel's 'Reset Scroll Position' patch is installed
 
+ * If Bsiegel's 'Reset Scroll Position' patch is installed
+ * then this does what it says on the tin for the first page.
+
+ * then this does what it says on the tin for the middle page.
 
+ */
 
+ */
+ event.value = 0; /* fudge this because onPageChange expects a
+
+ event.value = 0; /* Fudge this because onPageChange expects a
+   * mojo-property-change event but it's actually
+
+ * mojo-property-change event but it's actually
+   * getting mojo-event-deactivate.
+
+ * getting mojo-event-deactivate.
+   */
+
+ */
 
+ this.onPageChange(event);
 
+ this.onPageChange(event);
+
+
+ },
},
+
+
 
+
  /* clean and hide global search */
  onResize: function(event) {
+
  onDeactivate: function(event) {
 
</source>
 
</source>

Revision as of 04:30, 30 November 2009

<<- Return to webOS Patches


Introduction

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's closed (in readiness for when it's next opened). This works best in combination with the Patch Launcher Reset Scroll on Page Change patch to ensure the page is also always scrolled to the top.

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 'Mojo.listen' handlers in the setup method around line 70 (setup begins at line 67 in webOS 1.3.1):
<source lang="javascript">

setup: function() {

Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this)); Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));

</source>
  • Insert a new listener in between the existing two so that it now looks like this:
<source lang="javascript">

setup: function() {

Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this)); Mojo.listen(this.controller.document, Mojo.Event.activate, this.onActivate.bindAsEventListener(this)); Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));

</source>
  • Locate the beginning of the onDeactivate method around line 170 (onDeactivate begins at line 171 in webOS 1.3.1):
<source lang="javascript">

/* clean and hide global search */ onDeactivate: function(event) {

</source>
  • Add the following lines before onDeactivate so that is now looks like this:
<source lang="javascript">

/* set launcher page to override last used page */ onActivate: function(event) { // set launcher to first page $('launcher_root').mojo.setSnapIndex(0, false);

/** * If Bsiegel's 'Reset Scroll Position' patch is installed * then this does what it says on the tin for the middle page. */ event.value = 0; /* Fudge this because onPageChange expects a * mojo-property-change event but it's actually * getting mojo-event-deactivate. */ this.onPageChange(event); },

/* clean and hide global search */ onDeactivate: function(event) {

</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 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):
<source lang="bash">

cd / sudo patch -p0 --backup-if-mismatch < ~/patches/reset-to-first-page.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-to-first-page.patch)

<source lang="diff"> --- /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js.webosinternals.orig Sat Nov 28 01:54:57 2009 +++ /usr/lib/luna/system/luna-applauncher/app/controllers/launcher-assistant.js Mon Nov 30 03:15:43 2009 @@ -67,6 +67,7 @@

	setup: function() {
		
		Mojo.listen(this.controller.document, Mojo.Event.deactivate, this.onDeactivate.bindAsEventListener(this));

+ Mojo.listen(this.controller.document, Mojo.Event.activate, this.onActivate.bindAsEventListener(this));

		Mojo.listen(this.controller.window, 'resize', this.onResize.bindAsEventListener(this));
		
		this.pagesModel = new LauncherPages({

@@ -167,6 +168,22 @@

		this.updatePageIndicators();
	},
	

+ /* set launcher page to override last used page */ + onActivate: function(event) { + // set launcher to first page + $('launcher_root').mojo.setSnapIndex(0, false); + + /** + * If Bsiegel's 'Reset Scroll Position' patch is installed + * then this does what it says on the tin for the middle page. + */ + event.value = 0; /* Fudge this because onPageChange expects a + * mojo-property-change event but it's actually + * getting mojo-event-deactivate. + */ + this.onPageChange(event); + }, +

	/* clean and hide global search */
	onDeactivate: function(event) {

</source>