зеркало из https://github.com/mozilla/pjs.git
checkpointing changes. mainloop runs, event queues run, windows will show and resize. not part of the build.
This commit is contained in:
Родитель
8ffba705a1
Коммит
4c6204470a
|
@ -35,19 +35,29 @@ REQUIRES = xpcom \
|
|||
gfx \
|
||||
dom
|
||||
|
||||
CSRCS =
|
||||
CSRCS = \
|
||||
mozcontainer.c \
|
||||
mozdrawingarea.c \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsWindow.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsAppShell.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsBidiKeyboard.cpp \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
|
||||
|
||||
EXPORTS = \
|
||||
mozdrawingarea.h \
|
||||
mozcontainer.h \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CFLAGS += $(MOZ_GTK2_CFLAGS)
|
||||
|
|
|
@ -20,10 +20,35 @@
|
|||
*/
|
||||
|
||||
#include "nsAppShell.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "plhash.h"
|
||||
|
||||
#include <gtk/gtkmain.h>
|
||||
|
||||
static PRBool sInitialized = PR_FALSE;
|
||||
static PLHashTable *sQueueHashTable = nsnull;
|
||||
static PLHashTable *sCountHashTable = nsnull;
|
||||
|
||||
static gboolean event_processor_callback (GIOChannel *source,
|
||||
GIOCondition condition,
|
||||
gpointer data)
|
||||
{
|
||||
nsIEventQueue *eventQueue = (nsIEventQueue *)data;
|
||||
if (eventQueue)
|
||||
eventQueue->ProcessPendingEvents();
|
||||
|
||||
// always remove the source event
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define NUMBER_HASH_KEY(_num) ((PLHashNumber) _num)
|
||||
|
||||
static PLHashNumber
|
||||
IntHashKey(PRInt32 key)
|
||||
{
|
||||
return NUMBER_HASH_KEY(key);
|
||||
}
|
||||
|
||||
nsAppShell::nsAppShell(void)
|
||||
{
|
||||
|
@ -44,6 +69,8 @@ nsAppShell::Create(int *argc, char **argv)
|
|||
|
||||
sInitialized = PR_TRUE;
|
||||
|
||||
// XXX add all of the command line handling
|
||||
|
||||
gtk_init(argc, &argv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -52,13 +79,57 @@ nsAppShell::Create(int *argc, char **argv)
|
|||
NS_IMETHODIMP
|
||||
nsAppShell::Run(void)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!mEventQueue)
|
||||
Spinup();
|
||||
|
||||
if (!mEventQueue)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// go go gadget gtk2!
|
||||
gtk_main();
|
||||
|
||||
Spindown();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Spinup(void)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// get the event queue service
|
||||
nsCOMPtr <nsIEventQueueService> eventQService =
|
||||
do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to get event queue service");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// get the event queue for this thread
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(mEventQueue));
|
||||
|
||||
// if we got an event queue, just use it
|
||||
if (mEventQueue)
|
||||
goto done;
|
||||
|
||||
// otherwise creaet a new event queue for the thread
|
||||
rv = eventQService->CreateThreadEventQueue();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Could not create the thread event queue");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// ask again for the event queue now that we have create one.
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(mEventQueue));
|
||||
|
||||
done:
|
||||
ListenToEventQueue(mEventQueue, PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -70,29 +141,89 @@ nsAppShell::Spindown(void)
|
|||
NS_IMETHODIMP
|
||||
nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
// initialize our hash tables if we have to
|
||||
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) {
|
||||
/* add a listener */
|
||||
PRInt32 key = aQueue->GetEventQueueSelectFD();
|
||||
|
||||
/* only add if we arn't already in the table */
|
||||
if (!PL_HashTableLookup(sQueueHashTable, GINT_TO_POINTER(key))) {
|
||||
GIOChannel *ioc;
|
||||
ioc = g_io_channel_unix_new(key);
|
||||
g_io_add_watch_full (ioc, G_PRIORITY_HIGH_IDLE,
|
||||
G_IO_IN,
|
||||
event_processor_callback, aQueue, NULL);
|
||||
|
||||
if (ioc) {
|
||||
PL_HashTableAdd(sQueueHashTable, GINT_TO_POINTER(key),
|
||||
ioc);
|
||||
}
|
||||
}
|
||||
/* bump up the count */
|
||||
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 {
|
||||
/* remove listener */
|
||||
PRInt32 key = aQueue->GetEventQueueSelectFD();
|
||||
|
||||
gint count = GPOINTER_TO_INT(PL_HashTableLookup(sCountHashTable,
|
||||
GINT_TO_POINTER(key)));
|
||||
if (count - 1 == 0) {
|
||||
GIOChannel *ioc = (GIOChannel *)PL_HashTableLookup(sQueueHashTable,
|
||||
GINT_TO_POINTER(key));
|
||||
if (ioc) {
|
||||
g_io_channel_shutdown (ioc, TRUE, NULL);
|
||||
g_io_channel_unref(ioc);
|
||||
PL_HashTableRemove(sQueueHashTable, GINT_TO_POINTER(key));
|
||||
}
|
||||
}
|
||||
|
||||
// update the count for this key
|
||||
PL_HashTableAdd(sCountHashTable, GINT_TO_POINTER(key),
|
||||
GINT_TO_POINTER(count-1));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::GetNativeEvent(PRBool &aRealEvent, void * &aEvent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
aRealEvent = PR_FALSE;
|
||||
aEvent = 0;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
if (!mEventQueue)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
g_main_context_iteration(NULL, TRUE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::SetDispatchListener(nsDispatchListener *aDispatchListener)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAppShell::Exit(void)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
gtk_main_quit();
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is IBM code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM.
|
||||
* Portions created by IBM are
|
||||
* Copyright (C) International Business Machines
|
||||
* Corporation, 2000. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Simon Montagu
|
||||
*/
|
||||
|
||||
#include "nsBidiKeyboard.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
||||
|
||||
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsBidiKeyboard::~nsBidiKeyboard()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
|
||||
{
|
||||
*aIsRTL = PR_FALSE;
|
||||
#ifdef IBMBIDI
|
||||
// XXX Insert platform specific code to determine keyboard direction
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
|
||||
{
|
||||
#ifdef IBMBIDI
|
||||
// XXX Insert platform specific code to set keyboard language
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is IBM code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM.
|
||||
* Portions created by IBM are
|
||||
* Copyright (C) International Business Machines
|
||||
* Corporation, 2000. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Simon Montagu
|
||||
*/
|
||||
|
||||
#ifndef __nsBidiKeyboard
|
||||
#define __nsBidiKeyboard
|
||||
#include "nsIBidiKeyboard.h"
|
||||
|
||||
class nsBidiKeyboard : public nsIBidiKeyboard
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIBIDIKEYBOARD
|
||||
|
||||
nsBidiKeyboard();
|
||||
virtual ~nsBidiKeyboard();
|
||||
/* additional members */
|
||||
};
|
||||
|
||||
|
||||
#endif // __nsBidiKeyboard
|
|
@ -0,0 +1,159 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nscore.h" // needed for 'nsnull'
|
||||
#include "nsToolkit.h"
|
||||
|
||||
//
|
||||
// Static thread local storage index of the Toolkit
|
||||
// object associated with a given thread...
|
||||
//
|
||||
static PRUintn gToolkitTLSIndex = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// constructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::nsToolkit()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mSharedGC = nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// destructor
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
nsToolkit::~nsToolkit()
|
||||
{
|
||||
if (mSharedGC) {
|
||||
gdk_gc_unref(mSharedGC);
|
||||
}
|
||||
|
||||
// Remove the TLS reference to the toolkit...
|
||||
PR_SetThreadPrivate(gToolkitTLSIndex, nsnull);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// nsISupports implementation macro
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
|
||||
|
||||
void nsToolkit::CreateSharedGC(void)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
|
||||
if (mSharedGC)
|
||||
return;
|
||||
|
||||
pixmap = gdk_pixmap_new(NULL, 1, 1, gdk_rgb_get_visual()->depth);
|
||||
mSharedGC = gdk_gc_new(pixmap);
|
||||
gdk_pixmap_unref(pixmap);
|
||||
}
|
||||
|
||||
GdkGC *nsToolkit::GetSharedGC(void)
|
||||
{
|
||||
return gdk_gc_ref(mSharedGC);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsToolkit::Init(PRThread *aThread)
|
||||
{
|
||||
CreateSharedGC();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Return the nsIToolkit for the current thread. If a toolkit does not
|
||||
// yet exist, then one will be created...
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult)
|
||||
{
|
||||
nsIToolkit* toolkit = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
PRStatus status;
|
||||
|
||||
// Create the TLS index the first time through...
|
||||
if (0 == gToolkitTLSIndex) {
|
||||
status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL);
|
||||
if (PR_FAILURE == status) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex);
|
||||
|
||||
//
|
||||
// Create a new toolkit for this thread...
|
||||
//
|
||||
if (!toolkit) {
|
||||
toolkit = new nsToolkit();
|
||||
|
||||
if (!toolkit) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
NS_ADDREF(toolkit);
|
||||
toolkit->Init(PR_GetCurrentThread());
|
||||
//
|
||||
// The reference stored in the TLS is weak. It is removed in the
|
||||
// nsToolkit destructor...
|
||||
//
|
||||
PR_SetThreadPrivate(gToolkitTLSIndex, (void*)toolkit);
|
||||
}
|
||||
} else {
|
||||
NS_ADDREF(toolkit);
|
||||
}
|
||||
*aResult = toolkit;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
@ -1,22 +1,70 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Christopher Blizzard.
|
||||
* Portions created by Christopher Blizzard are Copyright (C)
|
||||
* Christopher Blizzard. All Rights Reserved.
|
||||
*
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef TOOLKIT_H
|
||||
#define TOOLKIT_H
|
||||
|
||||
#include "nsIToolkit.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
/**
|
||||
* Wrapper around the thread running the message pump.
|
||||
* The toolkit abstraction is necessary because the message pump must
|
||||
* execute within the same thread that created the widget under Win32.
|
||||
*/
|
||||
|
||||
class nsToolkit : public nsIToolkit
|
||||
{
|
||||
|
||||
public:
|
||||
nsToolkit();
|
||||
virtual ~nsToolkit();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(PRThread *aThread);
|
||||
|
||||
void CreateSharedGC(void);
|
||||
GdkGC *GetSharedGC(void);
|
||||
|
||||
private:
|
||||
GdkGC *mSharedGC;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // TOOLKIT_H
|
||||
|
|
|
@ -23,9 +23,14 @@
|
|||
#include "nsWidgetsCID.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsAppShell.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiKeyboard.h"
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChildWindow)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
|
@ -33,10 +38,20 @@ static nsModuleComponentInfo components[] =
|
|||
NS_WINDOW_CID,
|
||||
"@mozilla.org/widget/window/gtk2;1",
|
||||
nsWindowConstructor },
|
||||
{ "Gtk2 Child Window",
|
||||
NS_CHILD_CID,
|
||||
"@mozilla.org/widgets/child_window/gtk;1",
|
||||
nsChildWindowConstructor },
|
||||
{ "Gtk2 AppShell",
|
||||
NS_APPSHELL_CID,
|
||||
"@mozilla.org/widget/appshell/gtk2;1",
|
||||
nsAppShellConstructor },
|
||||
#ifdef IBMBIDI
|
||||
{ "Gtk2 Bidi Keyboard",
|
||||
NS_BIDIKEYBOARD_CID,
|
||||
"@mozilla.org/widget/bidikeyboard;1",
|
||||
nsBidiKeyboardConstructor },
|
||||
#endif /* IBMBIDI */
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
#include "nsWindow.h"
|
||||
#include "nsToolkit.h"
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
#include <gdk/gdkx.h>
|
||||
|
@ -29,6 +30,7 @@ nsWindow::nsWindow()
|
|||
mContainer = nsnull;
|
||||
mDrawingarea = nsnull;
|
||||
mIsTopLevel = PR_FALSE;
|
||||
mWindowType = eWindowType_child;
|
||||
}
|
||||
|
||||
nsWindow::~nsWindow()
|
||||
|
@ -292,11 +294,8 @@ nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
{
|
||||
switch (aDataType) {
|
||||
case NS_NATIVE_WINDOW:
|
||||
return mDrawingarea->inner_window;
|
||||
break;
|
||||
|
||||
case NS_NATIVE_WIDGET:
|
||||
return mDrawingarea;
|
||||
return mDrawingarea->inner_window;
|
||||
break;
|
||||
|
||||
case NS_NATIVE_PLUGIN_PORT:
|
||||
|
@ -309,8 +308,8 @@ nsWindow::GetNativeData(PRUint32 aDataType)
|
|||
break;
|
||||
|
||||
case NS_NATIVE_GRAPHIC:
|
||||
NS_WARNING("nsWindow::GetNativeData native graphic not support yet\n");
|
||||
return nsnull;
|
||||
NS_ASSERTION(nsnull != mToolkit, "NULL toolkit, unable to get a GC");
|
||||
return (void *)NS_STATIC_CAST(nsToolkit *, mToolkit)->GetSharedGC();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -412,6 +411,17 @@ nsWindow::ConvertToDeviceCoordinates(nscoord &aX,
|
|||
nscoord &aY)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::PreCreateWidget(nsWidgetInitData *aWidgetInitData)
|
||||
{
|
||||
if (nsnull != aWidgetInitData) {
|
||||
mWindowType = aWidgetInitData->mWindowType;
|
||||
mBorderStyle = aWidgetInitData->mBorderStyle;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindow::CaptureMouse(PRBool aCapture)
|
||||
|
@ -473,18 +483,24 @@ nsWindow::CommonCreate(nsIWidget *aParent,
|
|||
MozContainer *parentContainer = nsnull;
|
||||
GtkWindow *topLevelParent = nsnull;
|
||||
if (aParent || aNativeParent) {
|
||||
GdkWindow *parentWindow;
|
||||
// get the drawing area and the container from the parent
|
||||
if (aParent)
|
||||
parentArea = MOZ_DRAWINGAREA(aParent->GetNativeData(NS_NATIVE_WINDOW));
|
||||
parentWindow = (GdkWindow *)aParent->GetNativeData(NS_NATIVE_WINDOW);
|
||||
else
|
||||
parentArea = MOZ_DRAWINGAREA(aNativeParent);
|
||||
parentWindow = GDK_WINDOW(aNativeParent);
|
||||
|
||||
// find the mozarea on that window
|
||||
gpointer user_data = nsnull;
|
||||
user_data = g_object_get_data(G_OBJECT(parentWindow), "mozdrawingarea");
|
||||
parentArea = MOZ_DRAWINGAREA(user_data);
|
||||
|
||||
NS_ASSERTION(parentArea, "no drawingarea for parent widget!\n");
|
||||
if (!parentArea)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get the user data for the widget - it should be a container
|
||||
gpointer user_data = nsnull;
|
||||
user_data = nsnull;
|
||||
gdk_window_get_user_data(parentArea->inner_window, &user_data);
|
||||
NS_ASSERTION(user_data, "no user data for parentArea\n");
|
||||
if (!user_data)
|
||||
|
@ -547,8 +563,24 @@ nsWindow::CommonCreate(nsIWidget *aParent,
|
|||
this);
|
||||
g_object_set_data(G_OBJECT(mDrawingarea->inner_window), "nsWindow",
|
||||
this);
|
||||
g_object_set_data(G_OBJECT(mContainer), "nsWindow",
|
||||
this);
|
||||
|
||||
g_object_set_data(G_OBJECT(mDrawingarea->clip_window), "mozdrawingarea",
|
||||
mDrawingarea);
|
||||
g_object_set_data(G_OBJECT(mDrawingarea->inner_window), "mozdrawingarea",
|
||||
mDrawingarea);
|
||||
|
||||
if (mContainer)
|
||||
g_object_set_data(G_OBJECT(mContainer), "nsWindow", this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsChildWindow class
|
||||
|
||||
nsChildWindow::nsChildWindow()
|
||||
{
|
||||
}
|
||||
|
||||
nsChildWindow::~nsChildWindow()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
* Christopher Blizzard <blizzard@mozilla.org>
|
||||
*/
|
||||
|
||||
#ifndef __nsWindow_h__
|
||||
|
||||
#include <nsBaseWidget.h>
|
||||
|
||||
#include "mozcontainer.h"
|
||||
|
@ -108,6 +110,7 @@ class nsWindow : public nsBaseWidget {
|
|||
NS_IMETHOD EnableDragDrop(PRBool aEnable);
|
||||
virtual void ConvertToDeviceCoordinates(nscoord &aX,
|
||||
nscoord &aY);
|
||||
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture);
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener,
|
||||
PRBool aDoCapture,
|
||||
|
@ -136,3 +139,11 @@ class nsWindow : public nsBaseWidget {
|
|||
|
||||
nsCOMPtr<nsIWidget> mParent;
|
||||
};
|
||||
|
||||
class nsChildWindow : public nsWindow {
|
||||
public:
|
||||
nsChildWindow();
|
||||
~nsChildWindow();
|
||||
};
|
||||
|
||||
#endif /* __nsWindow_h__ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче