Back to index

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

#include <nsScreenGtk.h>

Inheritance diagram for nsScreenGtk:
Inheritance graph
Collaboration diagram for nsScreenGtk:
Collaboration graph

List of all members.

Public Member Functions

 nsScreenGtk ()
 ~nsScreenGtk ()
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 51 of file nsScreenGtk.h.

Constructor & Destructor Documentation

Definition at line 46 of file nsScreenGtk.cpp.

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

Definition at line 54 of file nsScreenGtk.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 109 of file nsScreenGtk.cpp.

  mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());

  // We need to account for the taskbar, etc in the available rect.
  // See

  // 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.

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

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

  GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
  GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;


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

  // Flush the X queue to catch errors now.

  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");

      mAvailRect.IntersectRect(mAvailRect, workarea);
  g_free (workareas);

Here is the call graph for this function:

Member Data Documentation

readonly attribute long nsIScreen::colorDepth [inherited]

Definition at line 49 of file nsIScreen.idl.

Definition at line 68 of file nsScreenGtk.h.

Definition at line 67 of file nsScreenGtk.h.

Definition at line 66 of file nsScreenGtk.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: