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
This commit is contained in:
blizzard%redhat.com
1999-08-23 12:50:53 +00:00
parent 323391d5a6
commit 4078f0da04
2 changed files with 19 additions and 10 deletions

View File

@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
#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)
{

View File

@@ -220,7 +220,7 @@ nsWidget::StandardWidgetCreate(nsIWidget *aParent,
if (mIsToplevel == PR_TRUE) {
SetUpWMHints();
}
XSync(mDisplay, False);
// XSync(mDisplay, False);
return NS_OK;
}