From 4078f0da0401331de2cc2a79c4555768e4f7403f Mon Sep 17 00:00:00 2001 From: "blizzard%redhat.com" Date: Mon, 23 Aug 1999 12:50:53 +0000 Subject: [PATCH] take out some extra XSync() calls and _Xdebug symbol. should make it a bit faster. also, if an X event is passed in and we don't know anything about the window then don't crash. git-svn-id: svn://10.0.0.236/trunk@44141 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/xlib/nsAppShell.cpp | 27 +++++++++++++++++--------- mozilla/widget/src/xlib/nsWidget.cpp | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/mozilla/widget/src/xlib/nsAppShell.cpp b/mozilla/widget/src/xlib/nsAppShell.cpp index 3122daa25a7..47ebcf84dfb 100644 --- a/mozilla/widget/src/xlib/nsAppShell.cpp +++ b/mozilla/widget/src/xlib/nsAppShell.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "nsWidget.h" #include "nsAppShell.h" @@ -249,7 +250,7 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv) exit(1); } - _Xdebug = 1; + // _Xdebug = 1; mScreen = DefaultScreenOfDisplay(mDisplay); @@ -307,12 +308,6 @@ nsresult nsAppShell::Run() done: printf("Getting the xlib connection number.\n"); xlib_fd = ConnectionNumber(mDisplay); - queue_fd = EQueue->GetEventQueueSelectFD(); - if (xlib_fd >= queue_fd) { - max_fd = xlib_fd + 1; - } else { - max_fd = queue_fd + 1; - } // process events. while (DieAppShellDie == PR_FALSE) { XEvent event; @@ -320,11 +315,19 @@ nsresult nsAppShell::Run() struct timeval *cur_time_ptr; int please_run_timer_queue = 0; gettimeofday(&cur_time, NULL); + // set up our fds + queue_fd = EQueue->GetEventQueueSelectFD(); + if (xlib_fd >= queue_fd) { + max_fd = xlib_fd + 1; + } else { + max_fd = queue_fd + 1; + } FD_ZERO(&select_set); // add the queue and the xlib connection to the select set FD_SET(queue_fd, &select_set); FD_SET(xlib_fd, &select_set); + //printf("cur time: %ld %ld\n", cur_time.tv_sec, cur_time.tv_usec); if (CallTimeToNextTimeoutFunc(&cur_time) == 0) { cur_time_ptr = NULL; } @@ -335,12 +338,14 @@ nsresult nsAppShell::Run() please_run_timer_queue = 1; } } + // if (cur_time_ptr) + //printf("select time: %ld %ld\n", cur_time_ptr->tv_sec, cur_time_ptr->tv_usec); // note that we are passing in the timeout_ptr from above. // if there are no timers, this will be null and this will // block until hell freezes over select_retval = select(max_fd, &select_set, NULL, NULL, cur_time_ptr); if (select_retval == -1) { - printf("Select returned error.\n"); + printf("Select returned error: %s.\n", strerror(errno)); return NS_ERROR_FAILURE; } if (select_retval == 0) { @@ -406,7 +411,6 @@ NS_METHOD nsAppShell::PushThreadEventQueue() NS_METHOD nsAppShell::PopThreadEventQueue() { nsresult rv; - NS_WITH_SERVICE(nsIEventQueueService, eQueueService, kEventQueueServiceCID, &rv); if (NS_SUCCEEDED(rv)) rv = eQueueService->PopThreadEventQueue(); @@ -459,6 +463,11 @@ nsAppShell::DispatchXEvent(XEvent *event) nsWidget *widget; widget = nsWidget::GetWidgetForWindow(event->xany.window); + // did someone pass us an x event for a window we don't own? + // bad! bad! + if (widget == nsnull) + return; + // switch on the type of event switch (event->type) { diff --git a/mozilla/widget/src/xlib/nsWidget.cpp b/mozilla/widget/src/xlib/nsWidget.cpp index 5bc0629bd9f..d99218363c2 100644 --- a/mozilla/widget/src/xlib/nsWidget.cpp +++ b/mozilla/widget/src/xlib/nsWidget.cpp @@ -220,7 +220,7 @@ nsWidget::StandardWidgetCreate(nsIWidget *aParent, if (mIsToplevel == PR_TRUE) { SetUpWMHints(); } - XSync(mDisplay, False); + // XSync(mDisplay, False); return NS_OK; }