Remove dead webshell xlib stuff. b=113970

This commit is contained in:
locka%iol.ie 2002-01-31 15:48:23 +00:00
parent 322bc226e0
commit abd4f7f73f
14 changed files with 0 additions and 1345 deletions

View File

@ -1 +0,0 @@
Makefile

View File

@ -1,38 +0,0 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifdef MOZ_ENABLE_GTK
DIRS += gtk
endif
ifdef MOZ_ENABLE_QT
DIRS += qt
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,3 +0,0 @@
Makefile
embed_xlib_into_gtk

View File

@ -1,48 +0,0 @@
#
# 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 Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = embed_xlib_into_gtk
CPPSRCS = \
nsEmbedXlibIntoGtk.cpp \
$(NULL)
LIBS = \
-lgkgfx \
$(NETLIB_LIBS) \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(JSJ_LIB) \
$(NSPR_LIBS) \
$(MOZ_GTK_LDFLAGS) -lxlibrgb \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_GTK_CFLAGS)

View File

@ -1,302 +0,0 @@
/* -*- 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 Communicator client 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):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* 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 <gtk/gtk.h>
/* oops. gdkx.h doesn't have extern "C" around it. */
extern "C" {
#include <gdk/gdkx.h>
}
#include "nsXPCOM.h"
#include "nsIServiceManager.h"
#include "nsReadableUtils.h"
#include "nsIEventQueueService.h"
#include "nsIXlibWindowService.h"
#include "nsIUnixToolkitService.h"
#include "nsIWebShell.h"
#include "nsIContentViewer.h"
#include "nsIComponentManager.h"
#include "nsIPref.h"
#include "xlibrgb.h"
static NS_DEFINE_IID(kIEventQueueServiceIID,
NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kEventQueueServiceCID,
NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kWindowServiceCID,
NS_XLIB_WINDOW_SERVICE_CID);
static NS_DEFINE_IID(kWindowServiceIID,
NS_XLIB_WINDOW_SERVICE_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
static GdkFilterReturn test_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p);
static void event_processor_callback(gpointer data,
gint source,
GdkInputCondition condition)
{
printf("event_processor_callback()\n");
nsIEventQueue *eventQueue = (nsIEventQueue*)data;
eventQueue->ProcessPendingEvents();
}
static void WindowCreateCallback(PRUint32 aID)
{
GdkWindow *window;
// import that into gdk
window = gdk_window_foreign_new((guint32)aID);
// attach it to a filter
gdk_window_add_filter(window, test_filter, NULL);
printf("window created\n");
}
static void WindowDestroyCallback(PRUint32 aID)
{
printf("window destroyed\n");
}
static nsXlibEventDispatcher gsEventDispatcher = nsnull;
static nsIXlibWindowService * gsWindowService = nsnull;
static nsIWebShell * sgWebShell = nsnull;
static nsIPref * sgPrefs = nsnull;
int main(int argc, char **argv)
{
GtkWidget * main_window = NULL;
gtk_init(&argc, &argv);
nsresult rv;
// init xlibrgb
// XXX this is a hack, will replace with a service RSN
xlib_rgb_init(GDK_DISPLAY(), DefaultScreenOfDisplay(GDK_DISPLAY()));
main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(main_window, 500, 500);
gtk_widget_realize(main_window);
NS_InitXPCOM2(nsnull, nsnull, nsnull);
//////////////////////////////////////////////////////////////////////
// Toolkit Service setup
//////////////////////////////////////////////////////////////////////
nsIUnixToolkitService * unixToolkitService = nsnull;
rv = nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
NS_GET_IID(nsIUnixToolkitService),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_FAILED(rv))
return 1;
// Force the toolkit into "xlib" mode regardless of MOZ_TOOLKIT
unixToolkitService->SetToolkitName("xlib");
NS_RELEASE(unixToolkitService);
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
printf("Creating event queue.\n");
nsIEventQueueService * eventQueueService = nsnull;
nsIEventQueue * eventQueue = nsnull;
// Create the Event Queue for the UI thread...
rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **)&eventQueueService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not obtain the event queue service.");
if (NS_FAILED(rv))
return 1;
rv = eventQueueService->CreateThreadEventQueue();
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not create the event queue for the the thread.");
if (NS_FAILED(rv))
return 1;
rv = eventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get the newly created thread event queue.\n");
if (NS_FAILED(rv))
return 1;
NS_RELEASE(eventQueueService);
rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&gsWindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service\n");
if (NS_FAILED(rv))
return 1;
gsWindowService->SetWindowCreateCallback(WindowCreateCallback);
gsWindowService->SetWindowDestroyCallback(WindowDestroyCallback);
gdk_input_add(eventQueue->GetEventQueueSelectFD(),
GDK_INPUT_READ,
event_processor_callback,
eventQueue);
gtk_widget_show(main_window);
rv = nsRepository::CreateInstance(kWebShellCID, nsnull,
kIWebShellIID,
(void**)&sgWebShell);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot create WebShell.\n");
if (NS_FAILED(rv))
return 1;
// XXX - fix me!
//sgWebShell->Init((nsNativeWidget *)GDK_WINDOW_XWINDOW(main_window->window),
// 0, 0,
//500, 500);
NS_ASSERTION(PR_FALSE, "Please fix this code.");
gsWindowService->GetEventDispatcher(&gsEventDispatcher);
rv = nsServiceManager::GetService(kPrefCID, kIPrefIID,
(nsISupports**)&sgPrefs);
if (NS_OK != rv) {
printf("failed to get prefs instance\n");
return rv;
}
sgPrefs->StartUp();
sgPrefs->ReadUserPrefs();
nsIContentViewer *content_viewer=nsnull;
// XXX fix me!
//rv = sgWebShell->GetContentViewer(&content_viewer);
NS_ASSERTION(PR_FALSE, "Please fix this code.");
if (NS_SUCCEEDED(rv) && content_viewer) {
content_viewer->Show();
NS_RELEASE(content_viewer);
}
// sgWebShell->Show();
// attach the size_allocate signal to the main window
gtk_signal_connect_after(GTK_OBJECT(main_window),
"size_allocate",
GTK_SIGNAL_FUNC(handle_size_allocate),
sgWebShell);
char *url = "http://www.mozilla.org/unix/xlib.html";
nsString URL(url);
PRUnichar *u_url = ToNewUnicode(URL);
// XXX fix me - what's the new API?
//sgWebShell->LoadURL(u_url);
gtk_main();
return 0;
}
static GdkFilterReturn test_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
printf("test_filter called\n");
XEvent *xevent;
xevent = (XEvent *)gdk_xevent;
(*gsEventDispatcher)((nsXlibNativeEvent) xevent);
// gsWindowService->DispatchNativeXlibEvent((void *)xevent);
return GDK_FILTER_REMOVE;
}
// this will pick up size changes in the main window and resize
// the web shell window accordingly
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p)
{
printf("handling size allocate\n");
nsIWebShell *moz_widget = (nsIWebShell *)p;
nsIContentViewer *content_viewer=nsnull;
nsresult rv=NS_OK;
// XXX - fix me!
// rv = moz_widget->GetContentViewer(&content_viewer);
NS_ASSERTION(PR_FALSE, "Please fix this code.");
if (NS_SUCCEEDED(rv) && content_viewer) {
nsRect bounds(0,0, alloc->width, alloc->height);
content_viewer->SetBounds(bounds);
NS_RELEASE(content_viewer);
}
}

View File

@ -1,2 +0,0 @@
Makefile
embed_xlib_into_qt

View File

@ -1,124 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#include <qapplication.h>
#include "MainWidget.h"
MainWidget::MainWidget()
{
setMinimumSize( 500, 500 );
m_load = new QPushButton( "Load", this, "Load" );
m_quit = new QPushButton( "Quit", this, "Quit" );
m_mozilla = new QMozillaContainer( this );
m_edit = new QLineEdit( this );
m_progressBar = NULL;
printf("done creating MainWidget parts...\n");
m_load->setGeometry( 10, 10, 50, 25 );
m_quit->setGeometry( 70, 10, 50, 25 );
m_mozilla->setGeometry( 0, 40, 500, 460 );
m_edit-> setGeometry( 130, 10, width() - 140, 25 );
printf("done setting MainWidget parts geometry...\n");
m_mozilla->setFocusPolicy( QWidget::StrongFocus );
m_mozilla->setMouseTracking( TRUE );
QObject::connect( m_load, SIGNAL(clicked()),
this, SLOT(handleLoad()));
QObject::connect( m_edit, SIGNAL(returnPressed()),
this, SLOT(handleReturnPressed()));
QObject::connect( m_mozilla, SIGNAL(urlLoadStarted()),
this, SLOT(handleURLLoadStarted()));
QObject::connect( m_mozilla, SIGNAL(urlLoadProgressed( const char *, int, int )),
this, SLOT(handleURLLoadProgressed( const char*, int, int )));
QObject::connect( m_mozilla, SIGNAL(urlLoadEnded()),
this, SLOT(handleURLLoadEnded()));
}
MainWidget::~MainWidget()
{
}
/* private slot */
void MainWidget::handleLoad()
{
m_mozilla->loadURL( m_edit->text() );
}
/* private slot */
void MainWidget::handleReturnPressed()
{
m_mozilla->loadURL( m_edit->text() );
}
/* private slot */
void MainWidget::handleURLLoadStarted()
{
printf("URL Load Started...\n");
QApplication::setOverrideCursor( waitCursor );
if ( !m_progressBar )
{
printf("Creating Progress Bar...\n");
m_progressBar = new QProgressBar( 100, m_mozilla );
}
else
printf("Using available Progress Bar...\n");
m_progressBar->setProgress( 0 );
m_progressBar->move( ( m_mozilla->width() - m_progressBar->width() ) / 2,
( m_mozilla->height() - m_progressBar->height() ) / 2
);
m_progressBar->show();
}
/* private slot */
void MainWidget::handleURLLoadProgressed( const char *url, int progress, int max )
{
printf("URL Load Progressed...\n");
m_progressBar->setProgress( progress / max * 100 );
}
/* private slot */
void MainWidget::handleURLLoadEnded()
{
printf("URL Load Ended...\n");
m_progressBar->hide();
QApplication::restoreOverrideCursor();
}
QWidget* MainWidget::getQuitWidget()
{
return m_quit;
}
void MainWidget::resizeEvent( QResizeEvent * )
{
m_mozilla->setGeometry( 0, 40, width(), height() - 40 );
m_edit->setGeometry( 130, 10, width() - 130, 25 );
}

View File

@ -1,58 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#ifndef MainWidget_h__
#define MainWidget_h__
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qprogressbar.h>
#include "QMozillaContainer.h"
class MainWidget : public QWidget
{
Q_OBJECT
public:
MainWidget();
~MainWidget();
QWidget* getQuitWidget();
void resizeEvent( QResizeEvent * );
private slots:
void handleLoad();
void handleReturnPressed();
void handleURLLoadStarted();
void handleURLLoadProgressed( const char* url, int progress, int max );
void handleURLLoadEnded();
private:
QPushButton *m_load;
QPushButton *m_quit;
QMozillaContainer *m_mozilla;
QLineEdit *m_edit;
QProgressBar *m_progressBar;
};
#endif // MainWidget_h__

View File

@ -1,60 +0,0 @@
#
# 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 Mozilla Communicator client code.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are Copyright (C) 1998
# Netscape Communications Corporation. All Rights Reserved.
#
# Contributor(s):
# Milind Changire <changire@yahoo.com>
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PROGRAM = embed_xlib_into_qt
MOCSRCS = \
moc_MainWidget.cpp \
moc_QMozillaContainer.cpp \
moc_nsQtEventProcessor.cpp \
$(NULL)
CPPSRCS = \
$(MOCSRCS) \
MainWidget.cpp \
QMozillaContainer.cpp \
nsEmbedXlibIntoQt.cpp \
nsQtEventProcessor.cpp \
$(NULL)
LIBS = \
-lgkgfx \
$(NETLIB_LIBS) \
$(MOZ_JS_LIBS) \
$(XPCOM_LIBS) \
$(JSJ_LIB) \
$(NSPR_LIBS) \
$(MOZ_QT_LDFLAGS) -lxlibrgb \
$(NULL)
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
INCLUDES += -I./

View File

@ -1,471 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "QMozillaContainer.h"
#include "nsQtEventProcessor.h"
#include "nsReadableUtils.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
#include "nsIXlibWindowService.h"
#include "nsIUnixToolkitService.h"
#include "nsIWebShell.h"
#include "nsIComponentManager.h"
#include "nsIPref.h"
#include "xlibrgb.h"
#include <stdio.h>
//-----------------------------------------------------------------------------
static NS_DEFINE_CID(kCUnixToolkitServiceCID, NS_UNIX_TOOLKIT_SERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kWindowServiceCID, NS_XLIB_WINDOW_SERVICE_CID);
static NS_DEFINE_IID(kWindowServiceIID, NS_XLIB_WINDOW_SERVICE_IID);
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kWebShellCID, NS_WEB_SHELL_CID);
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
// XXX ----------------------------------------------------------------
// XXX
// XXX QMozillaWidget is used to bind the windows created by Mozilla
// XXX with the Qt library.
// XXX Please refer to the Qt sources QXtWidget and QXtApplication
// XXX for further details
// XXX
class QMozillaWidget : public QWidget
{
public:
QMozillaWidget( WId wid, QWidget* parent = NULL ) : QWidget( parent, "QMozillaContainer" )
{
create( wid, FALSE, FALSE );
}
virtual ~QMozillaWidget()
{
}
virtual bool x11Event( XEvent* e )
{
(*gsEventDispatcher)((nsXlibNativeEvent) e );
return TRUE;
}
static nsXlibEventDispatcher gsEventDispatcher;
};
nsXlibEventDispatcher QMozillaWidget::gsEventDispatcher = nsnull;
//----------------------------------------------------------------
// XXX
// XXX QMozillaContainer methods
// XXX
QMozillaContainer::QMozillaContainer( QWidget* parent ) : QWidget( parent, "Container" )
{
NS_INIT_ISUPPORTS();
printf("calling init()\n");
if ( init() != 0 )
printf("MOZILLA CONTAINER WIDGET: !!! ERROR !!! in init()\n");
printf("done\n");
}
QMozillaContainer::~QMozillaContainer()
{
delete m_MozillaEventProcessor;
m_WebShell->SetContainer(nsnull);
NS_RELEASE(m_WebShell);
}
/* virtual */
void QMozillaContainer::focusInEvent ( QFocusEvent * )
{
m_WebShell->SetFocus();
}
/* virtual */
void QMozillaContainer::focusOutEvent ( QFocusEvent * )
{
m_WebShell->RemoveFocus();
}
/* virtual */
bool QMozillaContainer::x11Event( XEvent* xevent )
{
if ( xevent->type == ConfigureNotify )
//if ( xevent->type == ResizeRequest )
{
int changed = 0;
XConfigureEvent &xconfigure = xevent->xconfigure;
XResizeRequestEvent &xresize = xevent->xresizerequest;
//nsIWebShell *webshell = ( nsIWebShell* )data;
if ( xevent->type == ConfigureNotify )
{
//x = x != xconfigure.x ? changed = 1, xconfigure.x : x;
//y = y != xconfigure.y ? changed = 1, xconfigure.y : y;
m_width = m_width != xconfigure.width ? changed = 1, xconfigure.width : m_width;
m_height = m_height != xconfigure.height ? changed = 1, xconfigure.height : m_height;
}
else
{
//x = x != xresize.x ? changed = 1, xresize.x : x;
//y = y != xresize.y ? changed = 1, xresize.y : y;
m_width = m_width != xresize.width ? changed = 1, xresize.width : m_width;
m_height = m_height != xresize.height ? changed = 1, xresize.height : m_height;
}
if ( changed )
{
//printf("RESIZE...%p(%d, %d)\n", w, width, height);
m_WebShell->SetBounds( 0, 0, width(), height() ); changed = 0;
}
}
return TRUE;
}
/* public slot */
void QMozillaContainer::loadURL( const char *url )
{
if ( m_WebShell )
{
nsString URL(url);
PRUnichar *u_url = ToNewUnicode(URL);
m_WebShell->LoadURL(u_url);
}
}
/* public slot */
void QMozillaContainer::reload( QMozillaReloadType type = ReloadFromCache )
{
if ( m_WebShell )
m_WebShell->Reload( type );
}
/* public slot */
void QMozillaContainer::forward()
{
if ( m_WebShell && m_WebShell->CanForward() )
m_WebShell->Forward();
}
/* public slot */
void QMozillaContainer::back()
{
if ( m_WebShell && m_WebShell->CanBack() )
m_WebShell->Back();
}
/* public slot */
void QMozillaContainer::stop()
{
if ( m_WebShell )
m_WebShell->Stop();
}
//-----------------------------------------------------------------------------
static void WindowCreateCallback( PRUint32 aID )
{
// XXX Milind:
printf( "window created: %u\n", aID );
QWidget* qwidget = new QMozillaWidget( ( WId )aID );
qwidget->setMouseTracking( TRUE );
XSelectInput( qt_xdisplay(),
( Window )aID,
( ExposureMask |
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | ButtonMotionMask |
EnterWindowMask | LeaveWindowMask |
KeyPressMask | KeyReleaseMask |
StructureNotifyMask
)
);
}
static void WindowDestroyCallback(PRUint32 aID)
{
printf("window destroyed\n");
}
int QMozillaContainer::init()
{
// init xlibrgb
xlib_rgb_init( qt_xdisplay(), DefaultScreenOfDisplay( qt_xdisplay() ) );
//////////////////////////////////////////////////////////////////////
// Toolkit Service setup
//////////////////////////////////////////////////////////////////////
nsresult rv;
nsIUnixToolkitService * unixToolkitService = nsnull;
rv = nsComponentManager::CreateInstance(kCUnixToolkitServiceCID,
nsnull,
NS_GET_IID(nsIUnixToolkitService),
(void **) &unixToolkitService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot obtain unix toolkit service.");
if (NS_FAILED(rv))
return 1;
// Force the toolkit into "xlib" mode regardless of MOZ_TOOLKIT
unixToolkitService->SetToolkitName("xlib");
NS_RELEASE(unixToolkitService);
//////////////////////////////////////////////////////////////////////
// End toolkit service setup
//////////////////////////////////////////////////////////////////////
printf("Creating event queue.\n");
nsIEventQueueService * eventQueueService = nsnull;
nsIEventQueue * eventQueue = nsnull;
// Create the Event Queue for the UI thread...
rv = nsServiceManager::GetService(kEventQueueServiceCID,
kIEventQueueServiceIID,
(nsISupports **)&eventQueueService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not obtain the event queue service.");
if (NS_FAILED(rv))
return 1;
rv = eventQueueService->CreateThreadEventQueue();
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not create the event queue for the the thread.");
if (NS_FAILED(rv))
return 1;
rv = eventQueueService->GetThreadEventQueue(NS_CURRENT_THREAD, &eventQueue);
NS_ASSERTION(NS_SUCCEEDED(rv),"Could not get the newly created thread event queue.\n");
if (NS_FAILED(rv))
return 1;
NS_RELEASE(eventQueueService);
rv = nsServiceManager::GetService(kWindowServiceCID,
kWindowServiceIID,
(nsISupports **)&m_WindowService);
NS_ASSERTION(NS_SUCCEEDED(rv),"Couldn't obtain window service\n");
if (NS_FAILED(rv))
return 1;
m_WindowService->SetWindowCreateCallback(WindowCreateCallback);
m_WindowService->SetWindowDestroyCallback(WindowDestroyCallback);
printf("adding xlib event queue callback...\n");
m_MozillaEventProcessor = new nsQtEventProcessor( eventQueue, this );
printf("creating webshell...\n");
rv = nsRepository::CreateInstance(kWebShellCID,
nsnull,
kIWebShellIID,
(void**)&m_WebShell);
NS_ASSERTION(NS_SUCCEEDED(rv),"Cannot create WebShell.\n");
if (NS_FAILED(rv))
return 1;
printf("initializing webshell...\n");
m_WebShell->Init( ( nsNativeWidget )winId(), 0, 0, 500, 500);
m_WebShell->SetContainer( this );
m_WindowService->GetEventDispatcher(&QMozillaWidget::gsEventDispatcher);
rv = nsComponentManager::CreateInstance(kPrefCID,
NULL,
kIPrefIID,
(void **) &m_Prefs);
if (NS_OK != rv) {
printf("failed to get prefs instance\n");
return rv;
}
m_Prefs->StartUp();
m_Prefs->ReadUserPrefs();
m_WebShell->SetPrefs(m_Prefs);
printf("showing webshell...\n");
m_WebShell->Show();
return 0;
}
// helper fuction for BeginLoadURL, ProgressLoadURL, EndLoadURL
// XXX Dont forget to delete this 'C' String since we create it here
static char* makeCString( const PRUnichar* aString )
{
int len = 0;
const PRUnichar* ptr = aString;
while ( *ptr ) len++, ptr++;
char *cstring = new char[ ++len ];
// just cast down to a character
while ( len >= 0 )
{
cstring[len] = ( char )aString[len];
len--;
}
}
// nsIWebShellContainer methods
NS_IMPL_ISUPPORTS1(QMozillaContainer, nsIWebShellContainer)
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::WillLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsLoadType aReason)
{
char *url = makeCString( aURL );
printf("MOZILLA CONTAINER WIDGET: will load %s...\n", url);
delete url;
return NS_OK;
}
NS_METHOD QMozillaContainer::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL)
{
char *url = makeCString( aURL );
printf("MOXILLA CONTAINER WIDGET: loading %s...\n", url);
delete url;
emit urlLoadStarted();
return NS_OK;
}
NS_METHOD QMozillaContainer::ProgressLoadURL( nsIWebShell* aShell,
const PRUnichar* aURL,
PRInt32 aProgress,
PRInt32 aProgressMax)
{
char *url = makeCString( aURL );
emit urlLoadProgressed( (const char *)url, (int)aProgress, (int)aProgressMax );
delete url;
return NS_OK;
}
NS_METHOD QMozillaContainer::EndLoadURL(nsIWebShell* aShell,
const PRUnichar* aURL,
nsresult aStatus)
{
char *url = makeCString( aURL );
if ( aStatus != NS_OK )
printf("MOZILLA CONTAINER WIDGET: error loading %s...\n", url);
else
printf("MOXILLA CONTAINER WIDGET: done loading %s...\n", url);
delete url;
emit urlLoadEnded();
return NS_OK;
}
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::NewWebShell( PRUint32 aChromeMask,
PRBool aVisible,
nsIWebShell *&aNewWebShell)
{
return NS_OK;
}
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::ContentShellAdded(nsIWebShell* aChildShell,
nsIContent* frameNode)
{
return NS_OK;
}
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::CreatePopup( nsIDOMElement* aElement,
nsIDOMElement* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType,
const nsString& anAnchorAlignment,
const nsString& aPopupAlignment,
nsIDOMWindowInternal* aWindow,
nsIDOMWindowInternal** outPopup)
{
return NS_OK;
}
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::FindWebShellWithName(const PRUnichar* aName,
nsIWebShell*& aResult)
{
return NS_OK;
}
// XXX DO NOTHING: STUB METHOD FOR COMPLIANCE WITH nsIWebShellContainer
NS_METHOD QMozillaContainer::FocusAvailable(nsIWebShell* aFocusedWebShell,
PRBool& aFocusTaken)
{
return NS_OK;
}

