Kaydet (Commit) dd7a3147 authored tarafından Katarina Behrens's avatar Katarina Behrens Kaydeden (comit) Thorsten Behrens

kde5: copy basic kde4 blocks -> kde5 and build againt qt5/kf5 libs

Change-Id: I70f0c4147721a20459e1183ff40cf0ac8adf49e6
üst 07cd70c8
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kde5))
$(call gb_CustomTarget_get_target,vcl/unx/kde5) : \
$(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/KDE5XLib.moc \
$(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/tst_exclude_socket_notifiers.moc \
$(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/tst_exclude_posted_events.moc
$(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/%.moc : \
$(SRCDIR)/vcl/unx/kde5/%.hxx \
| $(call gb_CustomTarget_get_workdir,vcl/unx/kde5)/.dir
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),MOC,1)
$(MOC5) $< -o $@
# vim: set noet sw=4:
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
#
$(eval $(call gb_Library_Library,vclplug_kde5))
$(eval $(call gb_Library_use_custom_headers,vclplug_kde5,vcl/unx/kde5))
$(eval $(call gb_Library_set_include,vclplug_kde5,\
$$(INCLUDE) \
-I$(SRCDIR)/vcl/inc \
))
$(eval $(call gb_Library_add_defs,vclplug_kde5,\
-DVCLPLUG_KDE5_IMPLEMENTATION \
))
$(eval $(call gb_Library_use_sdk_api,vclplug_kde5))
$(eval $(call gb_Library_use_libraries,vclplug_kde5,\
vclplug_gen \
vcl \
tl \
utl \
sot \
ucbhelper \
basegfx \
comphelper \
cppuhelper \
i18nlangtag \
i18nutil \
$(if $(ENABLE_JAVA), \
jvmaccess) \
cppu \
sal \
))
$(eval $(call gb_Library_use_externals,vclplug_kde5,\
boost_headers \
icuuc \
kde5 \
epoxy \
))
$(eval $(call gb_Library_add_libs,vclplug_kde5,\
-lX11 \
-lXext \
-lSM \
-lICE \
))
ifneq ($(KF5_HAVE_GLIB),)
$(eval $(call gb_Library_add_defs,vclplug_kde5,\
$(KF5_GLIB_CFLAGS) \
))
$(eval $(call gb_Library_add_libs,vclplug_kde5,\
$(KF5_GLIB_LIBS) \
))
endif
$(eval $(call gb_Library_add_exception_objects,vclplug_kde5,\
vcl/unx/kde5/KDE5Data \
vcl/unx/kde5/KDE5SalDisplay \
vcl/unx/kde5/KDE5SalFrame \
vcl/unx/kde5/KDE5SalGraphics \
vcl/unx/kde5/KDE5SalInstance \
vcl/unx/kde5/KDE5XLib \
vcl/unx/kde5/main \
))
ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclplug_kde5,\
-lm \
-ldl \
-lpthread \
))
endif
# vim: set noet sw=4 ts=4:
......@@ -81,6 +81,12 @@ $(eval $(call gb_Module_add_targets,vcl,\
Library_vclplug_kde4 \
))
endif
ifneq ($(ENABLE_KDE5),)
$(eval $(call gb_Module_add_targets,vcl,\
CustomTarget_kde5_moc \
Library_vclplug_kde5 \
))
endif
endif
ifeq ($(OS),MACOSX)
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
// the service names
#define FILE_PICKER_SERVICE_NAME "com.sun.star.ui.dialogs.KDE4FilePicker"
// the implementation names
#define FILE_PICKER_IMPL_NAME "com.sun.star.ui.dialogs.KDE4FilePicker"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <QtWidgets/QStyle>
#include <QtWidgets/QApplication>
#undef Region
#include "KDE5Data.hxx"
#include "KDE5XLib.hxx"
#include "KDE5SalDisplay.hxx"
KDEData::~KDEData()
{
}
void KDEData::Init()
{
pXLib_ = new KDEXLib();
pXLib_->Init();
SetDisplay( SalKDEDisplay::self() );
}
void KDEData::initNWF()
{
ImplSVData *pSVData = ImplGetSVData();
// draw toolbars on separate lines
pSVData->maNWFData.mbDockingAreaSeparateTB = true;
// no borders for menu, theming does that
pSVData->maNWFData.mbFlatMenu = true;
// Qt theme engines may support a rollover menubar
pSVData->maNWFData.mbRolloverMenubar = true;
pSVData->maNWFData.mbNoFocusRects = true;
// Styled menus need additional space
QStyle *style = QApplication::style();
pSVData->maNWFData.mnMenuFormatBorderX =
style->pixelMetric( QStyle::PM_MenuPanelWidth ) +
style->pixelMetric( QStyle::PM_MenuHMargin );
pSVData->maNWFData.mnMenuFormatBorderY =
style->pixelMetric( QStyle::PM_MenuPanelWidth ) +
style->pixelMetric( QStyle::PM_MenuVMargin );
}
void KDEData::deInitNWF()
{
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <unx/saldisp.hxx>
#include <unx/saldata.hxx>
class KDEData : public X11SalData
{
public:
explicit KDEData( SalInstance *pInstance )
: X11SalData( SAL_DATA_KDE4, pInstance ) {}
virtual ~KDEData() override;
virtual void Init() override;
virtual void initNWF() override;
virtual void deInitNWF() override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include "VCLKDE5Application.hxx"
#include "KDE5SalDisplay.hxx"
#ifdef Bool
#undef Bool
#endif
#include "KDE5XLib.hxx"
#include <assert.h>
SalKDEDisplay* SalKDEDisplay::selfptr = nullptr;
SalKDEDisplay::SalKDEDisplay( Display* pDisp )
: SalX11Display( pDisp )
{
assert( selfptr == nullptr );
selfptr = this;
xim_protocol = XInternAtom( pDisp_, "_XIM_PROTOCOL", False );
}
SalKDEDisplay::~SalKDEDisplay()
{
// in case never a frame opened
static_cast<KDEXLib*>(GetXLib())->doStartup();
// clean up own members
doDestruct();
selfptr = nullptr;
// prevent SalDisplay from closing KApplication's display
pDisp_ = nullptr;
}
void SalKDEDisplay::Yield()
{
if( DispatchInternalEvent() )
return;
// Prevent blocking from Drag'n'Drop events, which may have already have processed the event
if (XEventsQueued( pDisp_, QueuedAfterReading ) == 0)
return;
DBG_ASSERT( static_cast<SalYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())->GetThreadId() ==
osl::Thread::getCurrentIdentifier(),
"will crash soon since solar mutex not locked in SalKDEDisplay::Yield" );
/*XEvent event;
XNextEvent( pDisp_, &event );
if( checkDirectInputEvent( &event ))
return;
qApp->x11ProcessEvent( &event );*/
}
// HACK: When using Qt event loop, input methods (japanese, etc.) will get broken because
// of XFilterEvent() getting called twice, once by Qt, once by LO (bnc#665112).
// This function is therefore called before any XEvent is passed to Qt event handling
// and if it is a keyboard event and no Qt widget is the active window (i.e. we are
// processing events for some LO window), then feed the event only to LO directly and skip Qt
// completely. Skipped events are KeyPress, KeyRelease and also _XIM_PROTOCOL client message
// (seems to be necessary too, hopefully there are not other internal XIM messages that
// would need this handling).
bool SalKDEDisplay::checkDirectInputEvent( xcb_generic_event_t* ev )
{
switch (ev->response_type & ~0x80)
{
case XCB_CLIENT_MESSAGE:
case XCB_KEY_PRESS:
case XCB_KEY_RELEASE:
if( QApplication::activeWindow() == nullptr )
{
// Dispatch(ev);
return true;
}
break;
}
return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <unx/saldisp.hxx>
#include <xcb/xcb.h>
#ifdef CursorShape
#undef CursorShape
#endif
class SalKDEDisplay : public SalX11Display
{
public:
explicit SalKDEDisplay( Display* pDisp );
virtual ~SalKDEDisplay() override;
static SalKDEDisplay* self();
virtual void Yield() override;
bool checkDirectInputEvent( xcb_generic_event_t* ev );
private:
Atom xim_protocol;
static SalKDEDisplay* selfptr;
};
inline SalKDEDisplay* SalKDEDisplay::self()
{
return selfptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <memory>
#include <unx/saldisp.hxx>
#include <unx/salframe.h>
#include <unx/salgdi.h>
class KDESalFrame : public X11SalFrame
{
private:
static const int nMaxGraphics = 2;
struct GraphicsHolder
{
std::unique_ptr<X11SalGraphics> pGraphics;
bool bInUse;
GraphicsHolder() : bInUse( false ) {}
};
GraphicsHolder m_aGraphics[ nMaxGraphics ];
public:
KDESalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle );
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics *pGraphics ) override;
virtual void updateGraphics( bool bClear ) override;
virtual void UpdateSettings( AllSettings& rSettings ) override;
virtual void Show( bool bVisible, bool bNoActivate = false ) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <memory>
#include <rtl/string.hxx>
#include <unx/saldisp.hxx>
#include <unx/salgdi.h>
#include <QtGui/QImage>
/**
* Handles native graphics requests and performs the needed drawing operations.
*/
class KDESalGraphics : public X11SalGraphics
{
public:
virtual bool IsNativeControlSupported( ControlType, ControlPart ) override;
virtual bool hitTestNativeControl( ControlType, ControlPart,
const tools::Rectangle&, const Point&, bool& ) override;
virtual bool drawNativeControl( ControlType, ControlPart, const tools::Rectangle&,
ControlState, const ImplControlValue&, const OUString& ) override;
virtual bool getNativeControlRegion( ControlType, ControlPart, const tools::Rectangle&,
ControlState, const ImplControlValue&,
const OUString&, tools::Rectangle&, tools::Rectangle& ) override;
private:
std::unique_ptr<QImage> m_image;
QRect lastPopupRect;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
//#include "KDE4FilePicker.hxx"
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QThread>
#include <QtGui/QClipboard>
#include <QtWidgets/QApplication>
#include <QtWidgets/QFrame>
#include <QtX11Extras/QX11Info>
#include "KDE5SalInstance.hxx"
#include "KDE5SalFrame.hxx"
#include "KDE5XLib.hxx"
#include "KDE5SalDisplay.hxx"
using namespace com::sun::star;
KDESalInstance::KDESalInstance(SalYieldMutex* pMutex)
: X11SalInstance(pMutex)
{
ImplSVData* pSVData = ImplGetSVData();
delete pSVData->maAppData.mpToolkitName;
pSVData->maAppData.mpToolkitName = new OUString("kde4");
}
SalFrame* KDESalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nState )
{
return new KDESalFrame( pParent, nState );
}
uno::Reference< ui::dialogs::XFilePicker2 > KDESalInstance::createFilePicker(
const uno::Reference< uno::XComponentContext >& xMSF )
{
/*KDEXLib* kdeXLib = static_cast<KDEXLib*>( mpXLib );
if (kdeXLib->allowKdeDialogs())
return uno::Reference< ui::dialogs::XFilePicker2 >(
kdeXLib->createFilePicker(xMSF) );
else*/
return X11SalInstance::createFilePicker( xMSF );
}
SalX11Display* KDESalInstance::CreateDisplay() const
{
return new SalKDEDisplay( QX11Info::display() );
}
bool KDESalInstance::IsMainThread() const
{
return qApp->thread() == QThread::currentThread();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <unx/salinst.h>
class SalYieldMutex;
class SalFrame;
class KDESalInstance : public X11SalInstance
{
protected:
virtual SalX11Display* CreateDisplay() const override;
public:
explicit KDESalInstance(SalYieldMutex* pMutex);
virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
virtual bool hasNativeFileSelection() const override { return true; }
virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePicker( const css::uno::Reference<
css::uno::XComponentContext >& ) override;
virtual bool IsMainThread() const override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <memory>
#include <unx/saldisp.hxx>
//#include <fixx11h.h>
//
#include <QtCore/QObject>
#include <QtCore/QHash>
#include <QtCore/QSocketNotifier>
#include <QtCore/QTimer>
#include <QtCore/QAbstractNativeEventFilter>
#include <unx/salinst.h>
class VCLKDEApplication;
class KDEXLib : public QObject, public QAbstractNativeEventFilter, public SalXLib
{
Q_OBJECT
private:
bool m_bStartupDone;
std::unique_ptr<VCLKDEApplication> m_pApplication;
std::unique_ptr<char*[]> m_pFreeCmdLineArgs;
std::unique_ptr<char*[]> m_pAppCmdLineArgs;
int m_nFakeCmdLineArgs;
struct SocketData
{
void* data;
YieldFunc pending;
YieldFunc queued;
YieldFunc handle;
QSocketNotifier* notifier;
};
QHash< int, SocketData > socketData; // key is fd
QTimer timeoutTimer;
bool m_isGlibEventLoopType;
bool m_allowKdeDialogs;
int m_timerEventId;
int m_postUserEventId;
private:
void setupEventLoop();
private Q_SLOTS:
void socketNotifierActivated( int fd );
void timeoutActivated();
void startTimeoutTimer();
static bool processYield( bool bWait, bool bHandleAllCurrentEvents );
Q_SIGNALS:
void startTimeoutTimerSignal();
void processYieldSignal( bool bWait, bool bHandleAllCurrentEvents );
css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePickerSignal( const css::uno::Reference< css::uno::XComponentContext >& );
public:
KDEXLib();
virtual ~KDEXLib() override;
virtual void Init() override;
virtual bool Yield( bool bWait, bool bHandleAllCurrentEvents ) override;
virtual void Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, YieldFunc handle ) override;
virtual void Remove( int fd ) override;
virtual void StartTimer( sal_uLong nMS ) override;
virtual void StopTimer() override;
virtual void Wakeup() override;
virtual void PostUserEvent() override;
void doStartup();
bool allowKdeDialogs() { return m_allowKdeDialogs; }
virtual void customEvent(QEvent* e) override;
public Q_SLOTS:
css::uno::Reference< css::ui::dialogs::XFilePicker2 >
createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& );
public:
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include "VCLKDE5Application.hxx"
#include <QtGui/QClipboard>
#include <QtCore/QEvent>
#include "KDE5SalDisplay.hxx"
VCLKDEApplication::VCLKDEApplication() :
KApplication()
{
}
// various hacks to be performed before re-entering Qt's event loop
// because of showing a Qt dialog
void VCLKDEApplication::preDialogSetup()
{
// KFileDialog integration requires using event loop with QClipboard.
// Opening the KDE file dialog here can lead to QClipboard
// asking for clipboard contents. If LO core is the owner of the clipboard
// content, without event loop use this will block for 5 seconds and timeout,
// since the clipboard thread will not be able to acquire SolarMutex
// and thus won't be able to respond. If the event loops
// are properly integrated and QClipboard can use a nested event loop
// (see the KDE VCL plug), then this won't happen.
// We cannot simply release SolarMutex here, because the event loop started
// by the file dialog would also call back to LO code.
assert( QApplication::clipboard()->property( "useEventLoopWhenWaiting" ).toBool() );
}
// various hacks to be performed after a Qt dialog has been closed
void VCLKDEApplication::postDialogCleanup()
{
// HACK: KFileDialog uses KConfig("kdeglobals") for saving some settings
// (such as the auto-extension flag), but that doesn't update KGlobal::config()
// (which is probably a KDE bug), so force reading the new configuration,
// otherwise the next opening of the dialog would use the old settings.
KGlobal::config()->reparseConfiguration();
// HACK: If Qt owns clipboard or selection, give up on their ownership now. Otherwise
// LO core might ask for the contents, but it would block while doing so (i.e. it
// doesn't seem to have an equivalent of QClipboard's "useEventLoopWhenWaiting"),
// therefore QClipboard wouldn't be able to respond, and whole LO would block until
// a timeout. Given that Klipper is most probably running, giving up clipboard/selection
// ownership will not only avoid the blocking, but even pasting that content in LO
// will in fact work, if Klipper can handle it.
// Technically proper solution would be of course to allow Qt to process QClipboard
// events while LO waits for clipboard contents, or short-circuit to QClipboard somehow
// (it's a mystery why LO's clipboard handling has its own thread when whole LO can
// get blocked by both trying to send and receive clipboard contents anyway).
QClipboard* clipboard = QApplication::clipboard();
if( clipboard->ownsSelection())
clipboard->clear( QClipboard::Selection );
if( clipboard->ownsClipboard())
clipboard->clear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _VCLKDE5APPLICATION_HXX_
#define _VCLKDE5APPLICATION_HXX_
#pragma once
#include <QtWidgets/QApplication>
#include <QtCore/QAbstractNativeEventFilter>
#undef Region
class VCLKDEApplication : public QApplication, public QAbstractNativeEventFilter
{
public:
VCLKDEApplication();
static void preDialogSetup();
static void postDialogCleanup();
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
#include <QtGui/QApplication>
#include "KDE5Data.hxx"
#include "KDE5SalInstance.hxx"
#include <vclpluginapi.h>
#include <rtl/string.hxx>
/// entry point for the KDE4 VCL plugin
extern "C" {
VCLPLUG_KDE4_PUBLIC SalInstance* create_SalInstance()
{
/* #i92121# workaround deadlocks in the X11 implementation
*/
static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
/* #i90094#
from now on we know that an X connection will be
established, so protect X against itself
*/
if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
{
#if QT_VERSION >= 0x040800
// let Qt call XInitThreads(), so that also Qt knows it's been used
// (otherwise QPixmap may warn about threads not being initialized)
QApplication::setAttribute( Qt::AA_X11InitThreads );
#else
XInitThreads();
// just in case somebody builds with old version and then upgrades Qt,
// otherwise this is a no-op
QApplication::setAttribute( static_cast< Qt::ApplicationAttribute >( 10 ));
#endif
}
#if QT_VERSION < 0x050000
// Qt 4.x support needs >= 4.1.0
OString aVersion( qVersion() );
SAL_INFO( "vcl.kde4", "qt version string is " << aVersion );
sal_Int32 nIndex = 0, nMajor = 0, nMinor = 0;
nMajor = aVersion.getToken( 0, '.', nIndex ).toInt32();
if( nIndex > 0 )
nMinor = aVersion.getToken( 0, '.', nIndex ).toInt32();
if( nMajor != 4 || nMinor < 1 )
{
#if OSL_DEBUG_LEVEL > 1
sal_Int32 nMicro = 0;
if( nIndex > 0 )
nMicro = aVersion.getToken( 0, '.', nIndex ).toInt32();
SAL_INFO( "vcl.kde4", "unsuitable qt version " << nMajor << "." << nMinor << "." << nMicro );
#endif
return nullptr;
}
#endif
KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
SAL_INFO( "vcl.kde4", "created KDESalInstance " << &pInstance );
// initialize SalData
KDEData *salData = new KDEData( pInstance );
salData->Init();
salData->initNWF();
pInstance->SetLib(salData->GetLib());
return pInstance;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*
* This code is based on the SocketEventsTester from the Qt4 test suite.
*/
#pragma once
#include <QtCore/QCoreApplication>
#include <QtCore/QEventLoop>
const QEvent::Type eventType = QEvent::User;
class TestExcludePostedEvents
: public QObject
{
Q_OBJECT
public:
TestExcludePostedEvents();
virtual bool event( QEvent* e ) override;
bool processed;
};
TestExcludePostedEvents::TestExcludePostedEvents()
: processed( false )
{
}
bool TestExcludePostedEvents::event( QEvent* e )
{
if( e->type() == eventType )
processed = true;
return QObject::event( e );
}
#define QVERIFY(a) \
if (!a) return 1;
static int tst_excludePostedEvents()
{
TestExcludePostedEvents test;
QCoreApplication::postEvent( &test, new QEvent( eventType ));
QEventLoop loop;
loop.processEvents(QEventLoop::ExcludeUserInputEvents
| QEventLoop::ExcludeSocketNotifiers
// | QEventLoop::WaitForMoreEvents
| QEventLoop::X11ExcludeTimers);
QVERIFY( !test.processed );
loop.processEvents();
QVERIFY( test.processed );
return 0;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*
* This code is based on the SocketEventsTester from the Qt4 test suite.
*/
#pragma once
#include <QtCore/QCoreApplication>
#include <QtCore/QEventLoop>
#include <QtCore/QSocketNotifier>
#include <unistd.h>
class TestExcludeSocketNotifiers
: public QObject
{
Q_OBJECT
public:
TestExcludeSocketNotifiers( const int* pipes );
virtual ~TestExcludeSocketNotifiers() override;
bool received;
public slots:
void slotReceived();
private:
const int* pipes;
};
TestExcludeSocketNotifiers::TestExcludeSocketNotifiers( const int* thePipes )
: received( false )
, pipes( thePipes )
{
}
TestExcludeSocketNotifiers::~TestExcludeSocketNotifiers()
{
close( pipes[ 0 ] );
close( pipes[ 1 ] );
}
void TestExcludeSocketNotifiers::slotReceived()
{
received = true;
}
#define QVERIFY(a) \
if (!a) return 1;
static int tst_processEventsExcludeSocket()
{
int pipes[ 2 ];
if( pipe( pipes ) < 0 )
return 1;
TestExcludeSocketNotifiers test( pipes );
QSocketNotifier notifier( pipes[ 0 ], QSocketNotifier::Read );
QObject::connect( &notifier, SIGNAL( activated( int )), &test, SLOT( slotReceived()));
char dummy = 'a';
if( 1 != write( pipes[ 1 ], &dummy, 1 ) )
return 1;
QEventLoop loop;
loop.processEvents( QEventLoop::ExcludeSocketNotifiers );
QVERIFY( !test.received );
loop.processEvents();
QVERIFY( test.received );
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment