Using a non default icon makes persist fail

RESOLVED FIXED

Status

Mozilla Labs
Prism
RESOLVED FIXED
11 years ago
11 years ago

People

(Reporter: Xavier Vergés, Unassigned)

Tracking

Details

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070201 Webrunner/0.5

When an icon different from webrunner is specified as a parameter in the command line or in a webapp file, the window will not keep its size/position after closing and reopening.

The icon is changed using 
document.documentElement.setAttribute("id", params.icon);

That probably means that the new position is saved for "newicon". When the window is reopened, the position is obtained from "webrunner".

Reproducible: Always

Steps to Reproduce:
1. Open a window using "-uri ..." and "-icon gmail.ico" as additional params
2. Change the window's position
3. Close the window
4. Open a window using the same params as in step 1
Actual Results:  
The window's position is the same as in step 1

Expected Results:  
The window's position should be the one set in in step 2
(Reporter)

Comment 1

11 years ago
If the line

document.documentElement.setAttribute("id", params.icon);

is called before, outside of startup(), the positions get restored.
(Reporter)

Comment 2

11 years ago
If changing the id is the only possible way that XULRunner gives to change the icon, maybe it would be a good thing to add a "persist" flag to the command line/webapp profile, and remove the "persist" attribute in the window definition. Having window positions depend on the icon name is confusing.

Just in case it can be of any use, this code, that I wrote before I learned that moving the setAttribute("id", params.icon) call would be enough, restores the stored windows position:

function restoreWinPositions(id) {
  var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
                     getService(Components.interfaces.nsIRDFService);
  var rdfLocalStoreDS = Components.classes["@mozilla.org/rdf/datasource;1?name=local-store"].
                     getService(Components.interfaces.nsIRDFDataSource);
  var rdfRes = rdfService.GetResource("chrome://webrunner/content/webrunner.xul#" + id);
  
  var props = {};
  var targets = rdfLocalStoreDS.ArcLabelsOut(rdfRes);
  while (targets.hasMoreElements()){
    var predicate = targets.getNext();
    if (predicate instanceof Components.interfaces.nsIRDFResource){
      var target = rdfLocalStoreDS.GetTarget(rdfRes, predicate, true);
      if (target instanceof Components.interfaces.nsIRDFLiteral){
        props[predicate.Value] = target.Value;
      }
    }
  }
  if ((typeof(props.screenX) != 'undefined') && (typeof(props.screenY) != 'undefined')) {
    alert("moving");
    window.moveTo(props.screenX, props.screenY);
  }
  if ((typeof(props.width) != 'undefined') && (typeof(props.height) != 'undefined')) {
    alert("resizing");
    window.resizeTo(props.width, props.height);
  }
}

Comment 3

11 years ago
Where should the call to setAttribute("id", params.icon)  be moved to?
(Reporter)

Comment 4

11 years ago
The thing is that my webrunner (as packaged for 0.5) and the webrunner in svn look quite different. The HostUI and the WebRunner objects do not exist in my installed code. 

What fixed the thing for me was having
document.documentElement.setAttribute("id", params.icon);
outside of any function definiton, so it got executed before the "load" event called "startup". 

I'm sorry about not being able to check out the trunk now and give a more precise answer.

Comment 5

11 years ago
Ok, that probably won't work in the current SVN. I'll look for some workaround, or perhaps we should use the code you posted above.
Component: Prism → Prism
Product: Other Applications → Mozilla Labs
This should be fixed now. We store the window settings in localstore.json and we wait until the icon (window ID) is changed before loading or saving
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.