View File

@ -1,100 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#ifndef QMozillaContainer_h__
#define QMozillaContainer_h__
#include <qobject.h>
#include <qwidget.h>
#include "nsIWebShell.h"
class nsQtEventProcessor;
class nsIXlibWindowService;
class nsIPref;
class QMozillaContainer : public QWidget, public nsIWebShellContainer
{
Q_OBJECT
public:
QMozillaContainer( QWidget* parentWidget = NULL );
virtual ~QMozillaContainer( );
typedef enum { ReloadFromCache = 0, ReloadBypassCache } QMozillaReloadType;
public slots:
void loadURL( const char *url );
void reload( QMozillaReloadType type = ReloadFromCache );
void forward();
void back();
void stop();
signals:
void urlLoadStarted();
void urlLoadProgressed( const char* url, int progressed, int max );
void urlLoadEnded();
protected:
virtual bool x11Event( XEvent* xevent );
virtual void focusInEvent ( QFocusEvent * );
virtual void focusOutEvent ( QFocusEvent * );
public:
// nsISupports: macro to support the nsI* mozilla interfaces
NS_DECL_ISUPPORTS
// nsIWebShellContainer methods
NS_IMETHOD WillLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsLoadType aReason);
NS_IMETHOD BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL);
NS_IMETHOD ProgressLoadURL( nsIWebShell* aShell, const PRUnichar* aURL,
PRInt32 aProgress, PRInt32 aProgressMax);
NS_IMETHOD EndLoadURL(nsIWebShell* aShell, const PRUnichar* aURL, nsresult aStatus);
NS_IMETHOD NewWebShell(PRUint32 aChromeMask, PRBool aVisible, nsIWebShell *&aNewWebShell);
NS_IMETHOD ContentShellAdded(nsIWebShell* aChildShell, nsIContent* frameNode);
NS_IMETHOD CreatePopup( nsIDOMElement* aElement, nsIDOMElement* aPopupContent,
PRInt32 aXPos, PRInt32 aYPos,
const nsString& aPopupType, const nsString& anAnchorAlignment,
const nsString& aPopupAlignment,
nsIDOMWindowInternal* aWindow, nsIDOMWindowInternal** outPopup);
NS_IMETHOD FindWebShellWithName(const PRUnichar* aName, nsIWebShell*& aResult);
NS_IMETHOD FocusAvailable(nsIWebShell* aFocusedWebShell, PRBool& aFocusTaken);
private: // DATA
int init();
int m_x, m_y, m_width, m_height; // webshell position and dimensions
nsQtEventProcessor *m_MozillaEventProcessor; // local class
nsIXlibWindowService *m_WindowService; // Mozilla class
nsIPref *m_Prefs; // Mozilla class
nsIWebShell *m_WebShell; // Mozilla class
};
#endif // QMozillaContainer_h__

View File

@ -1,46 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#include <qapplication.h>
#include "MainWidget.h"
int main( int argc, char** argv )
{
QApplication qapp( argc, argv );
MainWidget main_widget;
main_widget.setGeometry( 100, 100, 500, 500 );
printf("main(): done setting main_widget geometry\n");
QObject::connect(main_widget.getQuitWidget(), SIGNAL(clicked()), &qapp, SLOT(quit()));
printf("main(): done getting Quit widget and connecting to app quit()\n");
qapp.setMainWidget( &main_widget );
printf("main(): done setting main_widget to app\n");
main_widget.show();
qapp.exec();
return 0;
}

View File

@ -1,48 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#include <stdio.h>
#include "nsQtEventProcessor.h"
nsQtEventProcessor::nsQtEventProcessor( nsIEventQueue* eventQueue, QObject* parent )
: QSocketNotifier( eventQueue->GetEventQueueSelectFD(), QSocketNotifier::Read, parent ),
m_eventQueue( eventQueue )
{
printf("CONNETING SOCKET...\n");
connect(this, SIGNAL(activated(int)), SLOT(handleActivated(int)));
printf("DONE.\n");
}
nsQtEventProcessor::~nsQtEventProcessor( )
{
}
// private slot
void nsQtEventProcessor::handleActivated( int socket )
{
printf("nsQtEventProcessor::handleActivated( %d )\n", socket);
m_eventQueue->ProcessPendingEvents( );
}

View File

@ -1,44 +0,0 @@
/* -*- 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 Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributor(s):
* Milind Changire <changire@yahoo.com>
*/
#ifndef nsQtEventProcessor_h__
#define nsQtEventProcessor_h__
#include <qobject.h>
#include <qsocketnotifier.h>
#include "nsIEventQueue.h"
class nsQtEventProcessor : public QSocketNotifier
{
Q_OBJECT
public:
nsQtEventProcessor( nsIEventQueue* eventQueue, QObject* parent );
~nsQtEventProcessor( );
private slots:
void handleActivated( int socket );
nsIEventQueue* m_eventQueue;
};
#endif // nsQtEventProcessor_h__