Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <signal.h>
22 : #include <string.h>
23 : #include <stdio.h>
24 : #include <stdlib.h>
25 : #include <unistd.h>
26 :
27 : #include "tools/debug.hxx"
28 :
29 : #include "sal/alloca.h"
30 :
31 : #include "vcl/floatwin.hxx"
32 : #include "vcl/svapp.hxx"
33 : #include "vcl/keycodes.hxx"
34 : #include "vcl/printerinfomanager.hxx"
35 : #include "vcl/settings.hxx"
36 :
37 : #include <tools/prex.h>
38 : #include <X11/Xatom.h>
39 : #include <X11/keysym.h>
40 : #include "FWS.hxx"
41 : #include <X11/extensions/shape.h>
42 : #if !defined(SOLARIS) && !defined(AIX)
43 : #include <X11/extensions/dpms.h>
44 : #endif
45 : #include <tools/postx.h>
46 :
47 : #include "unx/salunx.h"
48 : #include "unx/saldata.hxx"
49 : #include "unx/saldisp.hxx"
50 : #include "unx/salgdi.h"
51 : #include "unx/salframe.h"
52 : #include "unx/soicon.hxx"
53 : #include "unx/sm.hxx"
54 : #include "unx/wmadaptor.hxx"
55 : #include "generic/genprn.h"
56 : #include "unx/salbmp.h"
57 : #include "unx/i18n_ic.hxx"
58 : #include "unx/i18n_keysym.hxx"
59 : #include "unx/i18n_status.hxx"
60 : #include <unx/x11/xlimits.hxx>
61 :
62 : #include "generic/gensys.h"
63 : #include "sallayout.hxx"
64 :
65 : #include <sal/macros.h>
66 : #include <com/sun/star/uno/Exception.hpp>
67 :
68 : #include <algorithm>
69 :
70 : #ifndef Button6
71 : # define Button6 6
72 : #endif
73 : #ifndef Button7
74 : # define Button7 7
75 : #endif
76 :
77 : using namespace vcl_sal;
78 : using namespace vcl;
79 :
80 : // -=-= #defines -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
81 : #define CLIENT_EVENTS StructureNotifyMask \
82 : | SubstructureNotifyMask \
83 : | KeyPressMask \
84 : | KeyReleaseMask \
85 : | ButtonPressMask \
86 : | ButtonReleaseMask \
87 : | PointerMotionMask \
88 : | EnterWindowMask \
89 : | LeaveWindowMask \
90 : | FocusChangeMask \
91 : | ExposureMask \
92 : | VisibilityChangeMask \
93 : | PropertyChangeMask \
94 : | ColormapChangeMask
95 :
96 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
97 :
98 : static XLIB_Window hPresentationWindow = None, hPresFocusWindow = None;
99 0 : static ::std::list< XLIB_Window > aPresentationReparentList;
100 : static int nVisibleFloats = 0;
101 :
102 : // -=-= C++ statics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
103 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
104 0 : static void doReparentPresentationDialogues( SalDisplay* pDisplay )
105 : {
106 0 : GetGenericData()->ErrorTrapPush();
107 0 : while( aPresentationReparentList.begin() != aPresentationReparentList.end() )
108 : {
109 : int x, y;
110 : XLIB_Window aRoot, aChild;
111 : unsigned int w, h, bw, d;
112 : XGetGeometry( pDisplay->GetDisplay(),
113 0 : aPresentationReparentList.front(),
114 : &aRoot,
115 0 : &x, &y, &w, &h, &bw, &d );
116 : XTranslateCoordinates( pDisplay->GetDisplay(),
117 : hPresentationWindow,
118 : aRoot,
119 : x, y,
120 : &x, &y,
121 0 : &aChild );
122 : XReparentWindow( pDisplay->GetDisplay(),
123 0 : aPresentationReparentList.front(),
124 : aRoot,
125 0 : x, y );
126 0 : aPresentationReparentList.pop_front();
127 : }
128 0 : if( hPresFocusWindow )
129 0 : XSetInputFocus( pDisplay->GetDisplay(), hPresFocusWindow, PointerRoot, CurrentTime );
130 0 : XSync( pDisplay->GetDisplay(), False );
131 0 : GetGenericData()->ErrorTrapPop();
132 0 : }
133 :
134 : // -=-= SalFrame / X11SalFrame =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
135 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
136 :
137 0 : bool X11SalFrame::IsOverrideRedirect() const
138 : {
139 : return
140 0 : ((nStyle_ & SAL_FRAME_STYLE_INTRO) && !pDisplay_->getWMAdaptor()->supportsSplash())
141 : ||
142 0 : (!( nStyle_ & ~SAL_FRAME_STYLE_DEFAULT ) && !pDisplay_->getWMAdaptor()->supportsFullScreen())
143 : ;
144 : }
145 :
146 0 : bool X11SalFrame::IsFloatGrabWindow() const
147 : {
148 0 : static const char* pDisableGrab = getenv( "SAL_DISABLE_FLOATGRAB" );
149 :
150 : return
151 0 : ( ( !pDisableGrab || !*pDisableGrab ) &&
152 : (
153 : (nStyle_ & SAL_FRAME_STYLE_FLOAT) &&
154 0 : ! (nStyle_ & SAL_FRAME_STYLE_TOOLTIP) &&
155 0 : ! (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION)
156 : )
157 0 : );
158 : }
159 :
160 0 : void X11SalFrame::setXEmbedInfo()
161 : {
162 0 : if( m_bXEmbed )
163 : {
164 : long aInfo[2];
165 0 : aInfo[0] = 1; // XEMBED protocol version
166 0 : aInfo[1] = (bMapped_ ? 1 : 0); // XEMBED_MAPPED
167 : XChangeProperty( pDisplay_->GetDisplay(),
168 : mhWindow,
169 : pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::XEMBED_INFO ),
170 : pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::XEMBED_INFO ),
171 : 32,
172 : PropModeReplace,
173 : reinterpret_cast<unsigned char*>(aInfo),
174 0 : SAL_N_ELEMENTS(aInfo) );
175 : }
176 0 : }
177 :
178 0 : void X11SalFrame::askForXEmbedFocus( sal_Int32 i_nTimeCode )
179 : {
180 : XEvent aEvent;
181 :
182 0 : memset( &aEvent, 0, sizeof(aEvent) );
183 0 : aEvent.xclient.window = mhForeignParent;
184 0 : aEvent.xclient.type = ClientMessage;
185 0 : aEvent.xclient.message_type = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::XEMBED );
186 0 : aEvent.xclient.format = 32;
187 0 : aEvent.xclient.data.l[0] = i_nTimeCode ? i_nTimeCode : CurrentTime;
188 0 : aEvent.xclient.data.l[1] = 3; // XEMBED_REQUEST_FOCUS
189 0 : aEvent.xclient.data.l[2] = 0;
190 0 : aEvent.xclient.data.l[3] = 0;
191 0 : aEvent.xclient.data.l[4] = 0;
192 :
193 0 : GetGenericData()->ErrorTrapPush();
194 : XSendEvent( pDisplay_->GetDisplay(),
195 : mhForeignParent,
196 0 : False, NoEventMask, &aEvent );
197 0 : XSync( pDisplay_->GetDisplay(), False );
198 0 : GetGenericData()->ErrorTrapPop();
199 0 : }
200 :
201 :
202 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
203 :
204 0 : void X11SalFrame::Init( sal_uLong nSalFrameStyle, SalX11Screen nXScreen, SystemParentData* pParentData, bool bUseGeometry )
205 : {
206 0 : if( nXScreen.getXScreen() >= GetDisplay()->GetXScreenCount() )
207 0 : nXScreen = GetDisplay()->GetDefaultXScreen();
208 0 : if( mpParent )
209 0 : nXScreen = mpParent->m_nXScreen;
210 :
211 0 : m_nXScreen = nXScreen;
212 0 : nStyle_ = nSalFrameStyle;
213 : XWMHints Hints;
214 0 : Hints.flags = InputHint;
215 0 : Hints.input = (nSalFrameStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) ? False : True;
216 :
217 0 : int x = 0, y = 0;
218 0 : unsigned int w = 500, h = 500;
219 : XSetWindowAttributes Attributes;
220 :
221 : int nAttrMask = CWBorderPixel
222 : | CWBackPixmap
223 : | CWColormap
224 : | CWOverrideRedirect
225 0 : | CWEventMask
226 : ;
227 0 : Attributes.border_pixel = 0;
228 0 : Attributes.background_pixmap = None;
229 0 : Attributes.colormap = GetDisplay()->GetColormap( m_nXScreen ).GetXColormap();
230 0 : Attributes.override_redirect = False;
231 0 : Attributes.event_mask = CLIENT_EVENTS;
232 :
233 0 : const SalVisual& rVis = GetDisplay()->GetVisual( m_nXScreen );
234 0 : XLIB_Window aFrameParent = pParentData ? pParentData->aWindow : GetDisplay()->GetRootWindow( m_nXScreen );
235 0 : XLIB_Window aClientLeader = None;
236 :
237 0 : if( bUseGeometry )
238 : {
239 0 : x = maGeometry.nX;
240 0 : y = maGeometry.nY;
241 0 : w = maGeometry.nWidth;
242 0 : h = maGeometry.nHeight;
243 : }
244 :
245 0 : if( (nSalFrameStyle & SAL_FRAME_STYLE_FLOAT) &&
246 0 : ! (nSalFrameStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION)
247 : )
248 : {
249 0 : if( nShowState_ == SHOWSTATE_UNKNOWN )
250 : {
251 0 : w = 10;
252 0 : h = 10;
253 : }
254 0 : Attributes.override_redirect = True;
255 : }
256 0 : else if( (nSalFrameStyle & SAL_FRAME_STYLE_SYSTEMCHILD ) )
257 : {
258 : DBG_ASSERT( mpParent, "SAL_FRAME_STYLE_SYSTEMCHILD window without parent" );
259 0 : if( mpParent )
260 : {
261 0 : aFrameParent = mpParent->mhWindow;
262 : // FIXME: since with SAL_FRAME_STYLE_SYSTEMCHILD
263 : // multiple X11SalFrame objects can have the same shell window
264 : // dispatching events in saldisp.cxx is unclear (the first frame)
265 : // wins. HTH this correctly is unclear yet
266 : // for the time being, treat set the shell window to own window
267 : // like for a normal frame
268 : // mhShellWindow = mpParent->GetShellWindow();
269 : }
270 : }
271 0 : else if( pParentData )
272 : {
273 : // plugin parent may be killed unexpectedly by plugging
274 : // process; start permanantly ignoring X errors ...
275 0 : GetGenericData()->ErrorTrapPush();
276 :
277 0 : nStyle_ |= SAL_FRAME_STYLE_PLUG;
278 0 : Attributes.override_redirect = True;
279 0 : if( pParentData->nSize >= sizeof(SystemParentData) )
280 0 : m_bXEmbed = pParentData->bXEmbedSupport;
281 :
282 : int x_ret, y_ret;
283 : unsigned int bw, d;
284 : XLIB_Window aRoot, aParent;
285 :
286 : XGetGeometry( GetXDisplay(), pParentData->aWindow,
287 0 : &aRoot, &x_ret, &y_ret, &w, &h, &bw, &d );
288 0 : mhForeignParent = pParentData->aWindow;
289 :
290 0 : mhShellWindow = aParent = mhForeignParent;
291 : XLIB_Window* pChildren;
292 : unsigned int nChildren;
293 0 : bool bBreak = false;
294 0 : do
295 : {
296 : XQueryTree( GetDisplay()->GetDisplay(), mhShellWindow,
297 0 : &aRoot, &aParent, &pChildren, &nChildren );
298 0 : XFree( pChildren );
299 0 : if( aParent != aRoot )
300 0 : mhShellWindow = aParent;
301 0 : int nCount = 0;
302 : Atom* pProps = XListProperties( GetDisplay()->GetDisplay(),
303 : mhShellWindow,
304 0 : &nCount );
305 0 : for( int i = 0; i < nCount && ! bBreak; ++i )
306 0 : bBreak = (pProps[i] == XA_WM_HINTS);
307 0 : if( pProps )
308 0 : XFree( pProps );
309 0 : } while( aParent != aRoot && ! bBreak );
310 :
311 : // check if this is really one of our own frames
312 : // do not change the input mask in that case
313 0 : const std::list< SalFrame* >& rFrames = GetDisplay()->getFrames();
314 0 : std::list< SalFrame* >::const_iterator it = rFrames.begin();
315 0 : while( it != rFrames.end() && mhForeignParent != static_cast<const X11SalFrame*>(*it)->GetWindow() )
316 0 : ++it;
317 :
318 0 : if( it == rFrames.end() )
319 : {
320 0 : XSelectInput( GetDisplay()->GetDisplay(), mhForeignParent, StructureNotifyMask | FocusChangeMask );
321 0 : XSelectInput( GetDisplay()->GetDisplay(), mhShellWindow, StructureNotifyMask | FocusChangeMask );
322 : }
323 : }
324 : else
325 : {
326 0 : if( ! bUseGeometry )
327 : {
328 0 : Size aScreenSize( GetDisplay()->getDataForScreen( m_nXScreen ).m_aSize );
329 0 : w = aScreenSize.Width();
330 0 : h = aScreenSize.Height();
331 0 : if( nSalFrameStyle & SAL_FRAME_STYLE_SIZEABLE &&
332 : nSalFrameStyle & SAL_FRAME_STYLE_MOVEABLE )
333 : {
334 : // fill in holy default values brought to us by product management
335 0 : if( aScreenSize.Width() >= 800 )
336 0 : w = 785;
337 0 : if( aScreenSize.Width() >= 1024 )
338 0 : w = 920;
339 0 : if( aScreenSize.Width() >= 1280 )
340 0 : w = 1050;
341 :
342 0 : if( aScreenSize.Height() >= 600 )
343 0 : h = 550;
344 0 : if( aScreenSize.Height() >= 768 )
345 0 : h = 630;
346 0 : if( aScreenSize.Height() >= 1024 )
347 0 : h = 875;
348 : }
349 0 : if( ! mpParent )
350 : {
351 : // find the last document window (if any)
352 0 : const X11SalFrame* pFrame = NULL;
353 0 : const std::list< SalFrame* >& rFrames = GetDisplay()->getFrames();
354 0 : std::list< SalFrame* >::const_iterator it = rFrames.begin();
355 0 : while( it != rFrames.end() )
356 : {
357 0 : pFrame = static_cast< const X11SalFrame* >(*it);
358 0 : if( ! ( pFrame->mpParent
359 : || pFrame->mbFullScreen
360 0 : || ! ( pFrame->nStyle_ & SAL_FRAME_STYLE_SIZEABLE )
361 0 : || ! pFrame->GetUnmirroredGeometry().nWidth
362 0 : || ! pFrame->GetUnmirroredGeometry().nHeight
363 0 : )
364 : )
365 0 : break;
366 0 : ++it;
367 : }
368 :
369 0 : if( it != rFrames.end() )
370 : {
371 : // set a document position and size
372 : // the first frame gets positioned by the window manager
373 0 : const SalFrameGeometry& rGeom( pFrame->GetUnmirroredGeometry() );
374 0 : x = rGeom.nX;
375 0 : y = rGeom.nY;
376 0 : if( x+(int)w+40 <= (int)aScreenSize.Width() &&
377 0 : y+(int)h+40 <= (int)aScreenSize.Height()
378 : )
379 : {
380 0 : y += 40;
381 0 : x += 40;
382 : }
383 : else
384 : {
385 0 : x = 10; // leave some space for decoration
386 0 : y = 20;
387 : }
388 : }
389 0 : else if( GetDisplay()->IsXinerama() )
390 : {
391 : // place frame on same screen as mouse pointer
392 : XLIB_Window aRoot, aChild;
393 0 : int root_x = 0, root_y = 0, lx, ly;
394 : unsigned int mask;
395 : XQueryPointer( GetXDisplay(),
396 : GetDisplay()->GetRootWindow( m_nXScreen ),
397 : &aRoot, &aChild,
398 0 : &root_x, &root_y, &lx, &ly, &mask );
399 0 : const std::vector< Rectangle >& rScreens = GetDisplay()->GetXineramaScreens();
400 0 : for( unsigned int i = 0; i < rScreens.size(); i++ )
401 0 : if( rScreens[i].IsInside( Point( root_x, root_y ) ) )
402 : {
403 0 : x = rScreens[i].Left();
404 0 : y = rScreens[i].Top();
405 0 : break;
406 : }
407 : }
408 : }
409 : }
410 0 : Attributes.win_gravity = pDisplay_->getWMAdaptor()->getInitWinGravity();
411 0 : nAttrMask |= CWWinGravity;
412 0 : if( mpParent )
413 : {
414 0 : Attributes.save_under = True;
415 0 : nAttrMask |= CWSaveUnder;
416 : }
417 0 : if( IsOverrideRedirect() )
418 0 : Attributes.override_redirect = True;
419 : // default icon
420 0 : if( (nStyle_ & SAL_FRAME_STYLE_INTRO) == 0 )
421 : {
422 0 : bool bOk=false;
423 : try
424 : {
425 : bOk=SelectAppIconPixmap( pDisplay_, m_nXScreen,
426 : mnIconID != 1 ? mnIconID :
427 : (mpParent ? mpParent->mnIconID : 1), 32,
428 0 : Hints.icon_pixmap, Hints.icon_mask );
429 : }
430 0 : catch( com::sun::star::uno::Exception& )
431 : {
432 : // can happen - no ucb during early startup
433 : }
434 0 : if( bOk )
435 : {
436 0 : Hints.flags |= IconPixmapHint;
437 0 : if( Hints.icon_mask )
438 0 : Hints.flags |= IconMaskHint;
439 : }
440 : }
441 :
442 : // find the top level frame of the transience hierarchy
443 0 : X11SalFrame* pFrame = this;
444 0 : while( pFrame->mpParent )
445 0 : pFrame = pFrame->mpParent;
446 0 : if( (pFrame->nStyle_ & SAL_FRAME_STYLE_PLUG ) )
447 : {
448 : // if the top level window is a plugin window,
449 : // then we should place us in the same window group as
450 : // the parent application (or none if there is no window group
451 : // hint in the parent).
452 0 : if( pFrame->GetShellWindow() )
453 : {
454 : XWMHints* pWMHints = XGetWMHints( pDisplay_->GetDisplay(),
455 0 : pFrame->GetShellWindow() );
456 0 : if( pWMHints )
457 : {
458 0 : if( (pWMHints->flags & WindowGroupHint) )
459 : {
460 0 : Hints.flags |= WindowGroupHint;
461 0 : Hints.window_group = pWMHints->window_group;
462 : }
463 0 : XFree( pWMHints );
464 : }
465 : }
466 : }
467 : else
468 : {
469 0 : Hints.flags |= WindowGroupHint;
470 0 : Hints.window_group = pFrame->GetShellWindow();
471 : // note: for a normal document window this will produce None
472 : // as the window is not yet created and the shell window is
473 : // initialized to None. This must be corrected after window creation.
474 0 : aClientLeader = GetDisplay()->GetDrawable( m_nXScreen );
475 : }
476 : }
477 :
478 0 : nShowState_ = SHOWSTATE_UNKNOWN;
479 0 : bViewable_ = sal_True;
480 0 : bMapped_ = sal_False;
481 0 : nVisibility_ = VisibilityFullyObscured;
482 : mhWindow = XCreateWindow( GetXDisplay(),
483 : aFrameParent,
484 : x, y,
485 : w, h,
486 : 0,
487 : rVis.GetDepth(),
488 : InputOutput,
489 : rVis.GetVisual(),
490 : nAttrMask,
491 0 : &Attributes );
492 : // FIXME: see above: fake shell window for now to own window
493 0 : if( pParentData == NULL )
494 : {
495 0 : mhShellWindow = mhWindow;
496 : }
497 :
498 : // correct window group if necessary
499 0 : if( (Hints.flags & WindowGroupHint) == WindowGroupHint )
500 : {
501 0 : if( Hints.window_group == None )
502 0 : Hints.window_group = GetShellWindow();
503 : }
504 :
505 0 : maGeometry.nX = x;
506 0 : maGeometry.nY = y;
507 0 : maGeometry.nWidth = w;
508 0 : maGeometry.nHeight = h;
509 0 : updateScreenNumber();
510 :
511 0 : XSync( GetXDisplay(), False );
512 0 : setXEmbedInfo();
513 :
514 : XLIB_Time nUserTime = (nStyle_ & (SAL_FRAME_STYLE_OWNERDRAWDECORATION | SAL_FRAME_STYLE_TOOLWINDOW) ) == 0 ?
515 0 : pDisplay_->GetLastUserEventTime() : 0;
516 0 : pDisplay_->getWMAdaptor()->setUserTime( this, nUserTime );
517 :
518 0 : if( ! pParentData && ! IsChildWindow() && ! Attributes.override_redirect )
519 : {
520 0 : XSetWMHints( GetXDisplay(), mhWindow, &Hints );
521 : // WM Protocols && internals
522 : Atom a[3];
523 0 : int n = 0;
524 0 : a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_DELETE_WINDOW );
525 0 : if( pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING ) )
526 0 : a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::NET_WM_PING );
527 0 : if( (nSalFrameStyle & SAL_FRAME_STYLE_OWNERDRAWDECORATION) )
528 0 : a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_TAKE_FOCUS );
529 0 : XSetWMProtocols( GetXDisplay(), GetShellWindow(), a, n );
530 :
531 : // force wm class hint
532 0 : mnExtStyle = ~0;
533 0 : if (mpParent)
534 0 : m_sWMClass = mpParent->m_sWMClass;
535 0 : SetExtendedFrameStyle( 0 );
536 :
537 0 : XSizeHints* pHints = XAllocSizeHints();
538 0 : pHints->flags = PWinGravity | PPosition;
539 0 : pHints->win_gravity = GetDisplay()->getWMAdaptor()->getPositionWinGravity();
540 0 : pHints->x = 0;
541 0 : pHints->y = 0;
542 0 : if( mbFullScreen )
543 : {
544 0 : pHints->flags |= PMaxSize | PMinSize;
545 0 : pHints->max_width = w+100;
546 0 : pHints->max_height = h+100;
547 0 : pHints->min_width = w;
548 0 : pHints->min_height = h;
549 : }
550 : XSetWMNormalHints( GetXDisplay(),
551 : GetShellWindow(),
552 0 : pHints );
553 0 : XFree (pHints);
554 :
555 : // set PID and WM_CLIENT_MACHINE
556 0 : pDisplay_->getWMAdaptor()->setClientMachine( this );
557 0 : pDisplay_->getWMAdaptor()->setPID( this );
558 :
559 : // set client leader
560 0 : if( aClientLeader )
561 : {
562 : XChangeProperty( GetXDisplay(),
563 : mhWindow,
564 : pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_CLIENT_LEADER),
565 : XA_WINDOW,
566 : 32,
567 : PropModeReplace,
568 : (unsigned char*)&aClientLeader,
569 : 1
570 0 : );
571 : }
572 : #define DECOFLAGS (SAL_FRAME_STYLE_MOVEABLE | SAL_FRAME_STYLE_SIZEABLE | SAL_FRAME_STYLE_CLOSEABLE)
573 0 : int nDecoFlags = WMAdaptor::decoration_All;
574 0 : if( (nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN) ||
575 : (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION)
576 : )
577 0 : nDecoFlags = 0;
578 0 : else if( (nStyle_ & DECOFLAGS ) != DECOFLAGS || (nStyle_ & SAL_FRAME_STYLE_TOOLWINDOW) )
579 : {
580 0 : if( nStyle_ & DECOFLAGS )
581 : // if any decoration, then show a border
582 0 : nDecoFlags = WMAdaptor::decoration_Border;
583 : else
584 0 : nDecoFlags = 0;
585 :
586 0 : if( ! mpParent && (nStyle_ & DECOFLAGS) )
587 : // don't add a min button if window should be decorationless
588 0 : nDecoFlags |= WMAdaptor::decoration_MinimizeBtn;
589 0 : if( nStyle_ & SAL_FRAME_STYLE_CLOSEABLE )
590 0 : nDecoFlags |= WMAdaptor::decoration_CloseBtn;
591 0 : if( nStyle_ & SAL_FRAME_STYLE_SIZEABLE )
592 : {
593 0 : nDecoFlags |= WMAdaptor::decoration_Resize;
594 0 : if( ! (nStyle_ & SAL_FRAME_STYLE_TOOLWINDOW) )
595 0 : nDecoFlags |= WMAdaptor::decoration_MaximizeBtn;
596 : }
597 0 : if( nStyle_ & SAL_FRAME_STYLE_MOVEABLE )
598 0 : nDecoFlags |= WMAdaptor::decoration_Title;
599 : }
600 :
601 0 : WMAdaptor::WMWindowType eType = WMAdaptor::windowType_Normal;
602 0 : if( nStyle_ & SAL_FRAME_STYLE_INTRO )
603 0 : eType = WMAdaptor::windowType_Splash;
604 0 : if( (nStyle_ & SAL_FRAME_STYLE_DIALOG) && hPresentationWindow == None )
605 0 : eType = WMAdaptor::windowType_ModelessDialogue;
606 0 : if( nStyle_ & SAL_FRAME_STYLE_TOOLWINDOW )
607 0 : eType = WMAdaptor::windowType_Utility;
608 0 : if( nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION )
609 0 : eType = WMAdaptor::windowType_Toolbar;
610 0 : if( (nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN)
611 0 : && GetDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
612 0 : eType = WMAdaptor::windowType_Dock;
613 :
614 0 : GetDisplay()->getWMAdaptor()->
615 : setFrameTypeAndDecoration( this,
616 : eType,
617 : nDecoFlags,
618 0 : hPresentationWindow ? NULL : mpParent );
619 :
620 0 : if( (nStyle_ & (SAL_FRAME_STYLE_DEFAULT |
621 : SAL_FRAME_STYLE_OWNERDRAWDECORATION|
622 : SAL_FRAME_STYLE_FLOAT |
623 : SAL_FRAME_STYLE_INTRO |
624 : SAL_FRAME_STYLE_PARTIAL_FULLSCREEN) )
625 : == SAL_FRAME_STYLE_DEFAULT )
626 0 : pDisplay_->getWMAdaptor()->maximizeFrame( this, true, true );
627 : }
628 :
629 0 : m_nWorkArea = GetDisplay()->getWMAdaptor()->getCurrentWorkArea();
630 :
631 : // Pointer
632 0 : SetPointer( POINTER_ARROW );
633 0 : }
634 :
635 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
636 0 : X11SalFrame::X11SalFrame( SalFrame *pParent, sal_uLong nSalFrameStyle,
637 : SystemParentData* pSystemParent ) :
638 0 : m_nXScreen( 0 )
639 : {
640 0 : SalGenericData *pData = GetGenericData();
641 :
642 : // initialize frame geometry
643 0 : memset( &maGeometry, 0, sizeof(maGeometry) );
644 :
645 0 : mpParent = static_cast< X11SalFrame* >( pParent );
646 :
647 0 : mbTransientForRoot = false;
648 :
649 0 : pDisplay_ = pData->GetSalDisplay();
650 : // insert frame in framelist
651 0 : pDisplay_->registerFrame( this );
652 :
653 0 : mhWindow = None;
654 0 : mhShellWindow = None;
655 0 : mhStackingWindow = None;
656 0 : mhForeignParent = None;
657 0 : mhBackgroundPixmap = None;
658 0 : m_bSetFocusOnMap = false;
659 :
660 0 : pGraphics_ = NULL;
661 0 : pFreeGraphics_ = NULL;
662 :
663 0 : hCursor_ = None;
664 0 : nCaptured_ = 0;
665 :
666 0 : nReleaseTime_ = 0;
667 0 : nKeyCode_ = 0;
668 0 : nKeyState_ = 0;
669 0 : nCompose_ = -1;
670 0 : mbSendExtKeyModChange = false;
671 0 : mnExtKeyMod = 0;
672 :
673 0 : nShowState_ = SHOWSTATE_UNKNOWN;
674 0 : nWidth_ = 0;
675 0 : nHeight_ = 0;
676 0 : nStyle_ = 0;
677 0 : mnExtStyle = 0;
678 0 : bAlwaysOnTop_ = sal_False;
679 :
680 : // set bViewable_ to sal_True: hack GetClientSize to report something
681 : // different to 0/0 before first map
682 0 : bViewable_ = sal_True;
683 0 : bMapped_ = sal_False;
684 0 : bDefaultPosition_ = sal_True;
685 0 : nVisibility_ = VisibilityFullyObscured;
686 0 : m_nWorkArea = 0;
687 0 : mbInShow = sal_False;
688 0 : m_bXEmbed = false;
689 :
690 0 : nScreenSaversTimeout_ = 0;
691 :
692 0 : mpInputContext = NULL;
693 0 : mbInputFocus = False;
694 :
695 0 : maAlwaysOnTopRaiseTimer.SetTimeoutHdl( LINK( this, X11SalFrame, HandleAlwaysOnTopRaise ) );
696 0 : maAlwaysOnTopRaiseTimer.SetTimeout( 100 );
697 :
698 0 : meWindowType = WMAdaptor::windowType_Normal;
699 0 : mnDecorationFlags = WMAdaptor::decoration_All;
700 0 : mbMaximizedVert = false;
701 0 : mbMaximizedHorz = false;
702 0 : mbShaded = false;
703 0 : mbFullScreen = false;
704 :
705 0 : mnIconID = 1; // ICON_LO_DEFAULT
706 :
707 0 : m_pClipRectangles = NULL;
708 0 : m_nCurClipRect = 0;
709 0 : m_nMaxClipRect = 0;
710 :
711 0 : if( mpParent )
712 0 : mpParent->maChildren.push_back( this );
713 :
714 0 : Init( nSalFrameStyle, GetDisplay()->GetDefaultXScreen(), pSystemParent );
715 0 : }
716 :
717 0 : X11SalFrame::~X11SalFrame()
718 : {
719 0 : notifyDelete();
720 :
721 0 : if( m_pClipRectangles )
722 : {
723 0 : delete [] m_pClipRectangles;
724 0 : m_pClipRectangles = NULL;
725 0 : m_nCurClipRect = m_nMaxClipRect = 0;
726 : }
727 :
728 0 : if( mhBackgroundPixmap )
729 : {
730 0 : XSetWindowBackgroundPixmap( GetXDisplay(), GetWindow(), None );
731 0 : XFreePixmap( GetXDisplay(), mhBackgroundPixmap );
732 : }
733 :
734 0 : if( mhStackingWindow )
735 0 : aPresentationReparentList.remove( mhStackingWindow );
736 :
737 : // remove from parent's list
738 0 : if( mpParent )
739 0 : mpParent->maChildren.remove( this );
740 :
741 : // deregister on SalDisplay
742 0 : pDisplay_->deregisterFrame( this );
743 :
744 : // unselect all events, some may be still in the queue anyway
745 0 : if( ! IsSysChildWindow() )
746 0 : XSelectInput( GetXDisplay(), GetShellWindow(), 0 );
747 0 : XSelectInput( GetXDisplay(), GetWindow(), 0 );
748 :
749 0 : ShowFullScreen( sal_False, 0 );
750 :
751 0 : if( bMapped_ )
752 0 : Show( sal_False );
753 :
754 0 : if( mpInputContext )
755 : {
756 0 : mpInputContext->UnsetICFocus( this );
757 0 : mpInputContext->Unmap( this );
758 0 : delete mpInputContext;
759 : }
760 :
761 0 : if( GetWindow() == hPresentationWindow )
762 : {
763 0 : hPresentationWindow = None;
764 0 : doReparentPresentationDialogues( GetDisplay() );
765 : }
766 :
767 0 : if( pGraphics_ )
768 : {
769 0 : pGraphics_->DeInit();
770 0 : delete pGraphics_;
771 : }
772 :
773 0 : if( pFreeGraphics_ )
774 : {
775 0 : pFreeGraphics_->DeInit();
776 0 : delete pFreeGraphics_;
777 : }
778 :
779 :
780 0 : XDestroyWindow( GetXDisplay(), mhWindow );
781 :
782 : /*
783 : * check if there is only the status frame left
784 : * if so, free it
785 : */
786 0 : if( ! GetDisplay()->getFrames().empty() && I18NStatus::exists() )
787 : {
788 0 : SalFrame* pStatusFrame = I18NStatus::get().getStatusFrame();
789 0 : std::list< SalFrame* >::const_iterator sit = GetDisplay()->getFrames().begin();
790 0 : if( pStatusFrame
791 0 : && *sit == pStatusFrame
792 0 : && ++sit == GetDisplay()->getFrames().end() )
793 0 : vcl::I18NStatus::free();
794 : }
795 0 : }
796 :
797 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
798 :
799 0 : void X11SalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
800 : {
801 0 : if( nStyle != mnExtStyle && ! IsChildWindow() )
802 : {
803 0 : mnExtStyle = nStyle;
804 0 : updateWMClass();
805 : }
806 0 : }
807 :
808 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
809 :
810 0 : const SystemChildData* X11SalFrame::GetSystemData() const
811 : {
812 0 : X11SalFrame *pFrame = const_cast<X11SalFrame*>(this);
813 0 : pFrame->maSystemChildData.nSize = sizeof( SystemChildData );
814 0 : pFrame->maSystemChildData.pDisplay = GetXDisplay();
815 0 : pFrame->maSystemChildData.aWindow = pFrame->GetWindow();
816 0 : pFrame->maSystemChildData.pSalFrame = pFrame;
817 0 : pFrame->maSystemChildData.pWidget = NULL;
818 0 : pFrame->maSystemChildData.pVisual = GetDisplay()->GetVisual( m_nXScreen ).GetVisual();
819 0 : pFrame->maSystemChildData.nScreen = m_nXScreen.getXScreen();
820 0 : pFrame->maSystemChildData.nDepth = GetDisplay()->GetVisual( m_nXScreen ).GetDepth();
821 0 : pFrame->maSystemChildData.aColormap = GetDisplay()->GetColormap( m_nXScreen ).GetXColormap();
822 0 : pFrame->maSystemChildData.pAppContext = NULL;
823 0 : pFrame->maSystemChildData.aShellWindow = pFrame->GetShellWindow();
824 0 : pFrame->maSystemChildData.pShellWidget = NULL;
825 0 : return &maSystemChildData;
826 : }
827 :
828 0 : SalGraphics *X11SalFrame::GetGraphics()
829 : {
830 0 : if( pGraphics_ )
831 0 : return NULL;
832 :
833 0 : if( pFreeGraphics_ )
834 : {
835 0 : pGraphics_ = pFreeGraphics_;
836 0 : pFreeGraphics_ = NULL;
837 : }
838 : else
839 : {
840 0 : pGraphics_ = new X11SalGraphics();
841 0 : pGraphics_->Init( this, GetWindow(), m_nXScreen );
842 : }
843 :
844 0 : return pGraphics_;
845 : }
846 :
847 0 : void X11SalFrame::ReleaseGraphics( SalGraphics *pGraphics )
848 : {
849 : DBG_ASSERT( pGraphics == pGraphics_, "SalFrame::ReleaseGraphics pGraphics!=pGraphics_" );
850 :
851 0 : if( pGraphics != pGraphics_ )
852 0 : return;
853 :
854 0 : pFreeGraphics_ = pGraphics_;
855 0 : pGraphics_ = NULL;
856 : }
857 :
858 0 : void X11SalFrame::updateGraphics( bool bClear )
859 : {
860 0 : Drawable aDrawable = bClear ? None : GetWindow();
861 0 : if( pGraphics_ )
862 0 : pGraphics_->SetDrawable( aDrawable, m_nXScreen );
863 0 : if( pFreeGraphics_ )
864 0 : pFreeGraphics_->SetDrawable( aDrawable, m_nXScreen );
865 0 : }
866 :
867 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
868 :
869 0 : void X11SalFrame::Enable( sal_Bool /*bEnable*/ )
870 : {
871 : // NYI: enable/disable frame
872 0 : }
873 :
874 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
875 :
876 0 : void X11SalFrame::SetIcon( sal_uInt16 nIcon )
877 : {
878 0 : if ( ! IsChildWindow() )
879 : {
880 : // 0 == default icon -> #1
881 0 : if ( nIcon == 0 )
882 0 : nIcon = 1;
883 :
884 0 : mnIconID = nIcon;
885 :
886 0 : XIconSize *pIconSize = NULL;
887 0 : int nSizes = 0;
888 0 : int iconSize = 32;
889 0 : if ( XGetIconSizes( GetXDisplay(), GetDisplay()->GetRootWindow( m_nXScreen ), &pIconSize, &nSizes ) )
890 : {
891 : #if OSL_DEBUG_LEVEL > 1
892 : fprintf(stderr, "X11SalFrame::SetIcon(): found %d IconSizes:\n", nSizes);
893 : #endif
894 :
895 0 : const int ourLargestIconSize = 48;
896 :
897 : int i;
898 0 : for( i=0; i<nSizes; i++)
899 : {
900 : // select largest supported icon
901 :
902 : // Note: olwm/olvwm reports a huge max icon size of
903 : // 160x160 pixels; always choosing the max as the
904 : // preferred icon size is apparently wrong under olvwm
905 : // - so we keep the safe default |iconSize| when we see
906 : // unreasonable large max icon sizes (> twice of our
907 : // largest available icon) reported by XGetIconSizes.
908 0 : if( pIconSize[i].max_width > iconSize
909 0 : && pIconSize[i].max_width <= 2*ourLargestIconSize )
910 : {
911 0 : iconSize = pIconSize[i].max_width;
912 : }
913 0 : iconSize = pIconSize[i].max_width;
914 :
915 : #if OSL_DEBUG_LEVEL > 1
916 : fprintf(stderr, "min: %d, %d\nmax: %d, %d\ninc: %d, %d\n\n",
917 : pIconSize[i].min_width, pIconSize[i].min_height,
918 : pIconSize[i].max_width, pIconSize[i].max_height,
919 : pIconSize[i].width_inc, pIconSize[i].height_inc);
920 : #endif
921 : }
922 :
923 0 : XFree( pIconSize );
924 : }
925 : else
926 : {
927 0 : const String& rWM( pDisplay_->getWMAdaptor()->getWindowManagerName() );
928 0 : if( rWM.EqualsAscii( "KWin" ) ) // assume KDE is running
929 0 : iconSize = 48;
930 : static bool bGnomeIconSize = false;
931 : static bool bGnomeChecked = false;
932 0 : if( ! bGnomeChecked )
933 : {
934 0 : bGnomeChecked=true;
935 0 : int nCount = 0;
936 : Atom* pProps = XListProperties( GetXDisplay(),
937 : GetDisplay()->GetRootWindow( m_nXScreen ),
938 0 : &nCount );
939 0 : for( int i = 0; i < nCount && !bGnomeIconSize; i++ )
940 : {
941 0 : char* pName = XGetAtomName( GetXDisplay(), pProps[i] );
942 0 : if( !strcmp( pName, "GNOME_PANEL_DESKTOP_AREA" ) )
943 0 : bGnomeIconSize = true;
944 0 : if( pName )
945 0 : XFree( pName );
946 : }
947 0 : if( pProps )
948 0 : XFree( pProps );
949 : }
950 0 : if( bGnomeIconSize )
951 0 : iconSize = 48;
952 : }
953 :
954 : XWMHints Hints;
955 0 : Hints.flags = 0;
956 0 : XWMHints *pHints = XGetWMHints( GetXDisplay(), GetShellWindow() );
957 0 : if( pHints )
958 : {
959 0 : memcpy(&Hints, pHints, sizeof( XWMHints ));
960 0 : XFree( pHints );
961 : }
962 0 : pHints = &Hints;
963 :
964 : sal_Bool bOk = SelectAppIconPixmap( GetDisplay(), m_nXScreen,
965 : nIcon, iconSize,
966 0 : pHints->icon_pixmap, pHints->icon_mask );
967 0 : if ( !bOk )
968 : {
969 : // load default icon (0)
970 : bOk = SelectAppIconPixmap( GetDisplay(), m_nXScreen,
971 : 0, iconSize,
972 0 : pHints->icon_pixmap, pHints->icon_mask );
973 : }
974 0 : if( bOk )
975 : {
976 0 : pHints->flags |= IconPixmapHint;
977 0 : if( pHints->icon_mask )
978 0 : pHints->flags |= IconMaskHint;
979 :
980 0 : XSetWMHints( GetXDisplay(), GetShellWindow(), pHints );
981 : }
982 : }
983 0 : }
984 :
985 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
986 :
987 0 : void X11SalFrame::SetMaxClientSize( long nWidth, long nHeight )
988 : {
989 0 : if( ! IsChildWindow() )
990 : {
991 0 : if( GetShellWindow() && (nStyle_ & (SAL_FRAME_STYLE_FLOAT|SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) != SAL_FRAME_STYLE_FLOAT )
992 : {
993 0 : XSizeHints* pHints = XAllocSizeHints();
994 0 : long nSupplied = 0;
995 : XGetWMNormalHints( GetXDisplay(),
996 : GetShellWindow(),
997 : pHints,
998 : &nSupplied
999 0 : );
1000 0 : pHints->max_width = nWidth;
1001 0 : pHints->max_height = nHeight;
1002 0 : pHints->flags |= PMaxSize;
1003 : XSetWMNormalHints( GetXDisplay(),
1004 : GetShellWindow(),
1005 0 : pHints );
1006 0 : XFree( pHints );
1007 : }
1008 : }
1009 0 : }
1010 :
1011 0 : void X11SalFrame::SetMinClientSize( long nWidth, long nHeight )
1012 : {
1013 0 : if( ! IsChildWindow() )
1014 : {
1015 0 : if( GetShellWindow() && (nStyle_ & (SAL_FRAME_STYLE_FLOAT|SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) != SAL_FRAME_STYLE_FLOAT )
1016 : {
1017 0 : XSizeHints* pHints = XAllocSizeHints();
1018 0 : long nSupplied = 0;
1019 : XGetWMNormalHints( GetXDisplay(),
1020 : GetShellWindow(),
1021 : pHints,
1022 : &nSupplied
1023 0 : );
1024 0 : pHints->min_width = nWidth;
1025 0 : pHints->min_height = nHeight;
1026 0 : pHints->flags |= PMinSize;
1027 : XSetWMNormalHints( GetXDisplay(),
1028 : GetShellWindow(),
1029 0 : pHints );
1030 0 : XFree( pHints );
1031 : }
1032 : }
1033 0 : }
1034 :
1035 : // Show + Pos (x,y,z) + Size (width,height)
1036 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1037 0 : void X11SalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
1038 : {
1039 0 : if( ( bVisible && bMapped_ )
1040 0 : || ( !bVisible && !bMapped_ ) )
1041 0 : return;
1042 :
1043 : // HACK: this is a workaround for (at least) kwin
1044 : // even though transient frames should be kept above their parent
1045 : // this does not necessarily hold true for DOCK type windows
1046 : // so artificially set ABOVE and remove it again on hide
1047 0 : if( mpParent && (mpParent->nStyle_ & SAL_FRAME_STYLE_PARTIAL_FULLSCREEN ) && pDisplay_->getWMAdaptor()->isLegacyPartialFullscreen())
1048 0 : pDisplay_->getWMAdaptor()->enableAlwaysOnTop( this, bVisible );
1049 :
1050 0 : bMapped_ = bVisible;
1051 0 : bViewable_ = bVisible;
1052 0 : setXEmbedInfo();
1053 0 : if( bVisible )
1054 : {
1055 0 : mbInShow = sal_True;
1056 0 : if( ! (nStyle_ & SAL_FRAME_STYLE_INTRO) )
1057 : {
1058 : // hide all INTRO frames
1059 0 : const std::list< SalFrame* >& rFrames = GetDisplay()->getFrames();
1060 0 : for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
1061 : {
1062 0 : const X11SalFrame* pFrame = static_cast< const X11SalFrame* >(*it);
1063 : // look for intro bit map; if present, hide it
1064 0 : if( pFrame->nStyle_ & SAL_FRAME_STYLE_INTRO )
1065 : {
1066 0 : if( pFrame->bMapped_ )
1067 0 : const_cast<X11SalFrame*>(pFrame)->Show( sal_False );
1068 : }
1069 : }
1070 : }
1071 :
1072 : // update NET_WM_STATE which may have been deleted due to earlier Show(sal_False)
1073 0 : if( nShowState_ == SHOWSTATE_HIDDEN )
1074 0 : GetDisplay()->getWMAdaptor()->frameIsMapping( this );
1075 :
1076 : /*
1077 : * Actually this is rather exotic and currently happens only in conjunction
1078 : * with the basic dialogue editor,
1079 : * which shows a frame and instantly hides it again. After that the
1080 : * editor window is shown and the WM takes this as an opportunity
1081 : * to show our hidden transient frame also. So Show( sal_False ) must
1082 : * withdraw the frame AND delete the WM_TRANSIENT_FOR property.
1083 : * In case the frame is shown again, the transient hint must be restored here.
1084 : */
1085 0 : if( ! IsChildWindow()
1086 0 : && ! IsOverrideRedirect()
1087 0 : && ! IsFloatGrabWindow()
1088 : && mpParent
1089 : )
1090 : {
1091 0 : GetDisplay()->getWMAdaptor()->changeReferenceFrame( this, mpParent );
1092 : }
1093 :
1094 : // #i45160# switch to desktop where a dialog with parent will appear
1095 0 : if( mpParent && mpParent->m_nWorkArea != m_nWorkArea )
1096 0 : GetDisplay()->getWMAdaptor()->switchToWorkArea( mpParent->m_nWorkArea );
1097 :
1098 0 : if( IsFloatGrabWindow() &&
1099 : mpParent &&
1100 : nVisibleFloats == 0 &&
1101 0 : ! GetDisplay()->GetCaptureFrame() )
1102 : {
1103 : /* #i39420#
1104 : * outsmart KWin's "focus strictly under mouse" mode
1105 : * which insists on taking the focus from the document
1106 : * to the new float. Grab focus to parent frame BEFORE
1107 : * showing the float (cannot grab it to the float
1108 : * before show).
1109 : */
1110 : XGrabPointer( GetXDisplay(),
1111 : mpParent->GetWindow(),
1112 : True,
1113 : PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
1114 : GrabModeAsync,
1115 : GrabModeAsync,
1116 : None,
1117 0 : mpParent ? mpParent->GetCursor() : None,
1118 : CurrentTime
1119 0 : );
1120 : }
1121 :
1122 0 : XLIB_Time nUserTime = 0;
1123 0 : if( ! bNoActivate && (nStyle_ & (SAL_FRAME_STYLE_OWNERDRAWDECORATION)) == 0 )
1124 0 : nUserTime = pDisplay_->GetLastUserEventTime( true );
1125 0 : GetDisplay()->getWMAdaptor()->setUserTime( this, nUserTime );
1126 0 : if( ! bNoActivate && (nStyle_ & SAL_FRAME_STYLE_TOOLWINDOW) )
1127 0 : m_bSetFocusOnMap = true;
1128 :
1129 : // actually map the window
1130 0 : if( m_bXEmbed )
1131 0 : askForXEmbedFocus( 0 );
1132 : else
1133 : {
1134 0 : if( GetWindow() != GetShellWindow() && ! IsSysChildWindow() )
1135 : {
1136 0 : if( IsChildWindow() )
1137 0 : XMapWindow( GetXDisplay(), GetShellWindow() );
1138 0 : XSelectInput( GetXDisplay(), GetShellWindow(), CLIENT_EVENTS );
1139 : }
1140 0 : if( nStyle_ & SAL_FRAME_STYLE_FLOAT )
1141 0 : XMapRaised( GetXDisplay(), GetWindow() );
1142 : else
1143 0 : XMapWindow( GetXDisplay(), GetWindow() );
1144 : }
1145 0 : XSelectInput( GetXDisplay(), GetWindow(), CLIENT_EVENTS );
1146 :
1147 0 : if( maGeometry.nWidth > 0
1148 : && maGeometry.nHeight > 0
1149 : && ( nWidth_ != (int)maGeometry.nWidth
1150 : || nHeight_ != (int)maGeometry.nHeight ) )
1151 : {
1152 0 : nWidth_ = maGeometry.nWidth;
1153 0 : nHeight_ = maGeometry.nHeight;
1154 : }
1155 :
1156 0 : XSync( GetXDisplay(), False );
1157 :
1158 0 : if( IsFloatGrabWindow() )
1159 : {
1160 : /*
1161 : * Sawfish and twm can be switched to enter-exit focus behaviour. In this case
1162 : * we must grab the pointer else the dumb WM will put the focus to the
1163 : * override-redirect float window. The application window will be deactivated
1164 : * which causes that the floats are destroyed, so the user can never click on
1165 : * a menu because it vanishes as soon as he enters it.
1166 : */
1167 0 : nVisibleFloats++;
1168 0 : if( nVisibleFloats == 1 && ! GetDisplay()->GetCaptureFrame() )
1169 : {
1170 : /* #i39420# now move grab to the new float window */
1171 : XGrabPointer( GetXDisplay(),
1172 : GetWindow(),
1173 : True,
1174 : PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
1175 : GrabModeAsync,
1176 : GrabModeAsync,
1177 : None,
1178 0 : mpParent ? mpParent->GetCursor() : None,
1179 : CurrentTime
1180 0 : );
1181 : }
1182 : }
1183 0 : CallCallback( SALEVENT_RESIZE, NULL );
1184 :
1185 : /*
1186 : * sometimes a message box/dialogue is brought up when a frame is not mapped
1187 : * the corresponding TRANSIENT_FOR hint is then set to the root window
1188 : * so that the dialogue shows in all cases. Correct it here if the
1189 : * frame is shown afterwards.
1190 : */
1191 0 : if( ! IsChildWindow()
1192 0 : && ! IsOverrideRedirect()
1193 0 : && ! IsFloatGrabWindow()
1194 : )
1195 : {
1196 0 : for( std::list< X11SalFrame* >::const_iterator it = maChildren.begin();
1197 0 : it != maChildren.end(); ++it )
1198 : {
1199 0 : if( (*it)->mbTransientForRoot )
1200 0 : GetDisplay()->getWMAdaptor()->changeReferenceFrame( *it, this );
1201 : }
1202 : }
1203 : /*
1204 : * leave SHOWSTATE_UNKNOWN as this indicates first mapping
1205 : * and is only reset int HandleSizeEvent
1206 : */
1207 0 : if( nShowState_ != SHOWSTATE_UNKNOWN )
1208 0 : nShowState_ = SHOWSTATE_NORMAL;
1209 :
1210 : /*
1211 : * plugged windows don't necessarily get the
1212 : * focus on show because the parent may already be mapped
1213 : * and have the focus. So try to set the focus
1214 : * to the child on Show(sal_True)
1215 : */
1216 0 : if( (nStyle_ & SAL_FRAME_STYLE_PLUG) && ! m_bXEmbed )
1217 : XSetInputFocus( GetXDisplay(),
1218 : GetWindow(),
1219 : RevertToParent,
1220 0 : CurrentTime );
1221 :
1222 0 : if( mpParent )
1223 : {
1224 : // push this frame so it will be in front of its siblings
1225 : // only necessary for insane transient behaviour of Dtwm/olwm
1226 0 : mpParent->maChildren.remove( this );
1227 0 : mpParent->maChildren.push_front(this);
1228 : }
1229 : }
1230 : else
1231 : {
1232 0 : if( getInputContext() )
1233 0 : getInputContext()->Unmap( this );
1234 :
1235 0 : if( ! IsChildWindow() )
1236 : {
1237 : /* FIXME: Is deleting the property really necessary ? It hurts
1238 : * owner drawn windows at least.
1239 : */
1240 0 : if( mpParent && ! (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION) )
1241 0 : XDeleteProperty( GetXDisplay(), GetShellWindow(), GetDisplay()->getWMAdaptor()->getAtom( WMAdaptor::WM_TRANSIENT_FOR ) );
1242 0 : XWithdrawWindow( GetXDisplay(), GetShellWindow(), m_nXScreen.getXScreen() );
1243 : }
1244 0 : else if( ! m_bXEmbed )
1245 0 : XUnmapWindow( GetXDisplay(), GetWindow() );
1246 :
1247 0 : nShowState_ = SHOWSTATE_HIDDEN;
1248 0 : if( IsFloatGrabWindow() && nVisibleFloats )
1249 : {
1250 0 : nVisibleFloats--;
1251 0 : if( nVisibleFloats == 0 && ! GetDisplay()->GetCaptureFrame() )
1252 : XUngrabPointer( GetXDisplay(),
1253 0 : CurrentTime );
1254 : }
1255 : // flush here; there may be a very seldom race between
1256 : // the display connection used for clipboard and our connection
1257 0 : Flush();
1258 : }
1259 : }
1260 :
1261 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1262 0 : void X11SalFrame::ToTop( sal_uInt16 nFlags )
1263 : {
1264 0 : if( ( nFlags & SAL_FRAME_TOTOP_RESTOREWHENMIN )
1265 0 : && ! ( nStyle_ & SAL_FRAME_STYLE_FLOAT )
1266 : && nShowState_ != SHOWSTATE_HIDDEN
1267 : && nShowState_ != SHOWSTATE_UNKNOWN
1268 : )
1269 : {
1270 0 : GetDisplay()->getWMAdaptor()->frameIsMapping( this );
1271 0 : if( GetWindow() != GetShellWindow() && ! IsSysChildWindow() )
1272 0 : XMapWindow( GetXDisplay(), GetShellWindow() );
1273 0 : XMapWindow( GetXDisplay(), GetWindow() );
1274 : }
1275 :
1276 0 : XLIB_Window aToTopWindow = IsSysChildWindow() ? GetWindow() : GetShellWindow();
1277 0 : if( ! (nFlags & SAL_FRAME_TOTOP_GRABFOCUS_ONLY) )
1278 : {
1279 0 : XRaiseWindow( GetXDisplay(), aToTopWindow );
1280 0 : if( ! GetDisplay()->getWMAdaptor()->isTransientBehaviourAsExpected() )
1281 0 : for( std::list< X11SalFrame* >::const_iterator it = maChildren.begin();
1282 0 : it != maChildren.end(); ++it )
1283 0 : (*it)->ToTop( nFlags & ~SAL_FRAME_TOTOP_GRABFOCUS );
1284 : }
1285 :
1286 0 : if( ( ( nFlags & SAL_FRAME_TOTOP_GRABFOCUS ) || ( nFlags & SAL_FRAME_TOTOP_GRABFOCUS_ONLY ) )
1287 : && bMapped_ )
1288 : {
1289 0 : if( m_bXEmbed )
1290 0 : askForXEmbedFocus( 0 );
1291 : else
1292 0 : XSetInputFocus( GetXDisplay(), aToTopWindow, RevertToParent, CurrentTime );
1293 : }
1294 0 : }
1295 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1296 0 : void X11SalFrame::GetWorkArea( Rectangle& rWorkArea )
1297 : {
1298 0 : rWorkArea = pDisplay_->getWMAdaptor()->getWorkArea( 0 );
1299 0 : }
1300 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1301 0 : void X11SalFrame::GetClientSize( long &rWidth, long &rHeight )
1302 : {
1303 0 : if( ! bViewable_ )
1304 : {
1305 0 : rWidth = rHeight = 0;
1306 0 : return;
1307 : }
1308 :
1309 0 : rWidth = maGeometry.nWidth;
1310 0 : rHeight = maGeometry.nHeight;
1311 :
1312 0 : if( !rWidth || !rHeight )
1313 : {
1314 : XWindowAttributes aAttrib;
1315 :
1316 0 : XGetWindowAttributes( GetXDisplay(), GetWindow(), &aAttrib );
1317 :
1318 0 : maGeometry.nWidth = rWidth = aAttrib.width;
1319 0 : maGeometry.nHeight = rHeight = aAttrib.height;
1320 : }
1321 : }
1322 :
1323 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1324 :
1325 0 : void X11SalFrame::Center( )
1326 : {
1327 : int nX, nY, nScreenWidth, nScreenHeight;
1328 : int nRealScreenWidth, nRealScreenHeight;
1329 0 : int nScreenX = 0, nScreenY = 0;
1330 :
1331 0 : const Size& aScreenSize = GetDisplay()->getDataForScreen( m_nXScreen ).m_aSize;
1332 0 : nScreenWidth = aScreenSize.Width();
1333 0 : nScreenHeight = aScreenSize.Height();
1334 0 : nRealScreenWidth = nScreenWidth;
1335 0 : nRealScreenHeight = nScreenHeight;
1336 :
1337 0 : if( GetDisplay()->IsXinerama() )
1338 : {
1339 : // get xinerama screen we are on
1340 : // if there is a parent, use its center for screen determination
1341 : // else use the pointer
1342 : XLIB_Window aRoot, aChild;
1343 : int root_x, root_y, x, y;
1344 : unsigned int mask;
1345 0 : if( mpParent )
1346 : {
1347 0 : root_x = mpParent->maGeometry.nX + mpParent->maGeometry.nWidth/2;
1348 0 : root_y = mpParent->maGeometry.nY + mpParent->maGeometry.nHeight/2;
1349 : }
1350 : else
1351 : XQueryPointer( GetXDisplay(),
1352 : GetShellWindow(),
1353 : &aRoot, &aChild,
1354 : &root_x, &root_y,
1355 : &x, &y,
1356 0 : &mask );
1357 0 : const std::vector< Rectangle >& rScreens = GetDisplay()->GetXineramaScreens();
1358 0 : for( unsigned int i = 0; i < rScreens.size(); i++ )
1359 0 : if( rScreens[i].IsInside( Point( root_x, root_y ) ) )
1360 : {
1361 0 : nScreenX = rScreens[i].Left();
1362 0 : nScreenY = rScreens[i].Top();
1363 0 : nRealScreenWidth = rScreens[i].GetWidth();
1364 0 : nRealScreenHeight = rScreens[i].GetHeight();
1365 0 : break;
1366 : }
1367 : }
1368 :
1369 0 : if( mpParent )
1370 : {
1371 0 : X11SalFrame* pFrame = mpParent;
1372 0 : while( pFrame->mpParent )
1373 0 : pFrame = pFrame->mpParent;
1374 0 : if( pFrame->maGeometry.nWidth < 1 || pFrame->maGeometry.nHeight < 1 )
1375 : {
1376 0 : Rectangle aRect;
1377 0 : pFrame->GetPosSize( aRect );
1378 0 : pFrame->maGeometry.nX = aRect.Left();
1379 0 : pFrame->maGeometry.nY = aRect.Top();
1380 0 : pFrame->maGeometry.nWidth = aRect.GetWidth();
1381 0 : pFrame->maGeometry.nHeight = aRect.GetHeight();
1382 : }
1383 :
1384 0 : if( pFrame->nStyle_ & SAL_FRAME_STYLE_PLUG )
1385 : {
1386 : XLIB_Window aRoot;
1387 : unsigned int bw, depth;
1388 : XGetGeometry( GetXDisplay(),
1389 : pFrame->GetShellWindow(),
1390 : &aRoot,
1391 : &nScreenX, &nScreenY,
1392 : (unsigned int*)&nScreenWidth,
1393 : (unsigned int*)&nScreenHeight,
1394 0 : &bw, &depth );
1395 : }
1396 : else
1397 : {
1398 0 : nScreenX = pFrame->maGeometry.nX;
1399 0 : nScreenY = pFrame->maGeometry.nY;
1400 0 : nScreenWidth = pFrame->maGeometry.nWidth;
1401 0 : nScreenHeight = pFrame->maGeometry.nHeight;
1402 : }
1403 : }
1404 :
1405 0 : if( mpParent && mpParent->nShowState_ == SHOWSTATE_NORMAL )
1406 : {
1407 0 : if( maGeometry.nWidth >= mpParent->maGeometry.nWidth &&
1408 : maGeometry.nHeight >= mpParent->maGeometry.nHeight )
1409 : {
1410 0 : nX = nScreenX + 40;
1411 0 : nY = nScreenY + 40;
1412 : }
1413 : else
1414 : {
1415 : // center the window relative to the top level frame
1416 0 : nX = (nScreenWidth - (int)maGeometry.nWidth ) / 2 + nScreenX;
1417 0 : nY = (nScreenHeight - (int)maGeometry.nHeight) / 2 + nScreenY;
1418 : }
1419 : }
1420 : else
1421 : {
1422 : // center the window relative to screen
1423 0 : nX = (nRealScreenWidth - (int)maGeometry.nWidth ) / 2 + nScreenX;
1424 0 : nY = (nRealScreenHeight - (int)maGeometry.nHeight) / 2 + nScreenY;
1425 : }
1426 0 : nX = nX < 0 ? 0 : nX;
1427 0 : nY = nY < 0 ? 0 : nY;
1428 :
1429 0 : bDefaultPosition_ = False;
1430 0 : if( mpParent )
1431 : {
1432 0 : nX -= mpParent->maGeometry.nX;
1433 0 : nY -= mpParent->maGeometry.nY;
1434 : }
1435 :
1436 0 : Point aPoint(nX, nY);
1437 0 : SetPosSize( Rectangle( aPoint, Size( maGeometry.nWidth, maGeometry.nHeight ) ) );
1438 0 : }
1439 :
1440 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1441 0 : void X11SalFrame::updateScreenNumber()
1442 : {
1443 0 : if( GetDisplay()->IsXinerama() && GetDisplay()->GetXineramaScreens().size() > 1 )
1444 : {
1445 0 : Point aPoint( maGeometry.nX, maGeometry.nY );
1446 0 : const std::vector<Rectangle>& rScreenRects( GetDisplay()->GetXineramaScreens() );
1447 0 : size_t nScreens = rScreenRects.size();
1448 0 : for( size_t i = 0; i < nScreens; i++ )
1449 : {
1450 0 : if( rScreenRects[i].IsInside( aPoint ) )
1451 : {
1452 0 : maGeometry.nDisplayScreenNumber = static_cast<unsigned int>(i);
1453 0 : break;
1454 : }
1455 : }
1456 : }
1457 : else
1458 0 : maGeometry.nDisplayScreenNumber = m_nXScreen.getXScreen();
1459 0 : }
1460 :
1461 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1462 0 : void X11SalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags )
1463 : {
1464 0 : if( nStyle_ & SAL_FRAME_STYLE_PLUG )
1465 0 : return;
1466 :
1467 : // relative positioning in X11SalFrame::SetPosSize
1468 0 : Rectangle aPosSize( Point( maGeometry.nX, maGeometry.nY ), Size( maGeometry.nWidth, maGeometry.nHeight ) );
1469 0 : aPosSize.Justify();
1470 :
1471 0 : if( ! ( nFlags & SAL_FRAME_POSSIZE_X ) )
1472 : {
1473 0 : nX = aPosSize.Left();
1474 0 : if( mpParent )
1475 0 : nX -= mpParent->maGeometry.nX;
1476 : }
1477 0 : if( ! ( nFlags & SAL_FRAME_POSSIZE_Y ) )
1478 : {
1479 0 : nY = aPosSize.Top();
1480 0 : if( mpParent )
1481 0 : nY -= mpParent->maGeometry.nY;
1482 : }
1483 0 : if( ! ( nFlags & SAL_FRAME_POSSIZE_WIDTH ) )
1484 0 : nWidth = aPosSize.GetWidth();
1485 0 : if( ! ( nFlags & SAL_FRAME_POSSIZE_HEIGHT ) )
1486 0 : nHeight = aPosSize.GetHeight();
1487 :
1488 0 : aPosSize = Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) );
1489 :
1490 0 : if( ! ( nFlags & ( SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y ) ) )
1491 : {
1492 0 : if( bDefaultPosition_ )
1493 : {
1494 0 : maGeometry.nWidth = aPosSize.GetWidth();
1495 0 : maGeometry.nHeight = aPosSize.GetHeight();
1496 0 : Center();
1497 : }
1498 : else
1499 0 : SetSize( Size( nWidth, nHeight ) );
1500 : }
1501 : else
1502 0 : SetPosSize( aPosSize );
1503 :
1504 0 : bDefaultPosition_ = False;
1505 : }
1506 :
1507 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1508 0 : void X11SalFrame::SetAlwaysOnTop( sal_Bool bOnTop )
1509 : {
1510 0 : if( ! IsOverrideRedirect() )
1511 : {
1512 0 : bAlwaysOnTop_ = bOnTop;
1513 0 : pDisplay_->getWMAdaptor()->enableAlwaysOnTop( this, bOnTop );
1514 : }
1515 0 : }
1516 :
1517 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1518 :
1519 : #define _FRAMESTATE_MASK_GEOMETRY \
1520 : (SAL_FRAMESTATE_MASK_X | SAL_FRAMESTATE_MASK_Y | \
1521 : SAL_FRAMESTATE_MASK_WIDTH | SAL_FRAMESTATE_MASK_HEIGHT)
1522 : #define _FRAMESTATE_MASK_MAXIMIZED_GEOMETRY \
1523 : (SAL_FRAMESTATE_MASK_MAXIMIZED_X | SAL_FRAMESTATE_MASK_MAXIMIZED_Y | \
1524 : SAL_FRAMESTATE_MASK_MAXIMIZED_WIDTH | SAL_FRAMESTATE_MASK_MAXIMIZED_HEIGHT)
1525 :
1526 0 : void X11SalFrame::SetWindowState( const SalFrameState *pState )
1527 : {
1528 0 : if (pState == NULL)
1529 0 : return;
1530 :
1531 : // Request for position or size change
1532 0 : if (pState->mnMask & _FRAMESTATE_MASK_GEOMETRY)
1533 : {
1534 0 : Rectangle aPosSize;
1535 0 : bool bDoAdjust = false;
1536 :
1537 : /* #i44325#
1538 : * if maximized, set restore size and guess maximized size from last time
1539 : * in state change below maximize window
1540 : */
1541 0 : if( ! IsChildWindow() &&
1542 : (pState->mnMask & SAL_FRAMESTATE_MASK_STATE) &&
1543 : (pState->mnState & SAL_FRAMESTATE_MAXIMIZED) &&
1544 : (pState->mnMask & _FRAMESTATE_MASK_GEOMETRY) == _FRAMESTATE_MASK_GEOMETRY &&
1545 : (pState->mnMask & _FRAMESTATE_MASK_MAXIMIZED_GEOMETRY) == _FRAMESTATE_MASK_MAXIMIZED_GEOMETRY
1546 : )
1547 : {
1548 0 : XSizeHints* pHints = XAllocSizeHints();
1549 0 : long nSupplied = 0;
1550 : XGetWMNormalHints( GetXDisplay(),
1551 : GetShellWindow(),
1552 : pHints,
1553 0 : &nSupplied );
1554 0 : pHints->flags |= PPosition | PWinGravity;
1555 0 : pHints->x = pState->mnX;
1556 0 : pHints->y = pState->mnY;
1557 0 : pHints->win_gravity = pDisplay_->getWMAdaptor()->getPositionWinGravity();
1558 : XSetWMNormalHints( GetXDisplay(),
1559 : GetShellWindow(),
1560 0 : pHints );
1561 0 : XFree( pHints );
1562 :
1563 : XMoveResizeWindow( GetXDisplay(), GetShellWindow(),
1564 : pState->mnX, pState->mnY,
1565 0 : pState->mnWidth, pState->mnHeight );
1566 : // guess maximized geometry from last time
1567 0 : maGeometry.nX = pState->mnMaximizedX;
1568 0 : maGeometry.nY = pState->mnMaximizedY;
1569 0 : maGeometry.nWidth = pState->mnMaximizedWidth;
1570 0 : maGeometry.nHeight = pState->mnMaximizedHeight;
1571 0 : updateScreenNumber();
1572 : }
1573 : else
1574 : {
1575 : // initialize with current geometry
1576 0 : if ((pState->mnMask & _FRAMESTATE_MASK_GEOMETRY) != _FRAMESTATE_MASK_GEOMETRY)
1577 0 : GetPosSize (aPosSize);
1578 :
1579 : // change requested properties
1580 0 : if (pState->mnMask & SAL_FRAMESTATE_MASK_X)
1581 : {
1582 0 : aPosSize.setX (pState->mnX);
1583 : }
1584 0 : if (pState->mnMask & SAL_FRAMESTATE_MASK_Y)
1585 : {
1586 0 : aPosSize.setY (pState->mnY);
1587 : }
1588 0 : if (pState->mnMask & SAL_FRAMESTATE_MASK_WIDTH)
1589 : {
1590 0 : long nWidth = pState->mnWidth > 0 ? pState->mnWidth - 1 : 0;
1591 0 : aPosSize.setWidth (nWidth);
1592 0 : bDoAdjust = true;
1593 : }
1594 0 : if (pState->mnMask & SAL_FRAMESTATE_MASK_HEIGHT)
1595 : {
1596 0 : int nHeight = pState->mnHeight > 0 ? pState->mnHeight - 1 : 0;
1597 0 : aPosSize.setHeight (nHeight);
1598 0 : bDoAdjust = true;
1599 : }
1600 :
1601 0 : const Size& aScreenSize = pDisplay_->getDataForScreen( m_nXScreen ).m_aSize;
1602 :
1603 0 : if( bDoAdjust && aPosSize.GetWidth() <= aScreenSize.Width()
1604 0 : && aPosSize.GetHeight() <= aScreenSize.Height() )
1605 : {
1606 0 : SalFrameGeometry aGeom = maGeometry;
1607 :
1608 0 : if( ! (nStyle_ & ( SAL_FRAME_STYLE_FLOAT | SAL_FRAME_STYLE_PLUG ) ) &&
1609 : mpParent &&
1610 : aGeom.nLeftDecoration == 0 &&
1611 : aGeom.nTopDecoration == 0 )
1612 : {
1613 0 : aGeom = mpParent->maGeometry;
1614 0 : if( aGeom.nLeftDecoration == 0 &&
1615 : aGeom.nTopDecoration == 0 )
1616 : {
1617 0 : aGeom.nLeftDecoration = 5;
1618 0 : aGeom.nTopDecoration = 20;
1619 0 : aGeom.nRightDecoration = 5;
1620 0 : aGeom.nBottomDecoration = 5;
1621 : }
1622 : }
1623 :
1624 : // adjust position so that frame fits onto screen
1625 0 : if( aPosSize.Right()+(long)aGeom.nRightDecoration > aScreenSize.Width()-1 )
1626 0 : aPosSize.Move( (long)aScreenSize.Width() - (long)aPosSize.Right() - (long)aGeom.nRightDecoration, 0 );
1627 0 : if( aPosSize.Bottom()+(long)aGeom.nBottomDecoration > aScreenSize.Height()-1 )
1628 0 : aPosSize.Move( 0, (long)aScreenSize.Height() - (long)aPosSize.Bottom() - (long)aGeom.nBottomDecoration );
1629 0 : if( aPosSize.Left() < (long)aGeom.nLeftDecoration )
1630 0 : aPosSize.Move( (long)aGeom.nLeftDecoration - (long)aPosSize.Left(), 0 );
1631 0 : if( aPosSize.Top() < (long)aGeom.nTopDecoration )
1632 0 : aPosSize.Move( 0, (long)aGeom.nTopDecoration - (long)aPosSize.Top() );
1633 : }
1634 :
1635 0 : SetPosSize( 0, 0, aPosSize.GetWidth(), aPosSize.GetHeight(), SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
1636 : }
1637 : }
1638 :
1639 : // request for status change
1640 0 : if (pState->mnMask & SAL_FRAMESTATE_MASK_STATE)
1641 : {
1642 0 : if (pState->mnState & SAL_FRAMESTATE_MAXIMIZED)
1643 : {
1644 0 : nShowState_ = SHOWSTATE_NORMAL;
1645 0 : if( ! (pState->mnState & (SAL_FRAMESTATE_MAXIMIZED_HORZ|SAL_FRAMESTATE_MAXIMIZED_VERT) ) )
1646 0 : Maximize();
1647 : else
1648 : {
1649 0 : bool bHorz = (pState->mnState & SAL_FRAMESTATE_MAXIMIZED_HORZ) ? true : false;
1650 0 : bool bVert = (pState->mnState & SAL_FRAMESTATE_MAXIMIZED_VERT) ? true : false;
1651 0 : GetDisplay()->getWMAdaptor()->maximizeFrame( this, bHorz, bVert );
1652 : }
1653 0 : maRestorePosSize.Left() = pState->mnX;
1654 0 : maRestorePosSize.Top() = pState->mnY;
1655 0 : maRestorePosSize.Right() = maRestorePosSize.Left() + pState->mnWidth;
1656 0 : maRestorePosSize.Right() = maRestorePosSize.Left() + pState->mnHeight;
1657 : }
1658 0 : else if( mbMaximizedHorz || mbMaximizedVert )
1659 0 : GetDisplay()->getWMAdaptor()->maximizeFrame( this, false, false );
1660 :
1661 0 : if (pState->mnState & SAL_FRAMESTATE_MINIMIZED)
1662 : {
1663 0 : if (nShowState_ == SHOWSTATE_UNKNOWN)
1664 0 : nShowState_ = SHOWSTATE_NORMAL;
1665 0 : Minimize();
1666 : }
1667 0 : if (pState->mnState & SAL_FRAMESTATE_NORMAL)
1668 : {
1669 0 : if (nShowState_ != SHOWSTATE_NORMAL)
1670 0 : Restore();
1671 : }
1672 0 : if (pState->mnState & SAL_FRAMESTATE_ROLLUP)
1673 0 : GetDisplay()->getWMAdaptor()->shade( this, true );
1674 : }
1675 : }
1676 :
1677 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1678 0 : sal_Bool X11SalFrame::GetWindowState( SalFrameState* pState )
1679 : {
1680 0 : if( SHOWSTATE_MINIMIZED == nShowState_ )
1681 0 : pState->mnState = SAL_FRAMESTATE_MINIMIZED;
1682 : else
1683 0 : pState->mnState = SAL_FRAMESTATE_NORMAL;
1684 :
1685 0 : Rectangle aPosSize;
1686 0 : if( maRestorePosSize.IsEmpty() )
1687 0 : GetPosSize( aPosSize );
1688 : else
1689 0 : aPosSize = maRestorePosSize;
1690 :
1691 0 : if( mbMaximizedHorz )
1692 0 : pState->mnState |= SAL_FRAMESTATE_MAXIMIZED_HORZ;
1693 0 : if( mbMaximizedVert )
1694 0 : pState->mnState |= SAL_FRAMESTATE_MAXIMIZED_VERT;
1695 0 : if( mbShaded )
1696 0 : pState->mnState |= SAL_FRAMESTATE_ROLLUP;
1697 :
1698 0 : pState->mnX = aPosSize.Left();
1699 0 : pState->mnY = aPosSize.Top();
1700 0 : pState->mnWidth = aPosSize.GetWidth();
1701 0 : pState->mnHeight = aPosSize.GetHeight();
1702 :
1703 0 : pState->mnMask = _FRAMESTATE_MASK_GEOMETRY | SAL_FRAMESTATE_MASK_STATE;
1704 :
1705 :
1706 0 : if (! maRestorePosSize.IsEmpty() )
1707 : {
1708 0 : GetPosSize( aPosSize );
1709 0 : pState->mnState |= SAL_FRAMESTATE_MAXIMIZED;
1710 0 : pState->mnMaximizedX = aPosSize.Left();
1711 0 : pState->mnMaximizedY = aPosSize.Top();
1712 0 : pState->mnMaximizedWidth = aPosSize.GetWidth();
1713 0 : pState->mnMaximizedHeight = aPosSize.GetHeight();
1714 0 : pState->mnMask |= _FRAMESTATE_MASK_MAXIMIZED_GEOMETRY;
1715 : }
1716 :
1717 0 : return sal_True;
1718 : }
1719 :
1720 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1721 :
1722 : // native menu implementation - currently empty
1723 0 : void X11SalFrame::DrawMenuBar()
1724 : {
1725 0 : }
1726 :
1727 0 : void X11SalFrame::SetMenu( SalMenu* )
1728 : {
1729 0 : }
1730 :
1731 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1732 0 : void X11SalFrame::GetPosSize( Rectangle &rPosSize )
1733 : {
1734 0 : if( maGeometry.nWidth < 1 || maGeometry.nHeight < 1 )
1735 : {
1736 0 : const Size& aScreenSize = pDisplay_->getDataForScreen( m_nXScreen ).m_aSize;
1737 0 : long w = aScreenSize.Width() - maGeometry.nLeftDecoration - maGeometry.nRightDecoration;
1738 0 : long h = aScreenSize.Height() - maGeometry.nTopDecoration - maGeometry.nBottomDecoration;
1739 :
1740 0 : rPosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ), Size( w, h ) );
1741 : }
1742 : else
1743 : rPosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ),
1744 0 : Size( maGeometry.nWidth, maGeometry.nHeight ) );
1745 0 : }
1746 :
1747 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1748 0 : void X11SalFrame::SetSize( const Size &rSize )
1749 : {
1750 0 : if( rSize.Width() > 0 && rSize.Height() > 0 )
1751 : {
1752 0 : if( ! ( nStyle_ & SAL_FRAME_STYLE_SIZEABLE )
1753 0 : && ! IsChildWindow()
1754 : && ( nStyle_ & (SAL_FRAME_STYLE_FLOAT|SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) != SAL_FRAME_STYLE_FLOAT )
1755 : {
1756 0 : XSizeHints* pHints = XAllocSizeHints();
1757 0 : long nSupplied = 0;
1758 : XGetWMNormalHints( GetXDisplay(),
1759 : GetShellWindow(),
1760 : pHints,
1761 : &nSupplied
1762 0 : );
1763 0 : pHints->min_width = rSize.Width();
1764 0 : pHints->min_height = rSize.Height();
1765 0 : pHints->max_width = rSize.Width();
1766 0 : pHints->max_height = rSize.Height();
1767 0 : pHints->flags |= PMinSize | PMaxSize;
1768 : XSetWMNormalHints( GetXDisplay(),
1769 : GetShellWindow(),
1770 0 : pHints );
1771 0 : XFree( pHints );
1772 : }
1773 0 : XResizeWindow( GetXDisplay(), IsSysChildWindow() ? GetWindow() : GetShellWindow(), rSize.Width(), rSize.Height() );
1774 0 : if( GetWindow() != GetShellWindow() )
1775 : {
1776 0 : if( (nStyle_ & SAL_FRAME_STYLE_PLUG ) )
1777 0 : XMoveResizeWindow( GetXDisplay(), GetWindow(), 0, 0, rSize.Width(), rSize.Height() );
1778 : else
1779 0 : XResizeWindow( GetXDisplay(), GetWindow(), rSize.Width(), rSize.Height() );
1780 : }
1781 :
1782 0 : maGeometry.nWidth = rSize.Width();
1783 0 : maGeometry.nHeight = rSize.Height();
1784 :
1785 : // allow the external status window to reposition
1786 0 : if (mbInputFocus && mpInputContext != NULL)
1787 0 : mpInputContext->SetICFocus ( this );
1788 : }
1789 0 : }
1790 :
1791 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1792 :
1793 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1794 :
1795 0 : void X11SalFrame::SetPosSize( const Rectangle &rPosSize )
1796 : {
1797 : XWindowChanges values;
1798 0 : values.x = rPosSize.Left();
1799 0 : values.y = rPosSize.Top();
1800 0 : values.width = rPosSize.GetWidth();
1801 0 : values.height = rPosSize.GetHeight();
1802 :
1803 0 : if( !values.width || !values.height )
1804 0 : return;
1805 :
1806 0 : if( mpParent && ! IsSysChildWindow() )
1807 : {
1808 : // --- RTL --- (mirror window pos)
1809 0 : if( Application::GetSettings().GetLayoutRTL() )
1810 0 : values.x = mpParent->maGeometry.nWidth-values.width-1-values.x;
1811 :
1812 : XLIB_Window aChild;
1813 : // coordinates are relative to parent, so translate to root coordinates
1814 : XTranslateCoordinates( GetDisplay()->GetDisplay(),
1815 : mpParent->GetWindow(),
1816 : GetDisplay()->GetRootWindow( m_nXScreen ),
1817 : values.x, values.y,
1818 : &values.x, &values.y,
1819 0 : & aChild );
1820 : }
1821 :
1822 0 : bool bMoved = false;
1823 0 : bool bSized = false;
1824 0 : if( values.x != maGeometry.nX || values.y != maGeometry.nY )
1825 0 : bMoved = true;
1826 0 : if( values.width != (int)maGeometry.nWidth || values.height != (int)maGeometry.nHeight )
1827 0 : bSized = true;
1828 :
1829 0 : if( ! ( nStyle_ & ( SAL_FRAME_STYLE_PLUG | SAL_FRAME_STYLE_FLOAT ) )
1830 0 : && !(pDisplay_->GetProperties() & PROPERTY_SUPPORT_WM_ClientPos) )
1831 : {
1832 0 : values.x -= maGeometry.nLeftDecoration;
1833 0 : values.y -= maGeometry.nTopDecoration;
1834 : }
1835 :
1836 : // do net set WMNormalHints for ..
1837 0 : if(
1838 : // child windows
1839 0 : ! IsChildWindow()
1840 : // popups (menu, help window, etc.)
1841 : && (nStyle_ & (SAL_FRAME_STYLE_FLOAT|SAL_FRAME_STYLE_OWNERDRAWDECORATION) ) != SAL_FRAME_STYLE_FLOAT
1842 : // shown, sizeable windows
1843 : && ( nShowState_ == SHOWSTATE_UNKNOWN ||
1844 : nShowState_ == SHOWSTATE_HIDDEN ||
1845 0 : ! ( nStyle_ & SAL_FRAME_STYLE_SIZEABLE )
1846 : )
1847 : )
1848 : {
1849 0 : XSizeHints* pHints = XAllocSizeHints();
1850 0 : long nSupplied = 0;
1851 : XGetWMNormalHints( GetXDisplay(),
1852 : GetShellWindow(),
1853 : pHints,
1854 : &nSupplied
1855 0 : );
1856 0 : if( ! ( nStyle_ & SAL_FRAME_STYLE_SIZEABLE ) )
1857 : {
1858 0 : pHints->min_width = rPosSize.GetWidth();
1859 0 : pHints->min_height = rPosSize.GetHeight();
1860 0 : pHints->max_width = rPosSize.GetWidth();
1861 0 : pHints->max_height = rPosSize.GetHeight();
1862 0 : pHints->flags |= PMinSize | PMaxSize;
1863 : }
1864 0 : if( nShowState_ == SHOWSTATE_UNKNOWN || nShowState_ == SHOWSTATE_HIDDEN )
1865 : {
1866 0 : pHints->flags |= PPosition | PWinGravity;
1867 0 : pHints->x = values.x;
1868 0 : pHints->y = values.y;
1869 0 : pHints->win_gravity = pDisplay_->getWMAdaptor()->getPositionWinGravity();
1870 : }
1871 0 : if( mbFullScreen )
1872 : {
1873 0 : pHints->max_width = 10000;
1874 0 : pHints->max_height = 10000;
1875 0 : pHints->flags |= PMaxSize;
1876 : }
1877 : XSetWMNormalHints( GetXDisplay(),
1878 : GetShellWindow(),
1879 0 : pHints );
1880 0 : XFree( pHints );
1881 : }
1882 :
1883 0 : XMoveResizeWindow( GetXDisplay(), IsSysChildWindow() ? GetWindow() : GetShellWindow(), values.x, values.y, values.width, values.height );
1884 0 : if( GetShellWindow() != GetWindow() )
1885 : {
1886 0 : if( (nStyle_ & SAL_FRAME_STYLE_PLUG ) )
1887 0 : XMoveResizeWindow( GetXDisplay(), GetWindow(), 0, 0, values.width, values.height );
1888 : else
1889 0 : XMoveResizeWindow( GetXDisplay(), GetWindow(), values.x, values.y, values.width, values.height );
1890 : }
1891 :
1892 0 : maGeometry.nX = values.x;
1893 0 : maGeometry.nY = values.y;
1894 0 : maGeometry.nWidth = values.width;
1895 0 : maGeometry.nHeight = values.height;
1896 0 : if( IsSysChildWindow() && mpParent )
1897 : {
1898 : // translate back to root coordinates
1899 0 : maGeometry.nX += mpParent->maGeometry.nX;
1900 0 : maGeometry.nY += mpParent->maGeometry.nY;
1901 : }
1902 :
1903 0 : updateScreenNumber();
1904 0 : if( bSized && ! bMoved )
1905 0 : CallCallback( SALEVENT_RESIZE, NULL );
1906 0 : else if( bMoved && ! bSized )
1907 0 : CallCallback( SALEVENT_MOVE, NULL );
1908 : else
1909 0 : CallCallback( SALEVENT_MOVERESIZE, NULL );
1910 :
1911 : // allow the external status window to reposition
1912 0 : if (mbInputFocus && mpInputContext != NULL)
1913 0 : mpInputContext->SetICFocus ( this );
1914 : }
1915 :
1916 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1917 0 : void X11SalFrame::Minimize()
1918 : {
1919 0 : if( IsSysChildWindow() )
1920 0 : return;
1921 :
1922 0 : if( SHOWSTATE_UNKNOWN == nShowState_ || SHOWSTATE_HIDDEN == nShowState_ )
1923 : {
1924 : stderr0( "X11SalFrame::Minimize on withdrawn window\n" );
1925 0 : return;
1926 : }
1927 :
1928 0 : if( XIconifyWindow( GetXDisplay(),
1929 : GetShellWindow(),
1930 0 : pDisplay_->GetDefaultXScreen().getXScreen() ) )
1931 0 : nShowState_ = SHOWSTATE_MINIMIZED;
1932 : }
1933 :
1934 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1935 0 : void X11SalFrame::Maximize()
1936 : {
1937 0 : if( IsSysChildWindow() )
1938 0 : return;
1939 :
1940 0 : if( SHOWSTATE_MINIMIZED == nShowState_ )
1941 : {
1942 0 : GetDisplay()->getWMAdaptor()->frameIsMapping( this );
1943 0 : XMapWindow( GetXDisplay(), GetShellWindow() );
1944 0 : nShowState_ = SHOWSTATE_NORMAL;
1945 : }
1946 :
1947 0 : pDisplay_->getWMAdaptor()->maximizeFrame( this, true, true );
1948 : }
1949 :
1950 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1951 0 : void X11SalFrame::Restore()
1952 : {
1953 0 : if( IsSysChildWindow() )
1954 0 : return;
1955 :
1956 0 : if( SHOWSTATE_UNKNOWN == nShowState_ || SHOWSTATE_HIDDEN == nShowState_ )
1957 : {
1958 : stderr0( "X11SalFrame::Restore on withdrawn window\n" );
1959 0 : return;
1960 : }
1961 :
1962 0 : if( SHOWSTATE_MINIMIZED == nShowState_ )
1963 : {
1964 0 : GetDisplay()->getWMAdaptor()->frameIsMapping( this );
1965 0 : XMapWindow( GetXDisplay(), GetShellWindow() );
1966 0 : nShowState_ = SHOWSTATE_NORMAL;
1967 : }
1968 :
1969 0 : pDisplay_->getWMAdaptor()->maximizeFrame( this, false, false );
1970 : }
1971 :
1972 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1973 :
1974 0 : void X11SalFrame::SetScreenNumber( unsigned int nNewScreen )
1975 : {
1976 0 : if( nNewScreen == maGeometry.nDisplayScreenNumber )
1977 0 : return;
1978 :
1979 0 : if( GetDisplay()->IsXinerama() && GetDisplay()->GetXineramaScreens().size() > 1 )
1980 : {
1981 0 : if( nNewScreen >= GetDisplay()->GetXineramaScreens().size() )
1982 : return;
1983 :
1984 0 : Rectangle aOldScreenRect( GetDisplay()->GetXineramaScreens()[maGeometry.nDisplayScreenNumber] );
1985 0 : Rectangle aNewScreenRect( GetDisplay()->GetXineramaScreens()[nNewScreen] );
1986 0 : bool bVisible = bMapped_;
1987 0 : if( bVisible )
1988 0 : Show( sal_False );
1989 0 : maGeometry.nX = aNewScreenRect.Left() + (maGeometry.nX - aOldScreenRect.Left());
1990 0 : maGeometry.nY = aNewScreenRect.Top() + (maGeometry.nY - aOldScreenRect.Top());
1991 0 : createNewWindow( None, m_nXScreen );
1992 0 : if( bVisible )
1993 0 : Show( sal_True );
1994 0 : maGeometry.nDisplayScreenNumber = nNewScreen;
1995 : }
1996 0 : else if( nNewScreen < GetDisplay()->GetXScreenCount() )
1997 : {
1998 0 : bool bVisible = bMapped_;
1999 0 : if( bVisible )
2000 0 : Show( sal_False );
2001 0 : createNewWindow( None, SalX11Screen( nNewScreen ) );
2002 0 : if( bVisible )
2003 0 : Show( sal_True );
2004 0 : maGeometry.nDisplayScreenNumber = nNewScreen;
2005 : }
2006 : }
2007 :
2008 0 : void X11SalFrame::SetApplicationID( const rtl::OUString &rWMClass )
2009 : {
2010 0 : if( rWMClass != m_sWMClass && ! IsChildWindow() )
2011 : {
2012 0 : m_sWMClass = rWMClass;
2013 0 : updateWMClass();
2014 0 : std::list< X11SalFrame* >::const_iterator it;
2015 0 : for( it = maChildren.begin(); it != maChildren.end(); ++it )
2016 0 : (*it)->SetApplicationID(rWMClass);
2017 : }
2018 0 : }
2019 :
2020 0 : void X11SalFrame::updateWMClass()
2021 : {
2022 0 : XClassHint* pClass = XAllocClassHint();
2023 0 : rtl::OString aResName = SalGenericSystem::getFrameResName( mnExtStyle );
2024 0 : pClass->res_name = const_cast<char*>(aResName.getStr());
2025 :
2026 0 : rtl::OString aResClass = rtl::OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
2027 0 : const char *pResClass = !aResClass.isEmpty() ? aResClass.getStr() :
2028 0 : SalGenericSystem::getFrameClassName();
2029 :
2030 0 : pClass->res_class = const_cast<char*>(pResClass);
2031 0 : XSetClassHint( GetXDisplay(), GetShellWindow(), pClass );
2032 0 : XFree( pClass );
2033 0 : }
2034 :
2035 :
2036 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2037 :
2038 0 : void X11SalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nScreen )
2039 : {
2040 0 : if( GetDisplay()->IsXinerama() && GetDisplay()->GetXineramaScreens().size() > 1 )
2041 : {
2042 0 : if( mbFullScreen == (bool)bFullScreen )
2043 0 : return;
2044 0 : if( bFullScreen )
2045 : {
2046 : maRestorePosSize = Rectangle( Point( maGeometry.nX, maGeometry.nY ),
2047 0 : Size( maGeometry.nWidth, maGeometry.nHeight ) );
2048 0 : Rectangle aRect;
2049 0 : if( nScreen < 0 || nScreen >= static_cast<int>(GetDisplay()->GetXineramaScreens().size()) )
2050 0 : aRect = Rectangle( Point(0,0), GetDisplay()->GetScreenSize( m_nXScreen ) );
2051 : else
2052 0 : aRect = GetDisplay()->GetXineramaScreens()[nScreen];
2053 0 : nStyle_ |= SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
2054 0 : bool bVisible = bMapped_;
2055 0 : if( bVisible )
2056 0 : Show( sal_False );
2057 0 : maGeometry.nX = aRect.Left();
2058 0 : maGeometry.nY = aRect.Top();
2059 0 : maGeometry.nWidth = aRect.GetWidth();
2060 0 : maGeometry.nHeight = aRect.GetHeight();
2061 0 : mbMaximizedHorz = mbMaximizedVert = false;
2062 0 : mbFullScreen = true;
2063 0 : createNewWindow( None, m_nXScreen );
2064 0 : if( GetDisplay()->getWMAdaptor()->isLegacyPartialFullscreen() )
2065 0 : GetDisplay()->getWMAdaptor()->enableAlwaysOnTop( this, true );
2066 : else
2067 0 : GetDisplay()->getWMAdaptor()->showFullScreen( this, true );
2068 0 : if( bVisible )
2069 0 : Show(sal_True);
2070 :
2071 : }
2072 : else
2073 : {
2074 0 : mbFullScreen = false;
2075 0 : nStyle_ &= ~SAL_FRAME_STYLE_PARTIAL_FULLSCREEN;
2076 0 : bool bVisible = bMapped_;
2077 0 : Rectangle aRect = maRestorePosSize;
2078 0 : maRestorePosSize = Rectangle();
2079 0 : if( bVisible )
2080 0 : Show( sal_False );
2081 0 : createNewWindow( None, m_nXScreen );
2082 0 : if( !aRect.IsEmpty() )
2083 0 : SetPosSize( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(),
2084 : SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y |
2085 0 : SAL_FRAME_POSSIZE_WIDTH | SAL_FRAME_POSSIZE_HEIGHT );
2086 0 : if( bVisible )
2087 0 : Show( sal_True );
2088 : }
2089 : }
2090 : else
2091 : {
2092 0 : if( nScreen < 0 || nScreen >= (int)GetDisplay()->GetXScreenCount() )
2093 0 : nScreen = m_nXScreen.getXScreen();
2094 0 : if( nScreen != (int)m_nXScreen.getXScreen() )
2095 : {
2096 0 : bool bVisible = bMapped_;
2097 0 : if( mbFullScreen )
2098 0 : pDisplay_->getWMAdaptor()->showFullScreen( this, false );
2099 0 : if( bVisible )
2100 0 : Show( sal_False );
2101 0 : createNewWindow( None, SalX11Screen( nScreen ) );
2102 0 : if( mbFullScreen )
2103 0 : pDisplay_->getWMAdaptor()->showFullScreen( this, true );
2104 0 : if( bVisible )
2105 0 : Show( sal_True );
2106 : }
2107 0 : if( mbFullScreen == (bool)bFullScreen )
2108 0 : return;
2109 :
2110 0 : pDisplay_->getWMAdaptor()->showFullScreen( this, bFullScreen );
2111 0 : if( IsOverrideRedirect()
2112 0 : && WMSupportsFWS( GetXDisplay(), GetDisplay()->GetRootWindow( m_nXScreen ) ) )
2113 : {
2114 0 : AddFwsProtocols( GetXDisplay(), GetShellWindow() );
2115 0 : RegisterFwsWindow( GetXDisplay(), GetShellWindow() );
2116 : }
2117 : }
2118 : }
2119 :
2120 : /* ---------------------------------------------------------------------
2121 : the xautolock pseudo screen saver needs special treatment since it
2122 : doesn't cooperate with XxxxScreenSaver settings
2123 : ------------------------------------------------------------------- */
2124 :
2125 : static Bool
2126 0 : IsRunningXAutoLock( Display *p_display, XLIB_Window a_window )
2127 : {
2128 0 : const char *p_atomname = "XAUTOLOCK_SEMAPHORE_PID";
2129 : Atom a_pidatom;
2130 :
2131 : // xautolock interns this atom
2132 0 : a_pidatom = XInternAtom( p_display, p_atomname, True );
2133 0 : if ( a_pidatom == None )
2134 0 : return False;
2135 :
2136 : Atom a_type;
2137 : int n_format;
2138 : unsigned long n_items;
2139 : unsigned long n_bytes_after;
2140 : pid_t *p_pid;
2141 : pid_t n_pid;
2142 : // get pid of running xautolock
2143 : XGetWindowProperty (p_display, a_window, a_pidatom, 0L, 2L, False,
2144 : AnyPropertyType, &a_type, &n_format, &n_items, &n_bytes_after,
2145 0 : (unsigned char**) &p_pid );
2146 0 : n_pid = *p_pid;
2147 0 : XFree( p_pid );
2148 :
2149 0 : if ( a_type == XA_INTEGER )
2150 : {
2151 : // check if xautolock pid points to a running process
2152 0 : if ( kill(n_pid, 0) == -1 )
2153 0 : return False;
2154 : else
2155 0 : return True;
2156 : }
2157 :
2158 0 : return False;
2159 : }
2160 :
2161 : /* definitions from xautolock.c (pl15) */
2162 : #define XAUTOLOCK_DISABLE 1
2163 : #define XAUTOLOCK_ENABLE 2
2164 :
2165 : static Bool
2166 0 : MessageToXAutoLock( Display *p_display, int n_message )
2167 : {
2168 0 : const char *p_atomname = "XAUTOLOCK_MESSAGE" ;
2169 : Atom a_messageatom;
2170 : XLIB_Window a_rootwindow;
2171 :
2172 0 : a_rootwindow = RootWindowOfScreen( ScreenOfDisplay(p_display, 0) );
2173 0 : if ( ! IsRunningXAutoLock(p_display, a_rootwindow) )
2174 : {
2175 : // remove any pending messages
2176 0 : a_messageatom = XInternAtom( p_display, p_atomname, True );
2177 0 : if ( a_messageatom != None )
2178 0 : XDeleteProperty( p_display, a_rootwindow, a_messageatom );
2179 0 : return False;
2180 : }
2181 :
2182 0 : a_messageatom = XInternAtom( p_display, p_atomname, False );
2183 : XChangeProperty (p_display, a_rootwindow, a_messageatom, XA_INTEGER,
2184 0 : 8, PropModeReplace, (unsigned char*)&n_message, sizeof(n_message) );
2185 :
2186 0 : return True;
2187 : }
2188 :
2189 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2190 0 : void X11SalFrame::StartPresentation( sal_Bool bStart )
2191 : {
2192 0 : I18NStatus::get().show( !bStart, I18NStatus::presentation );
2193 0 : if ( bStart )
2194 0 : MessageToXAutoLock( GetXDisplay(), XAUTOLOCK_DISABLE );
2195 : else
2196 0 : MessageToXAutoLock( GetXDisplay(), XAUTOLOCK_ENABLE );
2197 :
2198 0 : if( ! bStart && hPresentationWindow != None )
2199 0 : doReparentPresentationDialogues( GetDisplay() );
2200 0 : hPresentationWindow = (bStart && IsOverrideRedirect() ) ? GetWindow() : None;
2201 :
2202 :
2203 : // needs static here to save DPMS settings
2204 : int dummy;
2205 : static bool DPMSExtensionAvailable =
2206 : #if !defined(SOLARIS) && !defined(AIX)
2207 0 : (DPMSQueryExtension(GetXDisplay(), &dummy, &dummy) != 0);
2208 : static sal_Bool DPMSEnabled = false;
2209 : #else
2210 : false;
2211 : bool DPMSEnabled = false;
2212 : (void)dummy;
2213 : #define CARD16 unsigned short
2214 : #endif
2215 : static CARD16 dpms_standby_timeout=0;
2216 : static CARD16 dpms_suspend_timeout=0;
2217 : static CARD16 dpms_off_timeout=0;
2218 :
2219 :
2220 0 : if( bStart || nScreenSaversTimeout_ || DPMSEnabled)
2221 : {
2222 0 : if( hPresentationWindow )
2223 : {
2224 : /* #i10559# workaround for WindowMaker: try to restore
2225 : * current focus after presentation window is gone
2226 : */
2227 0 : int revert_to = 0;
2228 0 : XGetInputFocus( GetXDisplay(), &hPresFocusWindow, &revert_to );
2229 : }
2230 : int timeout, interval, prefer_blanking, allow_exposures;
2231 : XGetScreenSaver( GetXDisplay(),
2232 : &timeout,
2233 : &interval,
2234 : &prefer_blanking,
2235 0 : &allow_exposures );
2236 :
2237 :
2238 : // get the DPMS state right before the start
2239 0 : if (DPMSExtensionAvailable)
2240 : {
2241 : #if !defined(SOLARIS) && !defined(AIX)
2242 : CARD16 state; // card16 is defined in Xdm.h
2243 : DPMSInfo( GetXDisplay(),
2244 : &state,
2245 0 : &DPMSEnabled);
2246 : #endif
2247 : }
2248 0 : if( bStart ) // start show
2249 : {
2250 0 : if ( timeout )
2251 : {
2252 0 : nScreenSaversTimeout_ = timeout;
2253 0 : XResetScreenSaver( GetXDisplay() );
2254 : XSetScreenSaver( GetXDisplay(),
2255 : 0,
2256 : interval,
2257 : prefer_blanking,
2258 0 : allow_exposures );
2259 : }
2260 : #if !defined(SOLARIS) && !defined(AIX)
2261 0 : if( DPMSEnabled )
2262 : {
2263 0 : if ( DPMSExtensionAvailable )
2264 : {
2265 : DPMSGetTimeouts( GetXDisplay(),
2266 : &dpms_standby_timeout,
2267 : &dpms_suspend_timeout,
2268 0 : &dpms_off_timeout);
2269 0 : DPMSSetTimeouts(GetXDisplay(), 0,0,0);
2270 : }
2271 : }
2272 : #endif
2273 : }
2274 : else
2275 : {
2276 0 : if( nScreenSaversTimeout_ )
2277 : {
2278 : XSetScreenSaver( GetXDisplay(),
2279 : nScreenSaversTimeout_,
2280 : interval,
2281 : prefer_blanking,
2282 0 : allow_exposures );
2283 0 : nScreenSaversTimeout_ = 0;
2284 : }
2285 : #if !defined(SOLARIS) && !defined(AIX)
2286 0 : if ( DPMSEnabled )
2287 : {
2288 0 : if ( DPMSExtensionAvailable )
2289 : {
2290 : // restore timeouts
2291 : DPMSSetTimeouts(GetXDisplay(), dpms_standby_timeout,
2292 0 : dpms_suspend_timeout, dpms_off_timeout);
2293 : }
2294 : }
2295 : #endif
2296 : }
2297 : }
2298 0 : }
2299 :
2300 : // Pointer
2301 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2302 0 : void X11SalFrame::SetPointer( PointerStyle ePointerStyle )
2303 : {
2304 0 : hCursor_ = pDisplay_->GetPointer( ePointerStyle );
2305 0 : XDefineCursor( GetXDisplay(), GetWindow(), hCursor_ );
2306 :
2307 0 : if( IsCaptured() || nVisibleFloats > 0 )
2308 : XChangeActivePointerGrab( GetXDisplay(),
2309 : PointerMotionMask|ButtonPressMask|ButtonReleaseMask,
2310 : hCursor_,
2311 0 : CurrentTime );
2312 0 : }
2313 :
2314 0 : void X11SalFrame::SetPointerPos(long nX, long nY)
2315 : {
2316 : /* when the application tries to center the mouse in the dialog the
2317 : * window isn't mapped already. So use coordinates relative to the root window.
2318 : */
2319 0 : unsigned int nWindowLeft = maGeometry.nX + nX;
2320 0 : unsigned int nWindowTop = maGeometry.nY + nY;
2321 :
2322 : XWarpPointer( GetXDisplay(), None, pDisplay_->GetRootWindow( pDisplay_->GetDefaultXScreen() ),
2323 0 : 0, 0, 0, 0, nWindowLeft, nWindowTop);
2324 0 : }
2325 :
2326 : // delay handling of extended text input
2327 : #if !defined(__synchronous_extinput__)
2328 : void
2329 0 : X11SalFrame::HandleExtTextEvent (XClientMessageEvent *pEvent)
2330 : {
2331 : #if SAL_TYPES_SIZEOFLONG > 4
2332 : void* pExtTextEvent = (void*)( (pEvent->data.l[0] & 0xffffffff)
2333 : | (pEvent->data.l[1] << 32) );
2334 : #else
2335 0 : void* pExtTextEvent = (void*)(pEvent->data.l[0]);
2336 : #endif
2337 0 : sal_uInt16 nExtTextEventType = sal_uInt16(pEvent->data.l[2]);
2338 :
2339 0 : CallCallback(nExtTextEventType, pExtTextEvent);
2340 :
2341 0 : switch (nExtTextEventType)
2342 : {
2343 : case SALEVENT_ENDEXTTEXTINPUT:
2344 0 : break;
2345 :
2346 : case SALEVENT_EXTTEXTINPUT:
2347 0 : break;
2348 :
2349 : default:
2350 :
2351 0 : fprintf(stderr, "X11SalFrame::HandleExtTextEvent: invalid extended input\n");
2352 : }
2353 0 : }
2354 : #endif /* defined(__synchronous_extinput__) */
2355 :
2356 : // PostEvent
2357 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2358 0 : sal_Bool X11SalFrame::PostEvent( void *pData )
2359 : {
2360 0 : GetDisplay()->SendInternalEvent( this, pData );
2361 0 : return sal_True;
2362 : }
2363 :
2364 : // Title
2365 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2366 0 : void X11SalFrame::SetTitle( const rtl::OUString& rTitle )
2367 : {
2368 0 : if( ! ( IsChildWindow() || (nStyle_ & SAL_FRAME_STYLE_FLOAT ) ) )
2369 : {
2370 0 : m_aTitle = rTitle;
2371 0 : GetDisplay()->getWMAdaptor()->setWMName( this, rTitle );
2372 : }
2373 0 : }
2374 :
2375 : // -----------------------------------------------------------------------
2376 :
2377 0 : void X11SalFrame::Flush()
2378 : {
2379 0 : XFlush( GetDisplay()->GetDisplay() );
2380 0 : }
2381 :
2382 : // -----------------------------------------------------------------------
2383 :
2384 0 : void X11SalFrame::Sync()
2385 : {
2386 0 : XSync( GetDisplay()->GetDisplay(), False );
2387 0 : }
2388 :
2389 : // Keyboard
2390 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2391 :
2392 : // -----------------------------------------------------------------------
2393 :
2394 0 : void X11SalFrame::SetInputContext( SalInputContext* pContext )
2395 : {
2396 0 : if (pContext == NULL)
2397 0 : return;
2398 :
2399 : // 1. We should create an input context for this frame
2400 : // only when SAL_INPUTCONTEXT_TEXT is set.
2401 :
2402 0 : if (!(pContext->mnOptions & SAL_INPUTCONTEXT_TEXT))
2403 : {
2404 0 : if( mpInputContext )
2405 0 : mpInputContext->Unmap( this );
2406 0 : return;
2407 : }
2408 :
2409 : // 2. We should use on-the-spot inputstyle
2410 : // only when SAL_INPUTCONTEXT_EXTTEXTINPUT is set.
2411 :
2412 0 : if (mpInputContext == NULL)
2413 : {
2414 0 : I18NStatus& rStatus( I18NStatus::get() );
2415 0 : rStatus.setParent( this );
2416 0 : mpInputContext = new SalI18N_InputContext( this );
2417 0 : if (mpInputContext->UseContext())
2418 : {
2419 0 : mpInputContext->ExtendEventMask( GetShellWindow() );
2420 0 : if (pContext->mnOptions & SAL_INPUTCONTEXT_CHANGELANGUAGE)
2421 0 : mpInputContext->SetLanguage(pContext->meLanguage);
2422 0 : if (mbInputFocus)
2423 0 : mpInputContext->SetICFocus( this );
2424 : }
2425 : }
2426 : else
2427 0 : mpInputContext->Map( this );
2428 0 : return;
2429 : }
2430 :
2431 : // -----------------------------------------------------------------------
2432 :
2433 0 : void X11SalFrame::EndExtTextInput( sal_uInt16 nFlags )
2434 : {
2435 0 : if (mpInputContext != NULL)
2436 0 : mpInputContext->EndExtTextInput( nFlags );
2437 0 : }
2438 :
2439 : // -----------------------------------------------------------------------
2440 :
2441 0 : rtl::OUString X11SalFrame::GetKeyName( sal_uInt16 nKeyCode )
2442 : {
2443 0 : return GetDisplay()->GetKeyName( nKeyCode );
2444 : }
2445 :
2446 0 : sal_Bool X11SalFrame::MapUnicodeToKeyCode( sal_Unicode , LanguageType , KeyCode& )
2447 : {
2448 : // not supported yet
2449 0 : return sal_False;
2450 : }
2451 :
2452 0 : LanguageType X11SalFrame::GetInputLanguage()
2453 : {
2454 : // could be improved by checking unicode ranges of the last input
2455 0 : return LANGUAGE_DONTKNOW;
2456 : }
2457 :
2458 : // Settings
2459 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2460 :
2461 : inline Color getColorFromLong( long nColor )
2462 : {
2463 : return Color( (nColor & 0xff), (nColor & 0xff00)>>8, (nColor & 0xff0000)>>16);
2464 : }
2465 :
2466 0 : void X11SalFrame::UpdateSettings( AllSettings& rSettings )
2467 : {
2468 0 : StyleSettings aStyleSettings = rSettings.GetStyleSettings();
2469 0 : aStyleSettings.SetCursorBlinkTime( 500 );
2470 0 : rSettings.SetStyleSettings( aStyleSettings );
2471 0 : }
2472 :
2473 0 : void X11SalFrame::CaptureMouse( sal_Bool bCapture )
2474 : {
2475 0 : nCaptured_ = pDisplay_->CaptureMouse( bCapture ? this : NULL );
2476 0 : }
2477 :
2478 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2479 :
2480 0 : void X11SalFrame::SetParent( SalFrame* pNewParent )
2481 : {
2482 0 : if( mpParent != pNewParent )
2483 : {
2484 0 : if( mpParent )
2485 0 : mpParent->maChildren.remove( this );
2486 :
2487 0 : mpParent = static_cast<X11SalFrame*>(pNewParent);
2488 0 : mpParent->maChildren.push_back( this );
2489 0 : if( mpParent->m_nXScreen != m_nXScreen )
2490 0 : createNewWindow( None, mpParent->m_nXScreen );
2491 0 : GetDisplay()->getWMAdaptor()->changeReferenceFrame( this, mpParent );
2492 : }
2493 0 : }
2494 :
2495 0 : SalFrame* X11SalFrame::GetParent() const
2496 : {
2497 0 : return mpParent;
2498 : }
2499 :
2500 0 : void X11SalFrame::createNewWindow( XLIB_Window aNewParent, SalX11Screen nXScreen )
2501 : {
2502 0 : bool bWasVisible = bMapped_;
2503 0 : if( bWasVisible )
2504 0 : Show( sal_False );
2505 :
2506 0 : if( nXScreen.getXScreen() >= GetDisplay()->GetXScreenCount() )
2507 0 : nXScreen = m_nXScreen;
2508 :
2509 : SystemParentData aParentData;
2510 0 : aParentData.aWindow = aNewParent;
2511 0 : aParentData.bXEmbedSupport = (aNewParent != None && m_bXEmbed); // caution: this is guesswork
2512 0 : if( aNewParent == None )
2513 : {
2514 0 : aNewParent = GetDisplay()->GetRootWindow(nXScreen);
2515 0 : aParentData.aWindow = None;
2516 0 : m_bXEmbed = false;
2517 : }
2518 : else
2519 : {
2520 : // is new parent a root window ?
2521 0 : Display* pDisp = GetDisplay()->GetDisplay();
2522 0 : int nScreens = GetDisplay()->GetXScreenCount();
2523 0 : for( int i = 0; i < nScreens; i++ )
2524 : {
2525 0 : if( aNewParent == RootWindow( pDisp, i ) )
2526 : {
2527 0 : nXScreen = SalX11Screen( i );
2528 0 : aParentData.aWindow = None;
2529 0 : m_bXEmbed = false;
2530 0 : break;
2531 : }
2532 : }
2533 : }
2534 :
2535 : // first deinit frame
2536 0 : updateGraphics(true);
2537 0 : if( mpInputContext )
2538 : {
2539 0 : mpInputContext->UnsetICFocus( this );
2540 0 : mpInputContext->Unmap( this );
2541 : }
2542 0 : if( GetWindow() == hPresentationWindow )
2543 : {
2544 0 : hPresentationWindow = None;
2545 0 : doReparentPresentationDialogues( GetDisplay() );
2546 : }
2547 0 : XDestroyWindow( GetXDisplay(), mhWindow );
2548 0 : mhWindow = None;
2549 :
2550 : // now init with new parent again
2551 0 : if ( aParentData.aWindow != None )
2552 0 : Init( nStyle_ | SAL_FRAME_STYLE_PLUG, nXScreen, &aParentData );
2553 : else
2554 0 : Init( nStyle_ & ~SAL_FRAME_STYLE_PLUG, nXScreen, NULL, true );
2555 :
2556 : // update graphics if necessary
2557 0 : updateGraphics(false);
2558 :
2559 0 : if( ! m_aTitle.isEmpty() )
2560 0 : SetTitle( m_aTitle );
2561 :
2562 0 : if( mpParent )
2563 : {
2564 0 : if( mpParent->m_nXScreen != m_nXScreen )
2565 0 : SetParent( NULL );
2566 : else
2567 0 : pDisplay_->getWMAdaptor()->changeReferenceFrame( this, mpParent );
2568 : }
2569 :
2570 0 : if( bWasVisible )
2571 0 : Show( sal_True );
2572 :
2573 0 : std::list< X11SalFrame* > aChildren = maChildren;
2574 0 : for( std::list< X11SalFrame* >::iterator it = aChildren.begin(); it != aChildren.end(); ++it )
2575 0 : (*it)->createNewWindow( None, m_nXScreen );
2576 :
2577 : // FIXME: SalObjects
2578 0 : }
2579 :
2580 0 : bool X11SalFrame::SetPluginParent( SystemParentData* pNewParent )
2581 : {
2582 0 : if( pNewParent->nSize >= sizeof(SystemParentData) )
2583 0 : m_bXEmbed = pNewParent->aWindow != None && pNewParent->bXEmbedSupport;
2584 0 : createNewWindow( pNewParent ? pNewParent->aWindow : None );
2585 :
2586 0 : return true;
2587 : }
2588 :
2589 : // Event Handling
2590 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2591 0 : static sal_uInt16 sal_GetCode( int state )
2592 : {
2593 0 : sal_uInt16 nCode = 0;
2594 :
2595 0 : if( state & Button1Mask )
2596 0 : nCode |= MOUSE_LEFT;
2597 0 : if( state & Button2Mask )
2598 0 : nCode |= MOUSE_MIDDLE;
2599 0 : if( state & Button3Mask )
2600 0 : nCode |= MOUSE_RIGHT;
2601 :
2602 0 : if( state & ShiftMask )
2603 0 : nCode |= KEY_SHIFT;
2604 0 : if( state & ControlMask )
2605 0 : nCode |= KEY_MOD1;
2606 0 : if( state & Mod1Mask )
2607 0 : nCode |= KEY_MOD2;
2608 :
2609 : // Map Meta/Super modifier to MOD3 on all Unix systems
2610 : // except Mac OS X
2611 0 : if( (state & Mod3Mask) )
2612 0 : nCode |= KEY_MOD3;
2613 :
2614 0 : return nCode;
2615 : }
2616 :
2617 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2618 :
2619 0 : SalFrame::SalPointerState X11SalFrame::GetPointerState()
2620 : {
2621 0 : SalPointerState aState;
2622 : XLIB_Window aRoot, aChild;
2623 : int rx, ry, wx, wy;
2624 0 : unsigned int nMask = 0;
2625 : XQueryPointer( GetXDisplay(),
2626 : GetShellWindow(),
2627 : &aRoot,
2628 : &aChild,
2629 : &rx, &ry,
2630 : &wx, &wy,
2631 : &nMask
2632 0 : );
2633 :
2634 0 : aState.maPos = Point(wx, wy);
2635 0 : aState.mnState = sal_GetCode( nMask );
2636 0 : return aState;
2637 : }
2638 :
2639 0 : SalFrame::SalIndicatorState X11SalFrame::GetIndicatorState()
2640 : {
2641 : SalIndicatorState aState;
2642 0 : aState.mnState = GetGenericData()->GetSalDisplay()->GetIndicatorState();
2643 0 : return aState;
2644 : }
2645 :
2646 0 : void X11SalFrame::SimulateKeyPress( sal_uInt16 nKeyCode )
2647 : {
2648 0 : GetGenericData()->GetSalDisplay()->SimulateKeyPress(nKeyCode);
2649 0 : }
2650 :
2651 0 : long X11SalFrame::HandleMouseEvent( XEvent *pEvent )
2652 : {
2653 : SalMouseEvent aMouseEvt;
2654 0 : sal_uInt16 nEvent = 0;
2655 0 : bool bClosePopups = false;
2656 :
2657 0 : if( nVisibleFloats && pEvent->type == EnterNotify )
2658 0 : return 0;
2659 :
2660 : // Solaris X86: clicking the right button on a two-button mouse
2661 : // generates a button2 event not a button3 event
2662 0 : if (pDisplay_->GetProperties() & PROPERTY_SUPPORT_3ButtonMouse )
2663 : {
2664 0 : switch (pEvent->type)
2665 : {
2666 : case EnterNotify:
2667 : case LeaveNotify:
2668 0 : if ( pEvent->xcrossing.state & Button2Mask )
2669 : {
2670 0 : pEvent->xcrossing.state &= ~Button2Mask;
2671 0 : pEvent->xcrossing.state |= Button3Mask;
2672 : }
2673 0 : break;
2674 :
2675 : case MotionNotify:
2676 0 : if ( pEvent->xmotion.state & Button2Mask )
2677 : {
2678 0 : pEvent->xmotion.state &= ~Button2Mask;
2679 0 : pEvent->xmotion.state |= Button3Mask;
2680 : }
2681 0 : break;
2682 :
2683 : default:
2684 0 : if ( Button2 == pEvent->xbutton.button )
2685 : {
2686 0 : pEvent->xbutton.state &= ~Button2Mask;
2687 0 : pEvent->xbutton.state |= Button3Mask;
2688 0 : pEvent->xbutton.button = Button3;
2689 : }
2690 0 : break;
2691 : }
2692 : }
2693 :
2694 :
2695 0 : if( LeaveNotify == pEvent->type || EnterNotify == pEvent->type )
2696 : {
2697 : /*
2698 : * some WMs (and/or) applications have a passive grab on
2699 : * mouse buttons (XGrabButton). This leads to enter/leave notifies
2700 : * with mouse buttons pressed in the state mask before the actual
2701 : * ButtonPress event gets dispatched. But EnterNotify
2702 : * is reported in vcl as MouseMove event. Some office code
2703 : * decides that a pressed button in a MouseMove belongs to
2704 : * a drag operation which leads to doing things differently.
2705 : *
2706 : * ignore Enter/LeaveNotify resulting from grabs so that
2707 : * help windows do not disappear just after appearing
2708 : *
2709 : * hopefully this workaround will not break anything.
2710 : */
2711 0 : if( pEvent->xcrossing.mode == NotifyGrab || pEvent->xcrossing.mode == NotifyUngrab )
2712 0 : return 0;
2713 :
2714 0 : aMouseEvt.mnX = pEvent->xcrossing.x;
2715 0 : aMouseEvt.mnY = pEvent->xcrossing.y;
2716 0 : aMouseEvt.mnTime = pEvent->xcrossing.time;
2717 0 : aMouseEvt.mnCode = sal_GetCode( pEvent->xcrossing.state );
2718 0 : aMouseEvt.mnButton = 0;
2719 :
2720 : nEvent = LeaveNotify == pEvent->type
2721 : ? SALEVENT_MOUSELEAVE
2722 0 : : SALEVENT_MOUSEMOVE;
2723 : }
2724 0 : else if( pEvent->type == MotionNotify )
2725 : {
2726 0 : aMouseEvt.mnX = pEvent->xmotion.x;
2727 0 : aMouseEvt.mnY = pEvent->xmotion.y;
2728 0 : aMouseEvt.mnTime = pEvent->xmotion.time;
2729 0 : aMouseEvt.mnCode = sal_GetCode( pEvent->xmotion.state );
2730 :
2731 0 : aMouseEvt.mnButton = 0;
2732 :
2733 0 : nEvent = SALEVENT_MOUSEMOVE;
2734 0 : if( nVisibleFloats > 0 && mpParent )
2735 : {
2736 0 : XLIB_Cursor aCursor = mpParent->GetCursor();
2737 0 : if( pEvent->xmotion.x >= 0 && pEvent->xmotion.x < (int)maGeometry.nWidth &&
2738 : pEvent->xmotion.y >= 0 && pEvent->xmotion.y < (int)maGeometry.nHeight )
2739 0 : aCursor = None;
2740 :
2741 : XChangeActivePointerGrab( GetXDisplay(),
2742 : PointerMotionMask|ButtonPressMask|ButtonReleaseMask,
2743 : aCursor,
2744 0 : CurrentTime );
2745 : }
2746 : }
2747 : else
2748 : {
2749 : // let mouse events reach the correct window
2750 0 : if( nVisibleFloats < 1 )
2751 : {
2752 0 : if( ! (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION) )
2753 0 : XUngrabPointer( GetXDisplay(), CurrentTime );
2754 : }
2755 0 : else if( pEvent->type == ButtonPress )
2756 : {
2757 : // see if the user clicks outside all of the floats
2758 : // if yes release the grab
2759 0 : bool bInside = false;
2760 0 : const std::list< SalFrame* >& rFrames = GetDisplay()->getFrames();
2761 0 : for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
2762 : {
2763 0 : const X11SalFrame* pFrame = static_cast< const X11SalFrame* >(*it);
2764 0 : if( pFrame->IsFloatGrabWindow() &&
2765 : pFrame->bMapped_ &&
2766 : pEvent->xbutton.x_root >= pFrame->maGeometry.nX &&
2767 : pEvent->xbutton.x_root < pFrame->maGeometry.nX + (int)pFrame->maGeometry.nWidth &&
2768 : pEvent->xbutton.y_root >= pFrame->maGeometry.nY &&
2769 : pEvent->xbutton.y_root < pFrame->maGeometry.nY + (int)pFrame->maGeometry.nHeight )
2770 : {
2771 0 : bInside = true;
2772 0 : break;
2773 : }
2774 : }
2775 0 : if( ! bInside )
2776 : {
2777 : // need not take care of the XUngrabPointer in Show( sal_False )
2778 : // because XUngrabPointer does not produce errors if pointer
2779 : // is not grabbed
2780 0 : XUngrabPointer( GetXDisplay(), CurrentTime );
2781 0 : bClosePopups = true;
2782 :
2783 : /* #i15246# only close popups if pointer is outside all our frames
2784 : * cannot use our own geometry data here because stacking
2785 : * is unknown (the above case implicitly assumes
2786 : * that floats are on top which should be true)
2787 : */
2788 : XLIB_Window aRoot, aChild;
2789 : int root_x, root_y, win_x, win_y;
2790 : unsigned int mask_return;
2791 0 : if( XQueryPointer( GetXDisplay(),
2792 : GetDisplay()->GetRootWindow( m_nXScreen ),
2793 : &aRoot, &aChild,
2794 : &root_x, &root_y,
2795 : &win_x, &win_y,
2796 0 : &mask_return )
2797 : && aChild // pointer may not be in any child
2798 : )
2799 : {
2800 0 : for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
2801 : {
2802 0 : const X11SalFrame* pFrame = static_cast< const X11SalFrame* >(*it);
2803 0 : if( ! pFrame->IsFloatGrabWindow()
2804 0 : && ( pFrame->GetWindow() == aChild ||
2805 0 : pFrame->GetShellWindow() == aChild ||
2806 0 : pFrame->GetStackingWindow() == aChild )
2807 : )
2808 : {
2809 : // #i63638# check that pointer is inside window, not
2810 : // only inside stacking window
2811 0 : if( root_x >= pFrame->maGeometry.nX && root_x < sal::static_int_cast< int >(pFrame->maGeometry.nX+pFrame->maGeometry.nWidth) &&
2812 0 : root_y >= pFrame->maGeometry.nY && root_y < sal::static_int_cast< int >(pFrame->maGeometry.nX+pFrame->maGeometry.nHeight) )
2813 : {
2814 0 : bClosePopups = false;
2815 : }
2816 0 : break;
2817 : }
2818 : }
2819 : }
2820 : }
2821 : }
2822 :
2823 0 : if( m_bXEmbed && pEvent->xbutton.button == Button1 )
2824 0 : askForXEmbedFocus( pEvent->xbutton.time );
2825 :
2826 0 : if( pEvent->xbutton.button == Button1 ||
2827 : pEvent->xbutton.button == Button2 ||
2828 : pEvent->xbutton.button == Button3 )
2829 : {
2830 0 : aMouseEvt.mnX = pEvent->xbutton.x;
2831 0 : aMouseEvt.mnY = pEvent->xbutton.y;
2832 0 : aMouseEvt.mnTime = pEvent->xbutton.time;
2833 0 : aMouseEvt.mnCode = sal_GetCode( pEvent->xbutton.state );
2834 :
2835 0 : if( Button1 == pEvent->xbutton.button )
2836 0 : aMouseEvt.mnButton = MOUSE_LEFT;
2837 0 : else if( Button2 == pEvent->xbutton.button )
2838 0 : aMouseEvt.mnButton = MOUSE_MIDDLE;
2839 0 : else if( Button3 == pEvent->xbutton.button )
2840 0 : aMouseEvt.mnButton = MOUSE_RIGHT;
2841 :
2842 : nEvent = ButtonPress == pEvent->type
2843 : ? SALEVENT_MOUSEBUTTONDOWN
2844 0 : : SALEVENT_MOUSEBUTTONUP;
2845 : }
2846 0 : else if( pEvent->xbutton.button == Button4 ||
2847 : pEvent->xbutton.button == Button5 ||
2848 : pEvent->xbutton.button == Button6 ||
2849 : pEvent->xbutton.button == Button7 )
2850 : {
2851 : const bool bIncrement(
2852 : pEvent->xbutton.button == Button4 ||
2853 0 : pEvent->xbutton.button == Button6 );
2854 : const bool bHoriz(
2855 : pEvent->xbutton.button == Button6 ||
2856 0 : pEvent->xbutton.button == Button7 );
2857 :
2858 0 : if( pEvent->type == ButtonRelease )
2859 0 : return 0;
2860 :
2861 : static sal_uLong nLines = 0;
2862 0 : if( ! nLines )
2863 : {
2864 0 : char* pEnv = getenv( "SAL_WHEELLINES" );
2865 0 : nLines = pEnv ? atoi( pEnv ) : 3;
2866 0 : if( nLines > 10 )
2867 0 : nLines = SAL_WHEELMOUSE_EVENT_PAGESCROLL;
2868 : }
2869 :
2870 0 : SalWheelMouseEvent aWheelEvt;
2871 0 : aWheelEvt.mnTime = pEvent->xbutton.time;
2872 0 : aWheelEvt.mnX = pEvent->xbutton.x;
2873 0 : aWheelEvt.mnY = pEvent->xbutton.y;
2874 0 : aWheelEvt.mnDelta = bIncrement ? 120 : -120;
2875 0 : aWheelEvt.mnNotchDelta = bIncrement ? 1 : -1;
2876 0 : aWheelEvt.mnScrollLines = nLines;
2877 0 : aWheelEvt.mnCode = sal_GetCode( pEvent->xbutton.state );
2878 0 : aWheelEvt.mbHorz = bHoriz;
2879 :
2880 0 : nEvent = SALEVENT_WHEELMOUSE;
2881 :
2882 : // --- RTL --- (mirror mouse pos)
2883 0 : if( Application::GetSettings().GetLayoutRTL() )
2884 0 : aWheelEvt.mnX = nWidth_-1-aWheelEvt.mnX;
2885 0 : return CallCallback( nEvent, &aWheelEvt );
2886 : }
2887 : }
2888 :
2889 0 : int nRet = 0;
2890 0 : if( nEvent == SALEVENT_MOUSELEAVE
2891 : || ( aMouseEvt.mnX < nWidth_ && aMouseEvt.mnX > -1 &&
2892 : aMouseEvt.mnY < nHeight_ && aMouseEvt.mnY > -1 )
2893 0 : || pDisplay_->MouseCaptured( this )
2894 : )
2895 : {
2896 : // --- RTL --- (mirror mouse pos)
2897 0 : if( Application::GetSettings().GetLayoutRTL() )
2898 0 : aMouseEvt.mnX = nWidth_-1-aMouseEvt.mnX;
2899 0 : nRet = CallCallback( nEvent, &aMouseEvt );
2900 : }
2901 :
2902 0 : if( bClosePopups )
2903 : {
2904 : /* #108213# close popups after dispatching the event outside the popup;
2905 : * applications do weird things.
2906 : */
2907 0 : ImplSVData* pSVData = ImplGetSVData();
2908 0 : if ( pSVData->maWinData.mpFirstFloat )
2909 : {
2910 0 : static const char* pEnv = getenv( "SAL_FLOATWIN_NOAPPFOCUSCLOSE" );
2911 0 : if ( !(pSVData->maWinData.mpFirstFloat->GetPopupModeFlags() & FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE) && !(pEnv && *pEnv) )
2912 0 : pSVData->maWinData.mpFirstFloat->EndPopupMode( FLOATWIN_POPUPMODEEND_CANCEL | FLOATWIN_POPUPMODEEND_CLOSEALL );
2913 : }
2914 : }
2915 :
2916 0 : return nRet;
2917 : }
2918 :
2919 : // F10 means either KEY_F10 or KEY_MENU, which has to be decided
2920 : // in the independent part.
2921 : struct KeyAlternate
2922 : {
2923 : sal_uInt16 nKeyCode;
2924 : sal_Unicode nCharCode;
2925 0 : KeyAlternate() : nKeyCode( 0 ), nCharCode( 0 ) {}
2926 0 : KeyAlternate( sal_uInt16 nKey, sal_Unicode nChar = 0 ) : nKeyCode( nKey ), nCharCode( nChar ) {}
2927 : };
2928 :
2929 : inline KeyAlternate
2930 0 : GetAlternateKeyCode( const sal_uInt16 nKeyCode )
2931 : {
2932 0 : KeyAlternate aAlternate;
2933 :
2934 0 : switch( nKeyCode )
2935 : {
2936 0 : case KEY_F10: aAlternate = KeyAlternate( KEY_MENU );break;
2937 0 : case KEY_F24: aAlternate = KeyAlternate( KEY_SUBTRACT, '-' );break;
2938 : }
2939 :
2940 0 : return aAlternate;
2941 : }
2942 :
2943 0 : void X11SalFrame::beginUnicodeSequence()
2944 : {
2945 0 : rtl::OUString& rSeq( GetGenericData()->GetUnicodeCommand() );
2946 0 : DeletionListener aDeleteWatch( this );
2947 :
2948 0 : if( !rSeq.isEmpty() )
2949 0 : endUnicodeSequence();
2950 :
2951 0 : rSeq = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "u" ) );
2952 :
2953 0 : if( ! aDeleteWatch.isDeleted() )
2954 : {
2955 0 : sal_uInt16 nTextAttr = SAL_EXTTEXTINPUT_ATTR_UNDERLINE;
2956 0 : SalExtTextInputEvent aEv;
2957 0 : aEv.mnTime = 0;
2958 0 : aEv.maText = rSeq;
2959 0 : aEv.mpTextAttr = &nTextAttr;
2960 0 : aEv.mnCursorPos = 0;
2961 0 : aEv.mnDeltaStart = 0;
2962 0 : aEv.mnCursorFlags = 0;
2963 0 : aEv.mbOnlyCursor = sal_False;
2964 :
2965 0 : CallCallback(SALEVENT_EXTTEXTINPUT, (void*)&aEv);
2966 0 : }
2967 0 : }
2968 :
2969 0 : bool X11SalFrame::appendUnicodeSequence( sal_Unicode c )
2970 : {
2971 0 : bool bRet = false;
2972 0 : rtl::OUString& rSeq( GetGenericData()->GetUnicodeCommand() );
2973 0 : if( !rSeq.isEmpty() )
2974 : {
2975 : // range check
2976 0 : if( (c >= sal_Unicode('0') && c <= sal_Unicode('9')) ||
2977 : (c >= sal_Unicode('a') && c <= sal_Unicode('f')) ||
2978 : (c >= sal_Unicode('A') && c <= sal_Unicode('F')) )
2979 : {
2980 0 : rtl::OUStringBuffer aBuf( rSeq.getLength() + 1 );
2981 0 : aBuf.append( rSeq );
2982 0 : aBuf.append( c );
2983 0 : rSeq = aBuf.makeStringAndClear();
2984 0 : std::vector<sal_uInt16> attribs( rSeq.getLength(), SAL_EXTTEXTINPUT_ATTR_UNDERLINE );
2985 :
2986 0 : SalExtTextInputEvent aEv;
2987 0 : aEv.mnTime = 0;
2988 0 : aEv.maText = rSeq;
2989 0 : aEv.mpTextAttr = &attribs[0];
2990 0 : aEv.mnCursorPos = 0;
2991 0 : aEv.mnDeltaStart = 0;
2992 0 : aEv.mnCursorFlags = 0;
2993 0 : aEv.mbOnlyCursor = sal_False;
2994 :
2995 0 : CallCallback(SALEVENT_EXTTEXTINPUT, (void*)&aEv);
2996 0 : bRet = true;
2997 : }
2998 : else
2999 0 : bRet = endUnicodeSequence();
3000 : }
3001 : else
3002 0 : endUnicodeSequence();
3003 0 : return bRet;
3004 : }
3005 :
3006 0 : bool X11SalFrame::endUnicodeSequence()
3007 : {
3008 0 : rtl::OUString& rSeq( GetGenericData()->GetUnicodeCommand() );
3009 :
3010 0 : DeletionListener aDeleteWatch( this );
3011 0 : if( rSeq.getLength() > 1 && rSeq.getLength() < 6 )
3012 : {
3013 : // cut the "u"
3014 0 : rtl::OUString aNumbers( rSeq.copy( 1 ) );
3015 0 : sal_Int32 nValue = aNumbers.toInt32( 16 );
3016 0 : if( nValue >= 32 )
3017 : {
3018 0 : sal_uInt16 nTextAttr = SAL_EXTTEXTINPUT_ATTR_UNDERLINE;
3019 0 : SalExtTextInputEvent aEv;
3020 0 : aEv.mnTime = 0;
3021 0 : aEv.maText = rtl::OUString( sal_Unicode(nValue) );
3022 0 : aEv.mpTextAttr = &nTextAttr;
3023 0 : aEv.mnCursorPos = 0;
3024 0 : aEv.mnDeltaStart = 0;
3025 0 : aEv.mnCursorFlags = 0;
3026 0 : aEv.mbOnlyCursor = sal_False;
3027 0 : CallCallback(SALEVENT_EXTTEXTINPUT, (void*)&aEv);
3028 0 : }
3029 : }
3030 0 : bool bWasInput = !rSeq.isEmpty();
3031 0 : rSeq = rtl::OUString();
3032 0 : if( bWasInput && ! aDeleteWatch.isDeleted() )
3033 0 : CallCallback(SALEVENT_ENDEXTTEXTINPUT, NULL);
3034 0 : return bWasInput;
3035 : }
3036 :
3037 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3038 0 : long X11SalFrame::HandleKeyEvent( XKeyEvent *pEvent )
3039 : {
3040 : KeySym nKeySym;
3041 : KeySym nUnmodifiedKeySym;
3042 0 : int nLen = 2048;
3043 0 : unsigned char *pPrintable = (unsigned char*)alloca( nLen );
3044 :
3045 : // singlebyte code composed by input method, the new default
3046 0 : if (mpInputContext != NULL && mpInputContext->UseContext())
3047 : {
3048 : // returns a keysym as well as the pPrintable (in system encoding)
3049 : // printable may be empty.
3050 : Status nStatus;
3051 : nKeySym = pDisplay_->GetKeySym( pEvent, pPrintable, &nLen,
3052 : &nUnmodifiedKeySym,
3053 0 : &nStatus, mpInputContext->GetContext() );
3054 0 : if ( nStatus == XBufferOverflow )
3055 : {
3056 0 : nLen *= 2;
3057 0 : pPrintable = (unsigned char*)alloca( nLen );
3058 : nKeySym = pDisplay_->GetKeySym( pEvent, pPrintable, &nLen,
3059 : &nUnmodifiedKeySym,
3060 0 : &nStatus, mpInputContext->GetContext() );
3061 : }
3062 : }
3063 : else
3064 : {
3065 : // fallback, this should never ever be called
3066 0 : Status nStatus = 0;
3067 0 : nKeySym = pDisplay_->GetKeySym( pEvent, pPrintable, &nLen, &nUnmodifiedKeySym, &nStatus );
3068 : }
3069 :
3070 : SalKeyEvent aKeyEvt;
3071 : sal_uInt16 nKeyCode;
3072 0 : sal_uInt16 nModCode = 0;
3073 : char aDummy;
3074 :
3075 0 : if( pEvent->state & ShiftMask )
3076 0 : nModCode |= KEY_SHIFT;
3077 0 : if( pEvent->state & ControlMask )
3078 0 : nModCode |= KEY_MOD1;
3079 0 : if( pEvent->state & Mod1Mask )
3080 0 : nModCode |= KEY_MOD2;
3081 :
3082 0 : if( nModCode != (KEY_SHIFT|KEY_MOD1) )
3083 0 : endUnicodeSequence();
3084 :
3085 0 : if( nKeySym == XK_Shift_L || nKeySym == XK_Shift_R
3086 : || nKeySym == XK_Control_L || nKeySym == XK_Control_R
3087 : || nKeySym == XK_Alt_L || nKeySym == XK_Alt_R
3088 : || nKeySym == XK_Meta_L || nKeySym == XK_Meta_R
3089 : || nKeySym == XK_Super_L || nKeySym == XK_Super_R )
3090 : {
3091 : SalKeyModEvent aModEvt;
3092 0 : aModEvt.mnModKeyCode = 0;
3093 0 : if( pEvent->type == XLIB_KeyPress && mnExtKeyMod == 0 )
3094 0 : mbSendExtKeyModChange = true;
3095 0 : else if( pEvent->type == KeyRelease && mbSendExtKeyModChange )
3096 : {
3097 0 : aModEvt.mnModKeyCode = mnExtKeyMod;
3098 0 : mnExtKeyMod = 0;
3099 : }
3100 :
3101 : // pressing just the ctrl key leads to a keysym of XK_Control but
3102 : // the event state does not contain ControlMask. In the release
3103 : // event its the other way round: it does contain the Control mask.
3104 : // The modifier mode therefore has to be adapted manually.
3105 0 : sal_uInt16 nExtModMask = 0;
3106 0 : sal_uInt16 nModMask = 0;
3107 0 : switch( nKeySym )
3108 : {
3109 : case XK_Control_L:
3110 0 : nExtModMask = MODKEY_LMOD1;
3111 0 : nModMask = KEY_MOD1;
3112 0 : break;
3113 : case XK_Control_R:
3114 0 : nExtModMask = MODKEY_RMOD1;
3115 0 : nModMask = KEY_MOD1;
3116 0 : break;
3117 : case XK_Alt_L:
3118 0 : nExtModMask = MODKEY_LMOD2;
3119 0 : nModMask = KEY_MOD2;
3120 0 : break;
3121 : case XK_Alt_R:
3122 0 : nExtModMask = MODKEY_RMOD2;
3123 0 : nModMask = KEY_MOD2;
3124 0 : break;
3125 : case XK_Shift_L:
3126 0 : nExtModMask = MODKEY_LSHIFT;
3127 0 : nModMask = KEY_SHIFT;
3128 0 : break;
3129 : case XK_Shift_R:
3130 0 : nExtModMask = MODKEY_RSHIFT;
3131 0 : nModMask = KEY_SHIFT;
3132 0 : break;
3133 : // Map Meta/Super keys to MOD3 modifier on all Unix systems
3134 : // except Mac OS X
3135 : case XK_Meta_L:
3136 : case XK_Super_L:
3137 0 : nExtModMask = MODKEY_LMOD3;
3138 0 : nModMask = KEY_MOD3;
3139 0 : break;
3140 : case XK_Meta_R:
3141 : case XK_Super_R:
3142 0 : nExtModMask = MODKEY_RMOD3;
3143 0 : nModMask = KEY_MOD3;
3144 0 : break;
3145 : }
3146 0 : if( pEvent->type == KeyRelease )
3147 : {
3148 0 : nModCode &= ~nModMask;
3149 0 : mnExtKeyMod &= ~nExtModMask;
3150 : }
3151 : else
3152 : {
3153 0 : nModCode |= nModMask;
3154 0 : mnExtKeyMod |= nExtModMask;
3155 : }
3156 :
3157 0 : aModEvt.mnCode = nModCode;
3158 0 : aModEvt.mnTime = pEvent->time;
3159 :
3160 0 : int nRet = CallCallback( SALEVENT_KEYMODCHANGE, &aModEvt );
3161 :
3162 0 : return nRet;
3163 : }
3164 :
3165 0 : mbSendExtKeyModChange = false;
3166 :
3167 : // try to figure out the vcl code for the keysym
3168 : // #i52338# use the unmodified KeySym if there is none for the real KeySym
3169 : // because the independent part has only keycodes for unshifted keys
3170 0 : nKeyCode = pDisplay_->GetKeyCode( nKeySym, &aDummy );
3171 0 : if( nKeyCode == 0 )
3172 0 : nKeyCode = pDisplay_->GetKeyCode( nUnmodifiedKeySym, &aDummy );
3173 :
3174 : // try to figure out a printable if XmbLookupString returns only a keysym
3175 : // and NOT a printable. Do not store it in pPrintable[0] since it is expected to
3176 : // be in system encoding, not unicode.
3177 : // #i8988##, if KeySym and printable look equally promising then prefer KeySym
3178 : // the printable is bound to the encoding so the KeySym might contain more
3179 : // information (in et_EE locale: "Compose + Z + <" delivers "," in printable and
3180 : // (the desired) Zcaron in KeySym
3181 0 : sal_Unicode nKeyString = 0x0;
3182 0 : if ( (nLen == 0)
3183 : || ((nLen == 1) && (nKeySym > 0)) )
3184 0 : nKeyString = KeysymToUnicode (nKeySym);
3185 : // if we have nothing we give up
3186 0 : if( !nKeyCode && !nLen && !nKeyString)
3187 0 : return 0;
3188 :
3189 0 : DeletionListener aDeleteWatch( this );
3190 :
3191 0 : if( nModCode == (KEY_SHIFT | KEY_MOD1) && pEvent->type == XLIB_KeyPress )
3192 : {
3193 0 : sal_uInt16 nSeqKeyCode = pDisplay_->GetKeyCode( nUnmodifiedKeySym, &aDummy );
3194 0 : if( nSeqKeyCode == KEY_U )
3195 : {
3196 0 : beginUnicodeSequence();
3197 0 : return 1;
3198 : }
3199 0 : else if( nSeqKeyCode >= KEY_0 && nSeqKeyCode <= KEY_9 )
3200 : {
3201 0 : if( appendUnicodeSequence( sal_Unicode( '0' ) + sal_Unicode(nSeqKeyCode - KEY_0) ) )
3202 0 : return 1;
3203 : }
3204 0 : else if( nSeqKeyCode >= KEY_A && nSeqKeyCode <= KEY_F )
3205 : {
3206 0 : if( appendUnicodeSequence( sal_Unicode( 'a' ) + sal_Unicode(nSeqKeyCode - KEY_A) ) )
3207 0 : return 1;
3208 : }
3209 : else
3210 0 : endUnicodeSequence();
3211 : }
3212 :
3213 0 : if( aDeleteWatch.isDeleted() )
3214 0 : return 0;
3215 :
3216 0 : rtl_TextEncoding nEncoding = osl_getThreadTextEncoding();
3217 :
3218 : sal_Unicode *pBuffer;
3219 : sal_Unicode *pString;
3220 0 : sal_Size nBufferSize = nLen * 2;
3221 : sal_Size nSize;
3222 0 : pBuffer = (sal_Unicode*) malloc( nBufferSize + 2 );
3223 0 : pBuffer[ 0 ] = 0;
3224 :
3225 0 : if (nKeyString != 0)
3226 : {
3227 0 : pString = &nKeyString;
3228 0 : nSize = 1;
3229 : }
3230 : else
3231 0 : if (nLen > 0 && nEncoding != RTL_TEXTENCODING_UNICODE)
3232 : {
3233 : // create text converter
3234 : rtl_TextToUnicodeConverter aConverter =
3235 0 : rtl_createTextToUnicodeConverter( nEncoding );
3236 : rtl_TextToUnicodeContext aContext =
3237 0 : rtl_createTextToUnicodeContext( aConverter );
3238 :
3239 : sal_uInt32 nConversionInfo;
3240 : sal_Size nConvertedChars;
3241 :
3242 : // convert to single byte text stream
3243 : nSize = rtl_convertTextToUnicode(
3244 : aConverter, aContext,
3245 : (char*)pPrintable, nLen,
3246 : pBuffer, nBufferSize,
3247 : RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE |
3248 : RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE,
3249 0 : &nConversionInfo, &nConvertedChars );
3250 :
3251 : // destroy converter
3252 0 : rtl_destroyTextToUnicodeContext( aConverter, aContext );
3253 0 : rtl_destroyTextToUnicodeConverter( aConverter );
3254 :
3255 0 : pString = pBuffer;
3256 : }
3257 : else
3258 0 : if (nLen > 0 /* nEncoding == RTL_TEXTENCODING_UNICODE */)
3259 : {
3260 0 : pString = (sal_Unicode*)pPrintable;
3261 0 : nSize = nLen;
3262 : }
3263 : else
3264 : {
3265 0 : pString = pBuffer;
3266 0 : nSize = 0;
3267 : }
3268 :
3269 0 : if ( mpInputContext != NULL
3270 0 : && mpInputContext->UseContext()
3271 : && KeyRelease != pEvent->type
3272 : && ( (nSize > 1)
3273 0 : || (nSize > 0 && mpInputContext->IsPreeditMode())) )
3274 : {
3275 0 : mpInputContext->CommitKeyEvent(pString, nSize);
3276 : }
3277 : else
3278 : // normal single character keyinput
3279 : {
3280 0 : aKeyEvt.mnCode = nKeyCode | nModCode;
3281 0 : aKeyEvt.mnRepeat = 0;
3282 0 : aKeyEvt.mnTime = pEvent->time;
3283 0 : aKeyEvt.mnCharCode = pString[ 0 ];
3284 :
3285 0 : if( KeyRelease == pEvent->type )
3286 : {
3287 0 : CallCallback( SALEVENT_KEYUP, &aKeyEvt );
3288 : }
3289 : else
3290 : {
3291 0 : if ( ! CallCallback(SALEVENT_KEYINPUT, &aKeyEvt) )
3292 : {
3293 : // independent layer doesnt want to handle key-event, so check
3294 : // whether the keycode may have an alternate meaning
3295 0 : KeyAlternate aAlternate = GetAlternateKeyCode( nKeyCode );
3296 0 : if ( aAlternate.nKeyCode != 0 )
3297 : {
3298 0 : aKeyEvt.mnCode = aAlternate.nKeyCode | nModCode;
3299 0 : if( aAlternate.nCharCode )
3300 0 : aKeyEvt.mnCharCode = aAlternate.nCharCode;
3301 0 : CallCallback(SALEVENT_KEYINPUT, &aKeyEvt);
3302 : }
3303 : }
3304 : }
3305 : }
3306 :
3307 : //
3308 : // update the spot location for PreeditPosition IME style
3309 : //
3310 0 : if (! aDeleteWatch.isDeleted())
3311 : {
3312 0 : if (mpInputContext != NULL && mpInputContext->UseContext())
3313 0 : mpInputContext->UpdateSpotLocation();
3314 : }
3315 :
3316 0 : free (pBuffer);
3317 0 : return True;
3318 : }
3319 :
3320 :
3321 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3322 0 : long X11SalFrame::HandleFocusEvent( XFocusChangeEvent *pEvent )
3323 : {
3324 : // ReflectionX in Windows mode changes focus while mouse is grabbed
3325 0 : if( nVisibleFloats > 0 && GetDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii( "ReflectionX Windows" ) )
3326 0 : return 1;
3327 :
3328 : /* ignore focusout resulting from keyboard grabs
3329 : * we do not grab it and are not interested when
3330 : * someone else does CDE e.g. does a XGrabKey on arrow keys
3331 : * handle focus events with mode NotifyWhileGrabbed
3332 : * because with CDE alt-tab focus changing we do not get
3333 : * normal focus events
3334 : * cast focus event to the input context, otherwise the
3335 : * status window does not follow the application frame
3336 : */
3337 :
3338 0 : if ( mpInputContext != NULL )
3339 : {
3340 0 : if( FocusIn == pEvent->type )
3341 0 : mpInputContext->SetICFocus( this );
3342 : else
3343 : {
3344 : /*
3345 : * do not unset the IC focuse here because would kill
3346 : * a lookup choice windows that might have the focus now
3347 : * mpInputContext->UnsetICFocus( this );
3348 : */
3349 0 : I18NStatus::get().show( false, I18NStatus::focus );
3350 : }
3351 : }
3352 :
3353 :
3354 0 : if ( pEvent->mode == NotifyNormal || pEvent->mode == NotifyWhileGrabbed ||
3355 0 : ( ( nStyle_ & SAL_FRAME_STYLE_PLUG ) && pEvent->window == GetShellWindow() )
3356 : )
3357 : {
3358 0 : if( hPresentationWindow != None && hPresentationWindow != GetShellWindow() )
3359 0 : return 0;
3360 :
3361 0 : if( FocusIn == pEvent->type )
3362 : {
3363 0 : GetSalData()->m_pInstance->updatePrinterUpdate();
3364 0 : mbInputFocus = True;
3365 0 : ImplSVData* pSVData = ImplGetSVData();
3366 :
3367 :
3368 :
3369 0 : long nRet = CallCallback( SALEVENT_GETFOCUS, 0 );
3370 0 : if ((mpParent != NULL && nStyle_ == 0)
3371 : && pSVData->maWinData.mpFirstFloat )
3372 : {
3373 0 : sal_uLong nMode = pSVData->maWinData.mpFirstFloat->GetPopupModeFlags();
3374 : pSVData->maWinData.mpFirstFloat->SetPopupModeFlags(
3375 0 : nMode & ~(FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE));
3376 : }
3377 0 : return nRet;
3378 : }
3379 : else
3380 : {
3381 0 : mbInputFocus = False;
3382 0 : mbSendExtKeyModChange = false;
3383 0 : mnExtKeyMod = 0;
3384 0 : return CallCallback( SALEVENT_LOSEFOCUS, 0 );
3385 : }
3386 : }
3387 :
3388 0 : return 0;
3389 : }
3390 :
3391 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3392 :
3393 0 : long X11SalFrame::HandleExposeEvent( XEvent *pEvent )
3394 : {
3395 0 : XRectangle aRect = { 0, 0, 0, 0 };
3396 0 : sal_uInt16 nCount = 0;
3397 :
3398 0 : if( pEvent->type == Expose )
3399 : {
3400 0 : aRect.x = pEvent->xexpose.x;
3401 0 : aRect.y = pEvent->xexpose.y;
3402 0 : aRect.width = pEvent->xexpose.width;
3403 0 : aRect.height = pEvent->xexpose.height;
3404 0 : nCount = pEvent->xexpose.count;
3405 : }
3406 0 : else if( pEvent->type == GraphicsExpose )
3407 : {
3408 0 : aRect.x = pEvent->xgraphicsexpose.x;
3409 0 : aRect.y = pEvent->xgraphicsexpose.y;
3410 0 : aRect.width = pEvent->xgraphicsexpose.width;
3411 0 : aRect.height = pEvent->xgraphicsexpose.height;
3412 0 : nCount = pEvent->xgraphicsexpose.count;
3413 : }
3414 :
3415 0 : if( IsOverrideRedirect() && mbFullScreen &&
3416 0 : aPresentationReparentList.begin() == aPresentationReparentList.end() )
3417 : // we are in fullscreen mode -> override redirect
3418 : // focus is possibly lost, so reget it
3419 0 : XSetInputFocus( GetXDisplay(), GetShellWindow(), RevertToNone, CurrentTime );
3420 :
3421 : // width and height are extents, so they are of by one for rectangle
3422 0 : maPaintRegion.Union( Rectangle( Point(aRect.x, aRect.y), Size(aRect.width+1, aRect.height+1) ) );
3423 :
3424 0 : if( nCount )
3425 : // wait for last expose rectangle, do not wait for resize timer
3426 : // if a completed graphics expose sequence is available
3427 0 : return 1;
3428 :
3429 0 : SalPaintEvent aPEvt( maPaintRegion.Left(), maPaintRegion.Top(), maPaintRegion.GetWidth(), maPaintRegion.GetHeight() );
3430 :
3431 0 : CallCallback( SALEVENT_PAINT, &aPEvt );
3432 0 : maPaintRegion = Rectangle();
3433 :
3434 0 : return 1;
3435 : }
3436 :
3437 0 : void X11SalFrame::RestackChildren( XLIB_Window* pTopLevelWindows, int nTopLevelWindows )
3438 : {
3439 0 : if( maChildren.begin() != maChildren.end() )
3440 : {
3441 0 : int nWindow = nTopLevelWindows;
3442 0 : while( nWindow-- )
3443 0 : if( pTopLevelWindows[nWindow] == GetStackingWindow() )
3444 0 : break;
3445 0 : if( nWindow < 0 )
3446 0 : return;
3447 :
3448 0 : std::list< X11SalFrame* >::const_iterator it;
3449 0 : for( it = maChildren.begin(); it != maChildren.end(); ++it )
3450 : {
3451 0 : X11SalFrame* pData = *it;
3452 0 : if( pData->bMapped_ )
3453 : {
3454 0 : int nChild = nWindow;
3455 0 : while( nChild-- )
3456 : {
3457 0 : if( pTopLevelWindows[nChild] == pData->GetStackingWindow() )
3458 : {
3459 : // if a child is behind its parent, place it above the
3460 : // parent (for insane WMs like Dtwm and olwm)
3461 : XWindowChanges aCfg;
3462 0 : aCfg.sibling = GetStackingWindow();
3463 0 : aCfg.stack_mode = Above;
3464 0 : XConfigureWindow( GetXDisplay(), pData->GetStackingWindow(), CWSibling|CWStackMode, &aCfg );
3465 : break;
3466 : }
3467 : }
3468 : }
3469 : }
3470 0 : for( it = maChildren.begin(); it != maChildren.end(); ++it )
3471 : {
3472 0 : X11SalFrame* pData = *it;
3473 0 : pData->RestackChildren( pTopLevelWindows, nTopLevelWindows );
3474 : }
3475 : }
3476 : }
3477 :
3478 0 : void X11SalFrame::RestackChildren()
3479 : {
3480 0 : if( ! GetDisplay()->getWMAdaptor()->isTransientBehaviourAsExpected()
3481 0 : && maChildren.begin() != maChildren.end() )
3482 : {
3483 0 : XLIB_Window aRoot, aParent, *pChildren = NULL;
3484 : unsigned int nChildren;
3485 0 : if( XQueryTree( GetXDisplay(),
3486 : GetDisplay()->GetRootWindow( m_nXScreen ),
3487 : &aRoot,
3488 : &aParent,
3489 : &pChildren,
3490 0 : &nChildren ) )
3491 : {
3492 0 : RestackChildren( pChildren, nChildren );
3493 0 : XFree( pChildren );
3494 : }
3495 : }
3496 0 : }
3497 :
3498 0 : static Bool size_event_predicate( Display*, XEvent* event, XPointer arg )
3499 : {
3500 0 : if( event->type != ConfigureNotify )
3501 0 : return False;
3502 0 : X11SalFrame* frame = reinterpret_cast< X11SalFrame* >( arg );
3503 0 : XConfigureEvent* pEvent = &event->xconfigure;
3504 0 : if( pEvent->window != frame->GetShellWindow()
3505 0 : && pEvent->window != frame->GetWindow()
3506 0 : && pEvent->window != frame->GetForeignParent()
3507 0 : && pEvent->window != frame->GetStackingWindow())
3508 : { // ignored at top of HandleSizeEvent()
3509 0 : return False;
3510 : }
3511 0 : if( pEvent->window == frame->GetStackingWindow())
3512 0 : return False; // filtered later in HandleSizeEvent()
3513 : // at this point we know that there is another similar event in the queue
3514 0 : frame->setPendingSizeEvent();
3515 0 : return False; // but do not process the new event out of order
3516 : }
3517 :
3518 0 : void X11SalFrame::setPendingSizeEvent()
3519 : {
3520 0 : mPendingSizeEvent = true;
3521 0 : }
3522 :
3523 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3524 0 : long X11SalFrame::HandleSizeEvent( XConfigureEvent *pEvent )
3525 : {
3526 : // NOTE: if you add more tests in this function, make sure to update size_event_predicate()
3527 : // so that it finds exactly the same events
3528 :
3529 0 : if ( pEvent->window != GetShellWindow()
3530 0 : && pEvent->window != GetWindow()
3531 0 : && pEvent->window != GetForeignParent()
3532 0 : && pEvent->window != GetStackingWindow()
3533 : )
3534 : {
3535 : // could be as well a sys-child window (aka SalObject)
3536 0 : return 1;
3537 : }
3538 :
3539 :
3540 0 : if( ( nStyle_ & SAL_FRAME_STYLE_PLUG ) && pEvent->window == GetShellWindow() )
3541 : {
3542 : // just update the children's positions
3543 0 : RestackChildren();
3544 0 : return 1;
3545 : }
3546 :
3547 0 : if( pEvent->window == GetForeignParent() )
3548 : XResizeWindow( GetXDisplay(),
3549 : GetWindow(),
3550 : pEvent->width,
3551 0 : pEvent->height );
3552 :
3553 : XLIB_Window hDummy;
3554 : XTranslateCoordinates( GetXDisplay(),
3555 : GetWindow(),
3556 : pDisplay_->GetRootWindow( pDisplay_->GetDefaultXScreen() ),
3557 : 0, 0,
3558 : &pEvent->x, &pEvent->y,
3559 0 : &hDummy );
3560 :
3561 0 : if( pEvent->window == GetStackingWindow() )
3562 : {
3563 0 : if( maGeometry.nX != pEvent->x || maGeometry.nY != pEvent->y )
3564 : {
3565 0 : maGeometry.nX = pEvent->x;
3566 0 : maGeometry.nY = pEvent->y;
3567 0 : CallCallback( SALEVENT_MOVE, NULL );
3568 : }
3569 0 : return 1;
3570 : }
3571 :
3572 : // check size hints in first time SalFrame::Show
3573 0 : if( SHOWSTATE_UNKNOWN == nShowState_ && bMapped_ )
3574 0 : nShowState_ = SHOWSTATE_NORMAL;
3575 :
3576 : // Avoid a race condition where resizing this window to one size and shortly after that
3577 : // to another size generates first size event with the old size and only after that
3578 : // with the new size, temporarily making us think the old size is valid (bnc#674806).
3579 : // So if there is another size event for this window pending, ignore this one.
3580 0 : mPendingSizeEvent = false;
3581 : XEvent dummy;
3582 0 : XCheckIfEvent( GetXDisplay(), &dummy, size_event_predicate, reinterpret_cast< XPointer >( this ));
3583 0 : if( mPendingSizeEvent )
3584 0 : return 1;
3585 :
3586 0 : nWidth_ = pEvent->width;
3587 0 : nHeight_ = pEvent->height;
3588 :
3589 0 : bool bMoved = ( pEvent->x != maGeometry.nX || pEvent->y != maGeometry.nY );
3590 0 : bool bSized = ( pEvent->width != (int)maGeometry.nWidth || pEvent->height != (int)maGeometry.nHeight );
3591 :
3592 0 : maGeometry.nX = pEvent->x;
3593 0 : maGeometry.nY = pEvent->y;
3594 0 : maGeometry.nWidth = pEvent->width;
3595 0 : maGeometry.nHeight = pEvent->height;
3596 0 : updateScreenNumber();
3597 :
3598 : // update children's position
3599 0 : RestackChildren();
3600 :
3601 0 : if( bSized && ! bMoved )
3602 0 : CallCallback( SALEVENT_RESIZE, NULL );
3603 0 : else if( bMoved && ! bSized )
3604 0 : CallCallback( SALEVENT_MOVE, NULL );
3605 0 : else if( bMoved && bSized )
3606 0 : CallCallback( SALEVENT_MOVERESIZE, NULL );
3607 :
3608 0 : return 1;
3609 : }
3610 :
3611 0 : IMPL_LINK_NOARG(X11SalFrame, HandleAlwaysOnTopRaise)
3612 : {
3613 0 : if( bMapped_ )
3614 0 : ToTop( 0 );
3615 0 : return 0;
3616 : }
3617 :
3618 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3619 0 : long X11SalFrame::HandleReparentEvent( XReparentEvent *pEvent )
3620 : {
3621 0 : Display *pDisplay = pEvent->display;
3622 : XLIB_Window hWM_Parent;
3623 : XLIB_Window hRoot, *Children, hDummy;
3624 : unsigned int nChildren;
3625 0 : sal_Bool bNone = pDisplay_->GetProperties()
3626 0 : & PROPERTY_SUPPORT_WM_Parent_Pixmap_None;
3627 0 : sal_Bool bAccessParentWindow = ! (pDisplay_->GetProperties()
3628 0 : & PROPERTY_FEATURE_TrustedSolaris);
3629 :
3630 0 : static const char* pDisableStackingCheck = getenv( "SAL_DISABLE_STACKING_CHECK" );
3631 :
3632 0 : GetGenericData()->ErrorTrapPush();
3633 :
3634 : /*
3635 : * don't rely on the new parent from the event.
3636 : * the event may be "out of date", that is the window manager
3637 : * window may not exist anymore. This can happen if someone
3638 : * shows a frame and hides it again quickly (not that that would
3639 : * be very sensible)
3640 : */
3641 0 : hWM_Parent = GetShellWindow();
3642 0 : do
3643 : {
3644 0 : Children = NULL;
3645 : XQueryTree( pDisplay,
3646 : hWM_Parent,
3647 : &hRoot,
3648 : &hDummy,
3649 : &Children,
3650 0 : &nChildren );
3651 :
3652 0 : bool bError = GetGenericData()->ErrorTrapPop( false );
3653 0 : GetGenericData()->ErrorTrapPush();
3654 :
3655 0 : if( bError )
3656 : {
3657 0 : hWM_Parent = GetShellWindow();
3658 0 : break;
3659 : }
3660 : /* this sometimes happens if a Show(sal_True) is
3661 : * immediately followed by Show(sal_False) (which is braindead anyway)
3662 : */
3663 0 : if( hDummy == hWM_Parent )
3664 0 : hDummy = hRoot;
3665 0 : if( hDummy != hRoot )
3666 : {
3667 0 : hWM_Parent = hDummy;
3668 0 : if( bAccessParentWindow && bNone )
3669 0 : XSetWindowBackgroundPixmap( pDisplay, hWM_Parent, None );
3670 : }
3671 0 : if( Children )
3672 0 : XFree( Children );
3673 : } while( hDummy != hRoot );
3674 :
3675 0 : if( GetStackingWindow() == None
3676 : && hWM_Parent != hPresentationWindow
3677 0 : && hWM_Parent != GetShellWindow()
3678 0 : && ( ! pDisableStackingCheck || ! *pDisableStackingCheck )
3679 : )
3680 : {
3681 0 : mhStackingWindow = hWM_Parent;
3682 0 : if (bAccessParentWindow)
3683 0 : XSelectInput( pDisplay, GetStackingWindow(), StructureNotifyMask );
3684 : }
3685 :
3686 0 : if( hWM_Parent == pDisplay_->GetRootWindow( pDisplay_->GetDefaultXScreen() )
3687 0 : || hWM_Parent == GetForeignParent()
3688 0 : || pEvent->parent == pDisplay_->GetRootWindow( pDisplay_->GetDefaultXScreen() )
3689 : || ( nStyle_ & SAL_FRAME_STYLE_FLOAT ) )
3690 : {
3691 : // Reparenting before Destroy
3692 0 : aPresentationReparentList.remove( GetStackingWindow() );
3693 0 : mhStackingWindow = None;
3694 0 : GetGenericData()->ErrorTrapPop();
3695 0 : return 0;
3696 : }
3697 :
3698 : /*
3699 : * evil hack to show decorated windows on top
3700 : * of override redirect presentation windows:
3701 : * reparent the window manager window to the presentation window
3702 : * does not work with non-reparenting WMs
3703 : * in future this should not be necessary anymore with
3704 : * _NET_WM_STATE_FULLSCREEN available
3705 : */
3706 0 : if( hPresentationWindow != None
3707 0 : && hPresentationWindow != GetWindow()
3708 0 : && GetStackingWindow() != None
3709 0 : && GetStackingWindow() != GetDisplay()->GetRootWindow( m_nXScreen )
3710 : )
3711 : {
3712 0 : int x = 0, y = 0;
3713 : XLIB_Window aChild;
3714 : XTranslateCoordinates( GetXDisplay(),
3715 : GetStackingWindow(),
3716 : GetDisplay()->GetRootWindow( m_nXScreen ),
3717 : 0, 0,
3718 : &x, &y,
3719 : &aChild
3720 0 : );
3721 : XReparentWindow( GetXDisplay(),
3722 : GetStackingWindow(),
3723 : hPresentationWindow,
3724 : x, y
3725 0 : );
3726 0 : aPresentationReparentList.push_back( GetStackingWindow() );
3727 : }
3728 :
3729 0 : int nLeft = 0, nTop = 0;
3730 : XTranslateCoordinates( GetXDisplay(),
3731 : GetShellWindow(),
3732 : hWM_Parent,
3733 : 0, 0,
3734 : &nLeft,
3735 : &nTop,
3736 0 : &hDummy );
3737 0 : maGeometry.nLeftDecoration = nLeft > 0 ? nLeft-1 : 0;
3738 0 : maGeometry.nTopDecoration = nTop > 0 ? nTop-1 : 0;
3739 :
3740 : /*
3741 : * decorations are not symmetric,
3742 : * so need real geometries here
3743 : * (this will fail with virtual roots ?)
3744 : */
3745 :
3746 : // reset error occurred
3747 0 : GetGenericData()->ErrorTrapPop();
3748 0 : GetGenericData()->ErrorTrapPush();
3749 :
3750 : int xp, yp, x, y;
3751 : unsigned int wp, w, hp, h, bw, d;
3752 : XGetGeometry( GetXDisplay(),
3753 : GetShellWindow(),
3754 : &hRoot,
3755 0 : &x, &y, &w, &h, &bw, &d );
3756 : XGetGeometry( GetXDisplay(),
3757 : hWM_Parent,
3758 : &hRoot,
3759 0 : &xp, &yp, &wp, &hp, &bw, &d );
3760 0 : bool bResized = false;
3761 0 : bool bError = GetGenericData()->ErrorTrapPop( false );
3762 0 : GetGenericData()->ErrorTrapPush();
3763 :
3764 0 : if( ! bError )
3765 : {
3766 0 : maGeometry.nRightDecoration = wp - w - maGeometry.nLeftDecoration;
3767 0 : maGeometry.nBottomDecoration = hp - h - maGeometry.nTopDecoration;
3768 : /*
3769 : * note: this works because hWM_Parent is direct child of root,
3770 : * not necessarily parent of GetShellWindow()
3771 : */
3772 0 : maGeometry.nX = xp + nLeft;
3773 0 : maGeometry.nY = yp + nTop;
3774 0 : bResized = w != maGeometry.nWidth || h != maGeometry.nHeight;
3775 0 : maGeometry.nWidth = w;
3776 0 : maGeometry.nHeight = h;
3777 : }
3778 :
3779 : // limit width and height if we are too large: #47757
3780 : // olwm and fvwm need this, it doesnt harm the rest
3781 :
3782 : // #i81311# do this only for sizable frames
3783 0 : if( (nStyle_ & SAL_FRAME_STYLE_SIZEABLE) != 0 )
3784 : {
3785 0 : Size aScreenSize = GetDisplay()->GetScreenSize( m_nXScreen );
3786 0 : int nScreenWidth = aScreenSize.Width();
3787 0 : int nScreenHeight = aScreenSize.Height();
3788 0 : int nFrameWidth = maGeometry.nWidth + maGeometry.nLeftDecoration + maGeometry.nRightDecoration;
3789 0 : int nFrameHeight = maGeometry.nHeight + maGeometry.nTopDecoration + maGeometry.nBottomDecoration;
3790 :
3791 0 : if ((nFrameWidth > nScreenWidth) || (nFrameHeight > nScreenHeight))
3792 : {
3793 0 : Size aSize(maGeometry.nWidth, maGeometry.nHeight);
3794 :
3795 0 : if (nFrameWidth > nScreenWidth)
3796 0 : aSize.Width() = nScreenWidth - maGeometry.nRightDecoration - maGeometry.nLeftDecoration;
3797 0 : if (nFrameHeight > nScreenHeight)
3798 0 : aSize.Height() = nScreenHeight - maGeometry.nBottomDecoration - maGeometry.nTopDecoration;
3799 :
3800 0 : SetSize( aSize );
3801 0 : bResized = false;
3802 : }
3803 : }
3804 0 : if( bResized )
3805 0 : CallCallback( SALEVENT_RESIZE, NULL );
3806 :
3807 0 : GetGenericData()->ErrorTrapPop();
3808 :
3809 0 : return 1;
3810 : }
3811 :
3812 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3813 0 : long X11SalFrame::HandleColormapEvent( XColormapEvent* )
3814 : {
3815 0 : return 0;
3816 : }
3817 :
3818 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3819 0 : long X11SalFrame::HandleStateEvent( XPropertyEvent *pEvent )
3820 : {
3821 : Atom actual_type;
3822 : int actual_format;
3823 : unsigned long nitems, bytes_after;
3824 0 : unsigned char *prop = NULL;
3825 :
3826 0 : if( 0 != XGetWindowProperty( GetXDisplay(),
3827 : GetShellWindow(),
3828 : pEvent->atom, // property
3829 : 0, // long_offset (32bit)
3830 : 2, // long_length (32bit)
3831 : False, // delete
3832 : pEvent->atom, // req_type
3833 : &actual_type,
3834 : &actual_format,
3835 : &nitems,
3836 : &bytes_after,
3837 0 : &prop )
3838 0 : || ! prop
3839 : )
3840 0 : return 0;
3841 :
3842 : DBG_ASSERT( actual_type = pEvent->atom
3843 : && 32 == actual_format
3844 : && 2 == nitems
3845 : && 0 == bytes_after, "HandleStateEvent" );
3846 :
3847 0 : if( *(unsigned long*)prop == NormalState )
3848 0 : nShowState_ = SHOWSTATE_NORMAL;
3849 0 : else if( *(unsigned long*)prop == IconicState )
3850 0 : nShowState_ = SHOWSTATE_MINIMIZED;
3851 :
3852 0 : XFree( prop );
3853 0 : return 1;
3854 : }
3855 :
3856 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3857 0 : long X11SalFrame::HandleClientMessage( XClientMessageEvent *pEvent )
3858 : {
3859 0 : const WMAdaptor& rWMAdaptor( *pDisplay_->getWMAdaptor() );
3860 :
3861 : #if !defined(__synchronous_extinput__)
3862 0 : if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::SAL_EXTTEXTEVENT ) )
3863 : {
3864 0 : HandleExtTextEvent (pEvent);
3865 0 : return 1;
3866 : }
3867 : #endif
3868 0 : else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::SAL_QUITEVENT ) )
3869 : {
3870 : stderr0( "X11SalFrame::Dispatch Quit\n" );
3871 0 : Close(); // ???
3872 0 : return 1;
3873 : }
3874 0 : else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::WM_PROTOCOLS ) )
3875 : {
3876 0 : if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::NET_WM_PING ) )
3877 0 : rWMAdaptor.answerPing( this, pEvent );
3878 0 : else if( ! ( nStyle_ & SAL_FRAME_STYLE_PLUG )
3879 0 : && ! (( nStyle_ & SAL_FRAME_STYLE_FLOAT ) && (nStyle_ & SAL_FRAME_STYLE_OWNERDRAWDECORATION))
3880 : )
3881 : {
3882 0 : if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_DELETE_WINDOW ) )
3883 : {
3884 0 : Close();
3885 0 : return 1;
3886 : }
3887 0 : else if( (Atom)pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_TAKE_FOCUS ) )
3888 : {
3889 : // do nothing, we set the input focus in ToTop() if necessary
3890 : #if OSL_DEBUG_LEVEL > 1
3891 : fprintf( stderr, "got WM_TAKE_FOCUS on %s window\n",
3892 : (nStyle_&SAL_FRAME_STYLE_OWNERDRAWDECORATION) ?
3893 : "ownerdraw" : "NON OWNERDRAW" );
3894 : #endif
3895 : }
3896 : }
3897 : }
3898 0 : else if( pEvent->message_type == rWMAdaptor.getAtom( WMAdaptor::XEMBED ) &&
3899 0 : pEvent->window == GetWindow() )
3900 : {
3901 0 : if( pEvent->data.l[1] == 1 || // XEMBED_WINDOW_ACTIVATE
3902 0 : pEvent->data.l[1] == 2 ) // XEMBED_WINDOW_DEACTIVATE
3903 : {
3904 : XFocusChangeEvent aEvent;
3905 0 : aEvent.type = (pEvent->data.l[1] == 1 ? FocusIn : FocusOut);
3906 0 : aEvent.serial = pEvent->serial;
3907 0 : aEvent.send_event = True;
3908 0 : aEvent.display = pEvent->display;
3909 0 : aEvent.window = pEvent->window;
3910 0 : aEvent.mode = NotifyNormal;
3911 0 : aEvent.detail = NotifyDetailNone;
3912 0 : HandleFocusEvent( &aEvent );
3913 : }
3914 : }
3915 0 : return 0;
3916 : }
3917 :
3918 : // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
3919 :
3920 : extern "C"
3921 : {
3922 0 : Bool call_checkKeyReleaseForRepeat( Display* pDisplay, XEvent* pCheck, XPointer pX11SalFrame )
3923 : {
3924 0 : return X11SalFrame::checkKeyReleaseForRepeat( pDisplay, pCheck, pX11SalFrame );
3925 : }
3926 : }
3927 :
3928 0 : Bool X11SalFrame::checkKeyReleaseForRepeat( Display*, XEvent* pCheck, XPointer pX11SalFrame )
3929 : {
3930 0 : X11SalFrame* pThis = (X11SalFrame*)pX11SalFrame;
3931 : return
3932 : pCheck->type == XLIB_KeyPress &&
3933 : pCheck->xkey.state == pThis->nKeyState_ &&
3934 : pCheck->xkey.keycode == pThis->nKeyCode_ &&
3935 0 : pCheck->xkey.time == pThis->nReleaseTime_ ? True : False;
3936 : }
3937 :
3938 0 : long X11SalFrame::Dispatch( XEvent *pEvent )
3939 : {
3940 0 : long nRet = 0;
3941 :
3942 0 : if( -1 == nCaptured_ )
3943 : {
3944 0 : CaptureMouse( sal_True );
3945 : #ifdef DBG_UTIL
3946 : if( -1 != nCaptured_ )
3947 : pDisplay_->DbgPrintDisplayEvent("Captured", pEvent);
3948 : #endif
3949 : }
3950 :
3951 0 : if( pEvent->xany.window == GetShellWindow() || pEvent->xany.window == GetWindow() )
3952 : {
3953 0 : switch( pEvent->type )
3954 : {
3955 : case XLIB_KeyPress:
3956 0 : nKeyCode_ = pEvent->xkey.keycode;
3957 0 : nKeyState_ = pEvent->xkey.state;
3958 0 : nRet = HandleKeyEvent( &pEvent->xkey );
3959 0 : break;
3960 :
3961 : case KeyRelease:
3962 0 : if( -1 == nCompose_ )
3963 : {
3964 0 : nReleaseTime_ = pEvent->xkey.time;
3965 : XEvent aEvent;
3966 0 : if( XCheckIfEvent( pEvent->xkey.display, &aEvent, call_checkKeyReleaseForRepeat, (XPointer)this ) )
3967 0 : XPutBackEvent( pEvent->xkey.display, &aEvent );
3968 : else
3969 0 : nRet = HandleKeyEvent( &pEvent->xkey );
3970 : }
3971 0 : break;
3972 :
3973 : case ButtonPress:
3974 : // if we loose the focus in presentation mode
3975 : // there are good chances that we never get it back
3976 : // since the WM ignores us
3977 0 : if( IsOverrideRedirect() )
3978 : {
3979 : XSetInputFocus( GetXDisplay(), GetShellWindow(),
3980 0 : RevertToNone, CurrentTime );
3981 : }
3982 :
3983 : case ButtonRelease:
3984 : case MotionNotify:
3985 : case EnterNotify:
3986 : case LeaveNotify:
3987 0 : nRet = HandleMouseEvent( pEvent );
3988 0 : break;
3989 :
3990 : case FocusIn:
3991 : case FocusOut:
3992 0 : nRet = HandleFocusEvent( &pEvent->xfocus );
3993 0 : break;
3994 :
3995 : case Expose:
3996 : case GraphicsExpose:
3997 0 : nRet = HandleExposeEvent( pEvent );
3998 0 : break;
3999 :
4000 : case MapNotify:
4001 0 : if( pEvent->xmap.window == GetShellWindow() )
4002 : {
4003 0 : if( nShowState_ == SHOWSTATE_HIDDEN )
4004 : {
4005 : /*
4006 : * workaround for (at least) KWin 2.2.2
4007 : * which will map windows that were once transient
4008 : * even if they are withdrawn when the respective
4009 : * document is mapped.
4010 : */
4011 0 : if( ! (nStyle_ & SAL_FRAME_STYLE_PLUG) )
4012 0 : XUnmapWindow( GetXDisplay(), GetShellWindow() );
4013 0 : break;
4014 : }
4015 0 : bMapped_ = sal_True;
4016 0 : bViewable_ = sal_True;
4017 0 : nRet = sal_True;
4018 0 : if ( mpInputContext != NULL )
4019 0 : mpInputContext->Map( this );
4020 0 : CallCallback( SALEVENT_RESIZE, NULL );
4021 :
4022 0 : bool bSetFocus = m_bSetFocusOnMap;
4023 : /* another workaround for sawfish: if a transient window for the same parent is shown
4024 : * sawfish does not set the focus to it. Applies only for click to focus mode.
4025 : */
4026 0 : if( ! (nStyle_ & SAL_FRAME_STYLE_FLOAT ) && mbInShow && GetDisplay()->getWMAdaptor()->getWindowManagerName().EqualsAscii( "Sawfish" ) )
4027 : {
4028 : // don't set the focus into the IME status window
4029 : // since this will lead to a parent loose-focus, close status,
4030 : // reget focus, open status, .... flicker loop
4031 0 : if ( (I18NStatus::get().getStatusFrame() != this) )
4032 0 : bSetFocus = true;
4033 : }
4034 :
4035 : /*
4036 : * sometimes a message box/dialogue is brought up when a frame is not mapped
4037 : * the corresponding TRANSIENT_FOR hint is then set to the root window
4038 : * so that the dialogue shows in all cases. Correct it here if the
4039 : * frame is shown afterwards.
4040 : */
4041 0 : if( ! IsChildWindow()
4042 0 : && ! IsOverrideRedirect()
4043 0 : && ! IsFloatGrabWindow()
4044 : )
4045 : {
4046 0 : for( std::list< X11SalFrame* >::const_iterator it = maChildren.begin();
4047 0 : it != maChildren.end(); ++it )
4048 : {
4049 0 : if( (*it)->mbTransientForRoot )
4050 0 : pDisplay_->getWMAdaptor()->changeReferenceFrame( *it, this );
4051 : }
4052 : }
4053 :
4054 0 : if( hPresentationWindow != None && GetShellWindow() == hPresentationWindow )
4055 0 : XSetInputFocus( GetXDisplay(), GetShellWindow(), RevertToParent, CurrentTime );
4056 :
4057 0 : if( bSetFocus )
4058 : {
4059 : XSetInputFocus( GetXDisplay(),
4060 : GetShellWindow(),
4061 : RevertToParent,
4062 0 : CurrentTime );
4063 : }
4064 :
4065 :
4066 0 : RestackChildren();
4067 0 : mbInShow = sal_False;
4068 0 : m_bSetFocusOnMap = false;
4069 : }
4070 0 : break;
4071 :
4072 : case UnmapNotify:
4073 0 : if( pEvent->xunmap.window == GetShellWindow() )
4074 : {
4075 0 : bMapped_ = sal_False;
4076 0 : bViewable_ = sal_False;
4077 0 : nRet = sal_True;
4078 0 : if ( mpInputContext != NULL )
4079 0 : mpInputContext->Unmap( this );
4080 0 : CallCallback( SALEVENT_RESIZE, NULL );
4081 : }
4082 0 : break;
4083 :
4084 : case ConfigureNotify:
4085 0 : if( pEvent->xconfigure.window == GetShellWindow()
4086 0 : || pEvent->xconfigure.window == GetWindow() )
4087 0 : nRet = HandleSizeEvent( &pEvent->xconfigure );
4088 0 : break;
4089 :
4090 : case VisibilityNotify:
4091 0 : nVisibility_ = pEvent->xvisibility.state;
4092 0 : nRet = sal_True;
4093 0 : if( bAlwaysOnTop_
4094 : && bMapped_
4095 0 : && ! GetDisplay()->getWMAdaptor()->isAlwaysOnTopOK()
4096 : && nVisibility_ != VisibilityUnobscured )
4097 0 : maAlwaysOnTopRaiseTimer.Start();
4098 0 : break;
4099 :
4100 : case ReparentNotify:
4101 0 : nRet = HandleReparentEvent( &pEvent->xreparent );
4102 0 : break;
4103 :
4104 : case MappingNotify:
4105 0 : if( MappingPointer != pEvent->xmapping.request )
4106 0 : nRet = CallCallback( SALEVENT_KEYBOARDCHANGED, 0 );
4107 0 : break;
4108 :
4109 : case ColormapNotify:
4110 0 : nRet = HandleColormapEvent( &pEvent->xcolormap );
4111 0 : break;
4112 :
4113 : case PropertyNotify:
4114 : {
4115 0 : if( pEvent->xproperty.atom == pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_STATE ) )
4116 0 : nRet = HandleStateEvent( &pEvent->xproperty );
4117 : else
4118 0 : nRet = pDisplay_->getWMAdaptor()->handlePropertyNotify( this, &pEvent->xproperty );
4119 0 : break;
4120 : }
4121 :
4122 : case ClientMessage:
4123 0 : nRet = HandleClientMessage( &pEvent->xclient );
4124 0 : break;
4125 : }
4126 : }
4127 : else
4128 : {
4129 0 : switch( pEvent->type )
4130 : {
4131 : case FocusIn:
4132 : case FocusOut:
4133 0 : if( ( nStyle_ & SAL_FRAME_STYLE_PLUG )
4134 0 : && ( pEvent->xfocus.window == GetShellWindow()
4135 0 : || pEvent->xfocus.window == GetForeignParent() )
4136 : )
4137 : {
4138 0 : nRet = HandleFocusEvent( &pEvent->xfocus );
4139 : }
4140 0 : break;
4141 :
4142 : case ConfigureNotify:
4143 0 : if( pEvent->xconfigure.window == GetForeignParent() ||
4144 0 : pEvent->xconfigure.window == GetShellWindow() )
4145 0 : nRet = HandleSizeEvent( &pEvent->xconfigure );
4146 :
4147 0 : if( pEvent->xconfigure.window == GetStackingWindow() )
4148 0 : nRet = HandleSizeEvent( &pEvent->xconfigure );
4149 :
4150 0 : RestackChildren();
4151 0 : break;
4152 : }
4153 : }
4154 :
4155 0 : return nRet;
4156 : }
4157 :
4158 0 : void X11SalFrame::ResetClipRegion()
4159 : {
4160 0 : delete [] m_pClipRectangles;
4161 0 : m_pClipRectangles = NULL;
4162 0 : m_nCurClipRect = m_nMaxClipRect = 0;
4163 :
4164 0 : const int dest_kind = ShapeBounding;
4165 0 : const int op = ShapeSet;
4166 0 : const int ordering = YSorted;
4167 :
4168 : XWindowAttributes win_attrib;
4169 : XRectangle win_size;
4170 :
4171 0 : XLIB_Window aShapeWindow = mhShellWindow;
4172 :
4173 : XGetWindowAttributes ( GetDisplay()->GetDisplay(),
4174 : aShapeWindow,
4175 0 : &win_attrib );
4176 :
4177 0 : win_size.x = 0;
4178 0 : win_size.y = 0;
4179 0 : win_size.width = win_attrib.width;
4180 0 : win_size.height = win_attrib.height;
4181 :
4182 : XShapeCombineRectangles ( GetDisplay()->GetDisplay(),
4183 : aShapeWindow,
4184 : dest_kind,
4185 : 0, 0, // x_off, y_off
4186 : &win_size, // list of rectangles
4187 : 1, // number of rectangles
4188 0 : op, ordering );
4189 0 : }
4190 :
4191 0 : void X11SalFrame::BeginSetClipRegion( sal_uLong nRects )
4192 : {
4193 0 : if( m_pClipRectangles )
4194 0 : delete [] m_pClipRectangles;
4195 0 : if( nRects )
4196 0 : m_pClipRectangles = new XRectangle[nRects];
4197 : else
4198 0 : m_pClipRectangles = NULL;
4199 0 : m_nMaxClipRect = static_cast<int>(nRects);
4200 0 : m_nCurClipRect = 0;
4201 0 : }
4202 :
4203 0 : void X11SalFrame::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
4204 : {
4205 0 : if( m_pClipRectangles && m_nCurClipRect < m_nMaxClipRect )
4206 : {
4207 0 : m_pClipRectangles[m_nCurClipRect].x = nX;
4208 0 : m_pClipRectangles[m_nCurClipRect].y = nY;
4209 0 : m_pClipRectangles[m_nCurClipRect].width = nWidth;
4210 0 : m_pClipRectangles[m_nCurClipRect].height = nHeight;
4211 0 : m_nCurClipRect++;
4212 : }
4213 0 : }
4214 :
4215 0 : void X11SalFrame::EndSetClipRegion()
4216 : {
4217 0 : const int dest_kind = ShapeBounding;
4218 0 : const int ordering = YSorted;
4219 0 : const int op = ShapeSet;
4220 :
4221 0 : XLIB_Window aShapeWindow = mhShellWindow;
4222 : XShapeCombineRectangles ( GetDisplay()->GetDisplay(),
4223 : aShapeWindow,
4224 : dest_kind,
4225 : 0, 0, // x_off, y_off
4226 : m_pClipRectangles,
4227 : m_nCurClipRect,
4228 0 : op, ordering );
4229 :
4230 0 : }
4231 :
4232 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|