Backing out since gdk_screen_get_default, gdk_screen_get_width, and gdk_screen_get_height don't exist on older version of GTK+ (lhasa tinderbox).

This commit is contained in:
dbaron%dbaron.org 2006-08-03 06:32:31 +00:00
parent cee7609648
commit 9f89f6f417
2 changed files with 11 additions and 84 deletions

View File

@ -38,45 +38,13 @@
#include "nsScreenGtk.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/Xatom.h>
static GdkFilterReturn
net_workarea_changed_filter(GdkXEvent *aGdkXEvent, GdkEvent *aGdkEvent,
gpointer aClosure)
{
XEvent *xevent = NS_STATIC_CAST(XEvent*, aGdkXEvent);
nsScreenGtk *ourScreen = NS_STATIC_CAST(nsScreenGtk*, aClosure);
switch (xevent->type) {
case PropertyNotify:
{
XPropertyEvent *propertyEvent = &xevent->xproperty;
if (propertyEvent->atom == ourScreen->NetWorkareaAtom()) {
ourScreen->Init(PR_TRUE);
}
}
break;
default:
break;
}
return GDK_FILTER_CONTINUE;
}
static void
screen_size_changed_cb(GdkScreen *aScreen, gpointer aClosure)
{
nsScreenGtk *ourScreen = NS_STATIC_CAST(nsScreenGtk*, aClosure);
ourScreen->Init(PR_TRUE);
}
nsScreenGtk :: nsScreenGtk ( )
: mScreen(nsnull),
mRootWindow(nsnull),
mScreenNum(0),
: mScreenNum(0),
mRect(0, 0, 0, 0),
mAvailRect(0, 0, 0, 0)
{
@ -85,16 +53,6 @@ nsScreenGtk :: nsScreenGtk ( )
nsScreenGtk :: ~nsScreenGtk()
{
if (mRootWindow) {
gdk_window_remove_filter(mRootWindow, net_workarea_changed_filter, this);
g_object_unref(mRootWindow);
mRootWindow = nsnull;
}
if (mScreen) {
g_signal_handler_disconnect(G_OBJECT(mScreen), mSizeChangedHandler);
g_object_unref(mScreen);
mScreen = nsnull;
}
}
@ -148,49 +106,25 @@ nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
void
nsScreenGtk :: Init (PRBool aReInit)
nsScreenGtk :: Init ()
{
if (!aReInit) {
// Listen for "size_changed" signals on default screen to pick up
// changes. The problem with this (event with _after) is that
// toolbars haven't been resized yet when we get this, so instead of
// excluding toolbars known by the window manager, we get a bunch of
// NS_WARNING("Invalid bounds") below.
mScreen = gdk_screen_get_default();
g_object_ref(mScreen);
mSizeChangedHandler =
g_signal_connect_after(G_OBJECT(mScreen), "size_changed",
G_CALLBACK(screen_size_changed_cb), this);
}
mAvailRect = mRect = nsRect(0, 0, gdk_screen_get_width(mScreen),
gdk_screen_get_height(mScreen));
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 (!aReInit) {
#if GTK_CHECK_VERSION(2,2,0)
mRootWindow = gdk_get_default_root_window();
GdkWindow *root_window = gdk_get_default_root_window();
#else
mRootWindow = GDK_ROOT_PARENT();
GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)
g_object_ref(mRootWindow);
gdk_window_set_events(mRootWindow,
GdkEventMask(gdk_window_get_events(mRootWindow) |
GDK_PROPERTY_CHANGE_MASK));
gdk_window_add_filter(mRootWindow, net_workarea_changed_filter, this);
mNetWorkareaAtom =
XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False);
}
long *workareas;
GdkAtom type_returned;
@ -206,7 +140,7 @@ nsScreenGtk :: Init (PRBool aReInit)
gdk_error_trap_push();
// gdk_property_get uses (length + 3) / 4, hence G_MAXLONG - 3 here.
if (!gdk_property_get(mRootWindow,
if (!gdk_property_get(root_window,
gdk_atom_intern ("_NET_WORKAREA", FALSE),
cardinal_atom,
0, G_MAXLONG - 3, FALSE,

View File

@ -40,10 +40,9 @@
#include "nsIScreen.h"
#include "nsRect.h"
#include "gdk/gdk.h"
#include <X11/Xlib.h>
#ifdef MOZ_ENABLE_XINERAMA
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
#endif // MOZ_ENABLE_XINERAMA
@ -58,19 +57,13 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
void Init(PRBool aReInit = PR_FALSE);
void Init();
#ifdef MOZ_ENABLE_XINERAMA
void Init(XineramaScreenInfo *aScreenInfo);
#endif
Atom NetWorkareaAtom() { return mNetWorkareaAtom; }
private:
GdkScreen *mScreen;
GdkWindow *mRootWindow;
PRUint32 mScreenNum;
gulong mSizeChangedHandler;
Atom mNetWorkareaAtom;
nsRect mRect; // in pixels, not twips
nsRect mAvailRect; // in pixels, not twips
};