From 77f037650c26466d95ed6b138adff38873f0f7d9 Mon Sep 17 00:00:00 2001 From: "davidben@chromium.org" Date: Fri, 16 Jul 2010 20:34:34 +0000 Subject: Fix crash bug in new SSLClientSocketPool. We also need to push additional error state out of the SSLClientSocketPool on a ERR_SSL_CLIENT_AUTH_CERT_NEEDED error. BUG=49197 TEST=no crash when visiting https://foafssl.org/srv/idp?authreqissuer=http://foaf.me/index.php Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=52693 Review URL: http://codereview.chromium.org/2827053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52735 0039d316-1c4b-4281-b951-d872f2087c98 --- app/x11_util.cc | 25 +++++++++++++++++++++++-- app/x11_util.h | 7 +++++++ 2 files changed, 30 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/x11_util.cc b/app/x11_util.cc index 934e824..101815a 100644 --- a/app/x11_util.cc +++ b/app/x11_util.cc @@ -159,6 +159,10 @@ XID GetX11RootWindow() { return GDK_WINDOW_XID(gdk_get_default_root_window()); } +bool GetCurrentDesktop(int* desktop) { + return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); +} + XID GetX11WindowFromGtkWidget(GtkWidget* widget) { return GDK_WINDOW_XID(widget->window); } @@ -192,7 +196,15 @@ int BitsPerPixelForPixmapDepth(Display* dpy, int depth) { bool IsWindowVisible(XID window) { XWindowAttributes win_attributes; XGetWindowAttributes(GetXDisplay(), window, &win_attributes); - return (win_attributes.map_state == IsViewable); + if (win_attributes.map_state != IsViewable) + return false; + // Some compositing window managers (notably kwin) do not actually unmap + // windows on desktop switch, so we also must check the current desktop. + int window_desktop, current_desktop; + return (!GetWindowDesktop(window, &window_desktop) || + !GetCurrentDesktop(¤t_desktop) || + window_desktop == kAllDesktops || + window_desktop == current_desktop); } bool GetWindowRect(XID window, gfx::Rect* rect) { @@ -342,6 +354,10 @@ XID GetHighestAncestorWindow(XID window, XID root) { } } +bool GetWindowDesktop(XID window, int* desktop) { + return GetIntProperty(window, "_NET_WM_DESKTOP", desktop); +} + // Returns true if |window| is a named window. bool IsWindowNamed(XID window) { XTextProperty prop; @@ -787,7 +803,12 @@ void GrabWindowSnapshot(GtkWindow* gtk_window, bool ChangeWindowDesktop(XID window, XID destination) { int desktop; - if (!GetIntProperty(destination, "_NET_WM_DESKTOP", &desktop)) + if (!GetWindowDesktop(destination, &desktop)) + return false; + + // If |window| is sticky, use the current desktop. + if (desktop == kAllDesktops && + !GetCurrentDesktop(&desktop)) return false; XEvent event; diff --git a/app/x11_util.h b/app/x11_util.h index b85061c..62881f0 100644 --- a/app/x11_util.h +++ b/app/x11_util.h @@ -66,6 +66,8 @@ int GetDefaultScreen(Display* display); // Get the X window id for the default root window XID GetX11RootWindow(); +// Returns the user's current desktop. +bool GetCurrentDesktop(int* desktop); // Get the X window id for the given GTK widget. XID GetX11WindowFromGtkWidget(GtkWidget* widget); XID GetX11WindowFromGdkWindow(GdkWindow* window); @@ -92,6 +94,11 @@ XID GetParentWindow(XID window); // Walk up |window|'s hierarchy until we find a direct child of |root|. XID GetHighestAncestorWindow(XID window, XID root); +static const int kAllDesktops = -1; +// Queries the desktop |window| is on, kAllDesktops if sticky. Returns false if +// property not found. +bool GetWindowDesktop(XID window, int* desktop); + // Implementers of this interface receive a notification for every X window of // the main display. class EnumerateWindowsDelegate { -- cgit v1.1