1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "KDESalDisplay.hxx"
22 #include "KDEXLib.hxx"
23 #include "VCLKDEApplication.hxx"
26 #include <unx/saldata.hxx>
28 SalKDEDisplay
* SalKDEDisplay::selfptr
= NULL
;
30 SalKDEDisplay::SalKDEDisplay( Display
* pDisp
)
31 : SalX11Display( pDisp
)
33 assert( selfptr
== NULL
);
35 xim_protocol
= XInternAtom( pDisp_
, "_XIM_PROTOCOL", False
);
38 SalKDEDisplay::~SalKDEDisplay()
40 // in case never a frame opened
41 static_cast<KDEXLib
*>(GetXLib())->doStartup();
42 // clean up own members
45 // prevent SalDisplay from closing KApplication's display
49 void SalKDEDisplay::Yield()
51 if( DispatchInternalEvent() )
54 // Prevent blocking from Drag'n'Drop events, which may have already have processed the event
55 if (XEventsQueued( pDisp_
, QueuedAfterReading
) == 0)
58 DBG_ASSERT( static_cast<SalYieldMutex
*>(GetSalData()->m_pInstance
->GetYieldMutex())->GetThreadId() ==
59 osl::Thread::getCurrentIdentifier(),
60 "will crash soon since solar mutex not locked in SalKDEDisplay::Yield" );
63 XNextEvent( pDisp_
, &event
);
64 if( checkDirectInputEvent( &event
))
66 qApp
->x11ProcessEvent( &event
);
69 // HACK: When using Qt event loop, input methods (japanese, etc.) will get broken because
70 // of XFilterEvent() getting called twice, once by Qt, once by LO (bnc#665112).
71 // This function is therefore called before any XEvent is passed to Qt event handling
72 // and if it is a keyboard event and no Qt widget is the active window (i.e. we are
73 // processing events for some LO window), then feed the event only to LO directly and skip Qt
74 // completely. Skipped events are KeyPress, KeyRelease and also _XIM_PROTOCOL client message
75 // (seems to be necessary too, hopefully there are not other internal XIM messages that
76 // would need this handling).
77 bool SalKDEDisplay::checkDirectInputEvent( XEvent
* ev
)
79 if( ev
->xany
.type
== KeyPress
|| ev
->xany
.type
== KeyRelease
80 || ( ev
->xany
.type
== ClientMessage
&& ev
->xclient
.message_type
== xim_protocol
))
82 if( QApplication::activeWindow() == NULL
)
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */