From 7aa3b8355acf5d8eec0634980699c32ff69116fb Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Mon, 28 Feb 2005 22:07:57 +0000 Subject: NULL check. Fixes bug #165999. 2005-02-28 Christian Persch * embed/mozilla/MozDownload.cpp: NULL check. Fixes bug #165999. * src/ephy-main.c: (slowly_and_stupidly_obtain_timestamp), (main): Try to get an approximation to the launch time if DESKTOP_STARTUP_ID is not set. Fixes bug #168820, patch by Elijah Newren. --- src/ephy-main.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src') diff --git a/src/ephy-main.c b/src/ephy-main.c index 5a62232ca..71b542a1a 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include static gboolean open_in_existing = FALSE; static gboolean open_in_new_tab = FALSE; @@ -140,6 +142,57 @@ idle_unref (GObject *object) return FALSE; } +/* Copied from libnautilus/nautilus-program-choosing.c; Needed in case + * we have no DESKTOP_STARTUP_ID (with its accompanying timestamp). + */ +static Time +slowly_and_stupidly_obtain_timestamp (Display *xdisplay) +{ + Window xwindow; + XEvent event; + + { + XSetWindowAttributes attrs; + Atom atom_name; + Atom atom_type; + char* name; + + attrs.override_redirect = True; + attrs.event_mask = PropertyChangeMask | StructureNotifyMask; + + xwindow = + XCreateWindow (xdisplay, + RootWindow (xdisplay, 0), + -100, -100, 1, 1, + 0, + CopyFromParent, + CopyFromParent, + CopyFromParent, + CWOverrideRedirect | CWEventMask, + &attrs); + + atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE); + g_assert (atom_name != None); + atom_type = XInternAtom (xdisplay, "STRING", TRUE); + g_assert (atom_type != None); + + name = "Fake Window"; + XChangeProperty (xdisplay, + xwindow, atom_name, + atom_type, + 8, PropModeReplace, name, strlen (name)); + } + + XWindowEvent (xdisplay, + xwindow, + PropertyChangeMask, + &event); + + XDestroyWindow(xdisplay, xwindow); + + return event.xproperty.time; +} + int main (int argc, char *argv[]) { @@ -174,6 +227,10 @@ main (int argc, char *argv[]) GNOME_PARAM_APP_DATADIR, DATADIR, NULL); + /* Get a timestamp manually if need be */ + if (user_time == 0) + user_time = slowly_and_stupidly_obtain_timestamp (gdk_display); + g_set_application_name (_("Epiphany Web Browser")); /* Set default window icon */ -- cgit v1.2.3