Closed Bug 30529 Opened 25 years ago Closed 23 years ago

[feature] Implement minimize/maximize/restore

Categories

(Core :: XUL, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla0.9.9

People

(Reporter: hyatt, Assigned: fabian)

References

Details

(Whiteboard: [HAVE FIX])

Attachments

(1 file, 3 obsolete files)

Implement minimize/maximize/restore on nsIWidget and nsIDOMWindow.
Status: NEW → ASSIGNED
OS: Windows 98 → All
Hardware: PC → All
Summary: Implement minimize/maximize/restore → [feature] Implement minimize/maximize/restore
Whiteboard: 1 day
Target Milestone: M15
Target Milestone: M15 → M20
Mass move of all M20 bugs to M30.
Mass move of M20 bugs to M30
Target Milestone: M20 → M30
Mass-moving all M20-M30 XPToolkit bugs to Future
Target Milestone: M30 → Future
Blocks: 61928
Hi!

I need this functionality to implement some Mouse Gestures in Mozilla.
Opera has gestures for minimizing, maximizing and restoring window.
We are (optimoz.mozdev.org) mimicing Opera's gesture, so we need this to be
implemented. 

--mondo
This is feature should be part of 1.0 API. Therefore I ask responsible peolple
to set the Target milestone to something like mozilla1.0 or before.
--mondo
pali: nsIWidget is not part of the public API, so not subject to freezing for
1.0.  for nsIDOMWindow, try jst (cc'ing him).

Pav, you should find a better assignee if you don't wanna own this bug.

/be
If we want this in the DOM we do have the option of adding this to the interface
nsIDOMWindowInternal, which won't be frozen any time soon. But do we really want
minimize in the scriptable DOM API? I smell abuse.
Johnny, what if it is limited to chrome uri's only?
jst: I it just to be added to interface, so that we can use it in MozGest. bug
61928 is request to enable it to the masses, and I don't feel to passionate
about that...
--mondo
If it's not supposed to be usable by anyone, it should not be added to the
window object, unless there's no other alternative.
Jst: well, it should manipulate the Window... and functions it should make
accessible through interface are here (lxr search for minimize & maximize - I'm
guessing these are those functions responsible for it...):
http://lxr.mozilla.org/seamonkey/source/widget/public/nsIWidget.h#418
http://lxr.mozilla.org/seamonkey/source/widget/src/os2/nsWindow.cpp#1117
http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsWindow.cpp#1397
http://lxr.mozilla.org/seamonkey/source/widget/src/xpwidgets/nsBaseWidget.cpp#368
I believe it belongs to window object... But they could be accesible also from
that nsIWidget - I don't care where, I just need to get to them :-)

--mondo
Blocks: 76537
jst: what is the status of this bug?
--mondo
I don't see why these methods would need to be accessible to JS, at least not to
web content. If that's the case, then it's not my bug, and I don't know what the
status is. The method you point out is already accessible through nsIWidget
(which is a non-public, non-scriptable, interface), but I'm not convinced we
need to expose such functionality to web content.
I'm also against exposing this to web content. That's bug 61928 (see blocks
^^^). I want to expose this in nsIWidget for scripting with JS. See bug 76537.
We need it!
--mondo
Eh, nsIWidget is not, and will probably never be, a scriptable interface, if you
need to do this from JS then we need a different solution.
OK I got a patch for this but there's a slight issue: it doesn't work on linux ;-)
I asked hwaara (he's using windows) to test my patch and he says it works for him.
But in my tests on linux (mandrake8.1, KDE2.2.1) it doesn't work. I suspect it's
a bug in the implementation of nsIWidget::SetSizeMode() on Linux rather than a
bug in my code.
Taking, marking 0.9.7. We could check this in as is then fix SetSizeMode().
Assignee: pavlov → hidday
Status: ASSIGNED → NEW
Target Milestone: Future → mozilla0.9.7
I really hope this will NOT be accessable for any malicious web author; it
should probably be chrome-only.
Once complete, this will indeed not be accessible to web content.
since my linux box is dead, here's what needs to be done to implement this. I
hope someone else will pick it up, otherwise it'll have to wait.
1) Wait until jst lands his nsIDOMWindowInternal => nsIDOMChromedWindow changes.
2) Add void maximize(); void minimize(); void restore();
to nsIDOMChromedWindow.idl
3) Implement GlobalWindowImpl::Maximize(), GWI::Minimize(), and GWI::Restore().
Here's what GWI::Maximize() looks like, Minimize and Restore are slightly
modified versions of this function.

NS_IMETHODIMP
GlobalWindowImpl::Maximize()
{
  nsCOMPtr<nsIBaseWindow> treeOwnerAsWin;
  nsresult rv = GetTreeOwner(getter_AddRefs(treeOwnerAsWin));
  
  if (treeOwnerAsWin) {
    nsCOMPtr<nsIWidget> widget;
    rv = treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));

    if (widget) {
      rv = widget->SetSizeMode(nsSizeMode_Maximized);
    }
  }

  return rv;
}

For GWI::Minimize(), replace nsSizeMode_Maximized with nsSizeMode_Minimized
For GWI::Restore(), replace nsSizeMode_Maximized with nsSizeMode_Normal.

4) add the following to all.js 
pref("capability.policy.default.Window.minimize","noAccess");
pref("capability.policy.default.Window.maximize","noAccess");
pref("capability.policy.default.Window.restore","noAccess");
to make them chrome-only.
I'm sorry my linux box is still down so this bug needs a new owner. Pushing to
0.9.8 in the mean time.
Target Milestone: mozilla0.9.7 → mozilla0.9.8
After so long... note that it doesn't work on my KDE for some reason, but
hwaara said it works on windows
jst, reviews please?
Status: NEW → ASSIGNED
Whiteboard: 1 day → [HAVE FIX]
Target Milestone: mozilla0.9.8 → mozilla0.9.9
jst, anyone: are the maximize, minimize, and restore names added here to
nsIDOMWindowInternal going to collide with script uses of the same names?

/be
Yes, that's why they're going in the not yet officially available
nsIDOMChromeWindow. I have a patch that adds a chrome only nsIDOMChromeWindow
interface that we should combine with this patch. Once that lands we'll finally
get rid of window.title too in content windows :-)
Blake, I'm about to implement window.restore(), window.minimize() and
window.maximize() (available from chrome). I remember you needed
window.isMinimized() and window.isMaximized earlier. Do you still need it?
Should I implement window.isMinimized() or window.minimized?
The new file nsIDOMChromeWindow.idl is not included in the diff, gotta wait
till jst cvs adds it. The patch just cleans up what jst sent me and merges with
the other patch in this bug.
Attachment #66668 - Attachment is obsolete: true
isMinimized is the better name (minimized is only one letter different, at the
end yet, and doesn't follow the Java-esque isFoo naming convention).

/be
Or do we want a more generic property for describing the current window state,
i.e. minimized, maximized, ...? Maybe something like window.windowState and some
constants in nsIDOMChromeWindow?
Yeah, I think windowState and constants are the best.
mozilla/dom/public/idl/base/nsIDOMChromeWindow.idl added to CVS.
Blocks: 117388
Summary of changes:
- Add windowState, constants, minimize(), maximize(), restore() to
nsIDOMChromeWindow
- Implement them in a new class, nsGlobalChromeWindow
- Add the necessary DOMClassInfo stuff
- Modify the docshell to create the correct global scripting object
- SetTitle no longer checks for a chrome context
- Add a helper function, nsGlobalChromeWindow::GetMainWidget()
- Change the creator functions for new script global objects to take a
aIsChrome parameter
- changed window.GetAttention() to window.getAttention() in all the places
where it's used.
Attachment #66727 - Attachment is obsolete: true
Up-to-date patch. Since this touches many files, I'd appreciate if we could get
rid of it pretty fast, it's a maintance nightmare. Thanks!
Attachment #66963 - Attachment is obsolete: true
Comment on attachment 67515 [details] [diff] [review]
Non-bitrotted patch.

- Make nsGlobalChromeWindow::GetWindowState() always set the out param to a
default just in case we encounter an unexpected condition.

sr=jst
Attachment #67515 - Flags: superreview+
Comment on attachment 67515 [details] [diff] [review]
Non-bitrotted patch.

r=heikki (pls remember to do the change jst requested)
Attachment #67515 - Flags: review+
Sure I'd make the change, but since I'm not the one checking in... ;-)
Unless you want a new patch for this change.
I'll check this in an make those changes...
Suresh, this will need 3 minor changes in the AIM code in the commercial tree,
window.GetAttention() needs to be replaced with window.getAttention() (search
for GetAttention in the commercial lxr), and a few C++ callers need to make sure
they have a chrome window and QI the window to nsIDOMChromeWindow and then call
GetAttention() on that. Could you apply this patch and make AIM happy again?
Triaging my bug list. Marking P2, bug has a reviewed patch, functionality is
blocking a couple of other bugs.
Suresh, can those changes to AIM be done? Should we ask someone else?
Priority: P3 → P2
is this affecting bug 120155?
FIXED, thanks alot to jst and suresh for landing the patch :-) 
Marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
No longer blocks: 61928
*** Bug 61928 has been marked as a duplicate of this bug. ***
What has happend to the getAttention method? It is no longer available in the
location bar. I've looked for it after loading a HTML document and after loading
a XML document. It ist present in the JavaScript console, but this window has no
icon to animate, so I can't see an effect, wenn calling it.

Th documentation writes about the old GetAttention to flash the icon in the
system tray. What is the system tray? I'm using Linux with KDE 1.0 and an other
Linux with KDE 2.0, but I don't see any animation.

I beleive to remeber to see the Mozilla M-Icon to anmimate on Windows with 0.9.7
using GetAttention in the location bar like loading something. But I do not get
such an effect with 0.9.7 on Linux.

What exactly should I expect and where can I use getAttention?
GetAttention() was renamed to getAttention() and it is only available in chrome
windows, not in content windows.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: