Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Creating Applications with Mozilla-Chapter 12. Remote Applications-P5 doc
Nội dung xem thử
Mô tả chi tiết
Chapter 12. Remote Applications-P5
12.8. Signed Remote Snake Game
In this section, we look at an enhanced version of the Snake game presented
earlier in the chapter. The enhanced version uses XPConnect to provide a
total full-screen display of the game on the Windows platform as a remote
application.
12.8.1. How to Expand Mozilla to Full Screen
The best way to expand Mozilla to a full screen mode is through full-screen
functions provided in an instance of navigator.xul. These functions run
in the Windows build of Mozilla via the Full Screen item in the View menu.
These functions also work in Linux and Mac, but do not provide 100% fullscreen mode, as some menus and titlebars still show.
The problem here is the current window's navigator.xul document,
which needs to be accessed to get these full-screen functions. A document
loaded in that window just can't use something like window.parent to
get to it, so another route must be found.
This route runs through the nsIWindowMediator interface by the way of
XPConnect. It gives access to the current browser window's
navigator.xul document's window object. Example 12-13 includes the
code for this window access process, along with the functions used to create
the full-screen effect.
Example 12-13. Function for switching screen modes
netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");
const
MEDIATOR_CONTRACTID="@mozilla.org/appshell/windowmediator;1";
const
nsIWindowMediator=Components.interfaces.nsIWindowMe
diator;
var windowManager=
Components.classes[MEDIATOR_CONTRACTID].getService(
nsIWindowMediator);
var hideSidebar=true;
var isRegular=true;
function switchScreen( )
{
if(isRegular)
{
try {
netscape.security.PrivilegeManager.enablePrivilege(
"UniversalXPConnect");