NS_IMETHOD            ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen) { return NS_OK; }
NS_IMETHODIMP nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen) { #ifdef DEBUG_APPSHELL printf("ListenToEventQueue(%p, %d) this=%p\n", aQueue, aListen, this); #endif if (!sQueueHashTable) { sQueueHashTable = PL_NewHashTable(3, (PLHashFunction)IntHashKey, PL_CompareValues, PL_CompareValues, 0, 0); } if (!sCountHashTable) { sCountHashTable = PL_NewHashTable(3, (PLHashFunction)IntHashKey, PL_CompareValues, PL_CompareValues, 0, 0); }  if (aListen) {  PRInt32 key = aQueue->GetEventQueueSelectFD();   if (!PL_HashTableLookup(sQueueHashTable, GINT_TO_POINTER(key))) { gint tag; tag = our_gdk_input_add(aQueue->GetEventQueueSelectFD(), event_processor_callback, aQueue, G_PRIORITY_HIGH_IDLE); if (tag >= 0) { PL_HashTableAdd(sQueueHashTable, GINT_TO_POINTER(key), GINT_TO_POINTER(tag)); } PLEventQueue *plqueue; aQueue->GetPLEventQueue(&plqueue); PL_RegisterEventIDFunc(plqueue, getNextRequest, 0); sEventQueueList->AppendElement(plqueue); }  gint count = GPOINTER_TO_INT(PL_HashTableLookup(sCountHashTable, GINT_TO_POINTER(key))); PL_HashTableAdd(sCountHashTable, GINT_TO_POINTER(key), GINT_TO_POINTER(count+1)); } else {  PRInt32 key = aQueue->GetEventQueueSelectFD();  PLEventQueue *plqueue; aQueue->GetPLEventQueue(&plqueue); PL_UnregisterEventIDFunc(plqueue); sEventQueueList->RemoveElement(plqueue);  gint count = GPOINTER_TO_INT(PL_HashTableLookup(sCountHashTable, GINT_TO_POINTER(key))); if (count - 1 == 0) { gint tag = GPOINTER_TO_INT(PL_HashTableLookup(sQueueHashTable, GINT_TO_POINTER(key))); if (tag > 0) { g_source_remove(tag); PL_HashTableRemove(sQueueHashTable, GINT_TO_POINTER(key)); } } PL_HashTableAdd(sCountHashTable, GINT_TO_POINTER(key), GINT_TO_POINTER(count-1));  }  return NS_OK; }
  NS_IMETHOD            ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen)                          { return NS_OK; }