Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Attributes
nsCairoScreen Class Reference

#include <nsCairoScreen.h>

Inheritance diagram for nsCairoScreen:
Inheritance graph
[legend]
Collaboration diagram for nsCairoScreen:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsCairoScreen ()
virtual ~nsCairoScreen ()
void Init ()
void GetRect (out long left, out long top, out long width, out long height)
void GetAvailRect (out long left, out long top, out long width, out long height)

Public Attributes

readonly attribute long pixelDepth
readonly attribute long colorDepth

Private Attributes

PRUint32 mScreenNum
nsRect mRect
nsRect mAvailRect

Detailed Description

Definition at line 46 of file nsCairoScreen.h.


Constructor & Destructor Documentation

Definition at line 51 of file nsCairoScreen.cpp.

  :
    mScreenNum(0), mRect(0, 0, 0, 0), mAvailRect(0, 0, 0, 0)

{
    NS_INIT_ISUPPORTS();
}

Definition at line 60 of file nsCairoScreen.cpp.

{
}

Member Function Documentation

void nsIScreen::GetAvailRect ( out long  left,
out long  top,
out long  width,
out long  height 
) [inherited]
void nsIScreen::GetRect ( out long  left,
out long  top,
out long  width,
out long  height 
) [inherited]

Definition at line 102 of file nsCairoScreen.cpp.

{
#ifdef MOZ_ENABLE_GTK2
    mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
    // We need to account for the taskbar, etc in the available rect.
    // See http://freedesktop.org/Standards/wm-spec/index.html#id2767771

    // XXX It doesn't change that often, but we should probably
    // listen for changes to _NET_WORKAREA.
    // XXX do we care about _NET_WM_STRUT_PARTIAL?  That will
    // add much more complexity to the code here (our screen
    // could have a non-rectangular shape), but should
    // lead to greater accuracy.

#if GTK_CHECK_VERSION(2,2,0)
    GdkWindow *root_window = gdk_get_default_root_window();
#else
    GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)

    long *workareas;
    GdkAtom type_returned;
    int format_returned;
    int length_returned;

#if GTK_CHECK_VERSION(2,0,0)
    GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
#else
    GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;
#endif

    gdk_error_trap_push();

    // gdk_property_get uses (length + 3) / 4, hence G_MAXLONG - 3 here.
    if (!gdk_property_get(root_window,
                          gdk_atom_intern ("_NET_WORKAREA", FALSE),
                          cardinal_atom,
                          0, G_MAXLONG - 3, FALSE,
                          &type_returned,
                          &format_returned,
                          &length_returned,
                          (guchar **) &workareas)) {
        // This window manager doesn't support the freedesktop standard.
        // Nothing we can do about it, so assume full screen size.
        return;
    }

    // Flush the X queue to catch errors now.
    gdk_flush();

    if (!gdk_error_trap_pop() &&
        type_returned == cardinal_atom &&
        length_returned && (length_returned % 4) == 0 &&
        format_returned == 32) {
        int num_items = length_returned / sizeof(long);

        for (int i = 0; i < num_items; i += 4) {
            nsRect workarea(workareas[i],     workareas[i + 1],
                            workareas[i + 2], workareas[i + 3]);
            if (!mRect.Contains(workarea)) {
                NS_WARNING("Invalid bounds");
                continue;
            }

            mAvailRect.IntersectRect(mAvailRect, workarea);
        }
    }

#elif MOZ_ENABLE_XLIB
    mScreenNum = 0;
    mRect.x = mAvailRect.x = 0;
    mRect.y = mAvailRect.y = 0;
    mRect.width = mAvailRect.width = 1600;
    mRect.height = mAvailRect.height = 1200;
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

readonly attribute long nsIScreen::colorDepth [inherited]

Definition at line 49 of file nsIScreen.idl.

Definition at line 59 of file nsCairoScreen.h.

Definition at line 58 of file nsCairoScreen.h.

Definition at line 57 of file nsCairoScreen.h.

readonly attribute long nsIScreen::pixelDepth [inherited]

Definition at line 48 of file nsIScreen.idl.


The documentation for this class was generated from the following files: