summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk/window
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/gtk/window')
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx208
-rw-r--r--vcl/unx/gtk/window/gtkobject.cxx16
2 files changed, 119 insertions, 105 deletions
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 5f4a2bda25f8..d49d0ae7921d 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -50,6 +51,7 @@
#include <vcl/bitmapex.hxx>
#include <impbmp.hxx>
#include <svids.hrc>
+#include <sal/macros.h>
#include <algorithm>
@@ -210,6 +212,9 @@ static sal_uInt16 GetKeyCode( guint keyval )
case GDK_asciitilde: nCode = KEY_TILDE; break;
case GDK_leftsinglequotemark:
case GDK_quoteleft: nCode = KEY_QUOTELEFT; break;
+ case GDK_bracketleft: nCode = KEY_BRACKETLEFT; break;
+ case GDK_bracketright: nCode = KEY_BRACKETRIGHT; break;
+ case GDK_semicolon: nCode = KEY_SEMICOLON; break;
// some special cases, also see saldisp.cxx
// - - - - - - - - - - - - - Apollo - - - - - - - - - - - - - 0x1000
case 0x1000FF02: // apXK_Copy
@@ -413,7 +418,7 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
GtkSalFrame::~GtkSalFrame()
{
- for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); ++i )
+ for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); ++i )
{
if( !m_aGraphics[i].pGraphics )
continue;
@@ -553,7 +558,6 @@ void GtkSalFrame::InitCommon()
// init members
m_pCurrentCursor = NULL;
m_nKeyModifiers = 0;
- m_bSingleAltPress = false;
m_bFullscreen = false;
m_nState = GDK_WINDOW_STATE_WITHDRAWN;
m_nVisibility = GDK_VISIBILITY_FULLY_OBSCURED;
@@ -792,6 +796,8 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
// force wm class hint
m_nExtStyle = ~0;
+ if (m_pParent)
+ m_sWMClass = m_pParent->m_sWMClass;
SetExtendedFrameStyle( 0 );
if( m_pParent && m_pParent->m_pWindow && ! isChild() )
@@ -860,7 +866,6 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
{
/* #i99360# ugly workaround an X11 library bug */
nUserTime= getDisplay()->GetLastUserEventTime( true );
- // nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
}
lcl_set_user_time(GTK_WIDGET(m_pWindow)->window, nUserTime);
}
@@ -975,25 +980,10 @@ void GtkSalFrame::SetExtendedFrameStyle( SalExtStyle nStyle )
if( nStyle != m_nExtStyle && ! isChild() )
{
m_nExtStyle = nStyle;
- if( GTK_WIDGET_REALIZED( m_pWindow ) )
- {
- XClassHint* pClass = XAllocClassHint();
- rtl::OString aResHint = X11SalData::getFrameResName( m_nExtStyle );
- pClass->res_name = const_cast<char*>(aResHint.getStr());
- pClass->res_class = const_cast<char*>(X11SalData::getFrameClassName());
- XSetClassHint( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(m_pWindow->window),
- pClass );
- XFree( pClass );
- }
- else
- gtk_window_set_wmclass( GTK_WINDOW(m_pWindow),
- X11SalData::getFrameResName( m_nExtStyle ),
- X11SalData::getFrameClassName() );
+ updateWMClass();
}
}
-
SalGraphics* GtkSalFrame::GetGraphics()
{
if( m_pWindow )
@@ -1121,13 +1111,6 @@ void GtkSalFrame::SetIcon( sal_uInt16 nIcon )
sal_uInt16 nOffsets[2] = { SV_ICON_SMALL_START, SV_ICON_LARGE_START };
sal_uInt16 nIndex;
- // Use high contrast icons where appropriate
- if( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
- {
- nOffsets[0] = SV_ICON_LARGE_HC_START;
- nOffsets[1] = SV_ICON_SMALL_HC_START;
- }
-
for( nIndex = 0; nIndex < sizeof(nOffsets)/ sizeof(sal_uInt16); nIndex++ )
{
// #i44723# workaround gcc temporary problem
@@ -1158,7 +1141,7 @@ void GtkSalFrame::SetIcon( sal_uInt16 nIcon )
aMask = AlphaMask( aIcon.GetMask() );
break;
default:
- DBG_ERROR( "unhandled transparent type" );
+ OSL_FAIL( "unhandled transparent type" );
break;
}
}
@@ -1296,7 +1279,6 @@ void GtkSalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
gtk_window_set_keep_above( GTK_WINDOW(m_pWindow), bVisible );
if( bVisible )
{
- SessionManagerClient::open(); // will simply return after the first time
initClientId();
getDisplay()->startupNotificationCompleted();
@@ -1632,8 +1614,6 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
sal_uInt16 nPosSizeFlags = 0;
long nX = pState->mnX - (m_pParent ? m_pParent->maGeometry.nX : 0);
long nY = pState->mnY - (m_pParent ? m_pParent->maGeometry.nY : 0);
- long nWidth = pState->mnWidth;
- long nHeight = pState->mnHeight;
if( pState->mnMask & SAL_FRAMESTATE_MASK_X )
nPosSizeFlags |= SAL_FRAME_POSSIZE_X;
else
@@ -1644,12 +1624,8 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
nY = maGeometry.nY - (m_pParent ? m_pParent->maGeometry.nY : 0);
if( pState->mnMask & SAL_FRAMESTATE_MASK_WIDTH )
nPosSizeFlags |= SAL_FRAME_POSSIZE_WIDTH;
- else
- nWidth = maGeometry.nWidth;
if( pState->mnMask & SAL_FRAMESTATE_MASK_HEIGHT )
nPosSizeFlags |= SAL_FRAME_POSSIZE_HEIGHT;
- else
- nHeight = maGeometry.nHeight;
SetPosSize( nX, nY, pState->mnWidth, pState->mnHeight, nPosSizeFlags );
}
if( pState->mnMask & SAL_FRAMESTATE_MASK_STATE && ! isChild() )
@@ -1740,7 +1716,7 @@ void GtkSalFrame::moveToScreen( int nScreen )
m_aSystemData.pAppContext = NULL;
m_aSystemData.aShellWindow = m_aSystemData.aWindow;
// update graphics if necessary
- for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+ for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
{
if( m_aGraphics[i].bInUse )
m_aGraphics[i].pGraphics->SetDrawable( GDK_WINDOW_XWINDOW(m_pWindow->window), m_nScreen );
@@ -1792,6 +1768,40 @@ void GtkSalFrame::SetScreenNumber( unsigned int nNewScreen )
}
}
+void GtkSalFrame::updateWMClass()
+{
+ rtl::OString aResClass = rtl::OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
+ const char *pResClass = aResClass.getLength() ? aResClass.getStr() : X11SalData::getFrameClassName();
+
+ if( GTK_WIDGET_REALIZED( m_pWindow ) )
+ {
+ XClassHint* pClass = XAllocClassHint();
+ rtl::OString aResName = X11SalData::getFrameResName( m_nExtStyle );
+ pClass->res_name = const_cast<char*>(aResName.getStr());
+ pClass->res_class = const_cast<char*>(pResClass);
+ XSetClassHint( getDisplay()->GetDisplay(),
+ GDK_WINDOW_XWINDOW(m_pWindow->window),
+ pClass );
+ XFree( pClass );
+ }
+ else
+ gtk_window_set_wmclass( GTK_WINDOW(m_pWindow),
+ X11SalData::getFrameResName( m_nExtStyle ),
+ pResClass );
+}
+
+void GtkSalFrame::SetApplicationID( const rtl::OUString &rWMClass )
+{
+ if( rWMClass != m_sWMClass && ! isChild() )
+ {
+ m_sWMClass = rWMClass;
+ updateWMClass();
+
+ for( std::list< GtkSalFrame* >::iterator it = m_aChildren.begin(); it != m_aChildren.end(); ++it )
+ (*it)->SetApplicationID(rWMClass);
+ }
+}
+
void GtkSalFrame::ShowFullScreen( sal_Bool bFullScreen, sal_Int32 nScreen )
{
if( m_pWindow && ! isChild() )
@@ -2077,7 +2087,6 @@ void GtkSalFrame::ToTop( sal_uInt16 nFlags )
gtk_window_present( GTK_WINDOW(m_pWindow) );
else
{
- // gdk_window_focus( m_pWindow->window, gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window) );
/* #i99360# ugly workaround an X11 library bug */
guint32 nUserTime= getDisplay()->GetLastUserEventTime( true );
gdk_window_focus( m_pWindow->window, nUserTime );
@@ -2124,6 +2133,8 @@ void GtkSalFrame::SetPointer( PointerStyle ePointerStyle )
void GtkSalFrame::grabPointer( sal_Bool bGrab, sal_Bool bOwnerEvents )
{
+ static const char* pEnv = getenv( "SAL_NO_MOUSEGRABS" );
+
if( m_pWindow )
{
if( bGrab )
@@ -2146,9 +2157,10 @@ void GtkSalFrame::grabPointer( sal_Bool bGrab, sal_Bool bOwnerEvents )
{
const int nMask = ( GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK );
- gdk_pointer_grab( m_pWindow->window, bOwnerEvents,
- (GdkEventMask) nMask, NULL, m_pCurrentCursor,
- GDK_CURRENT_TIME );
+ if( !pEnv || !*pEnv )
+ gdk_pointer_grab( m_pWindow->window, bOwnerEvents,
+ (GdkEventMask) nMask, NULL, m_pCurrentCursor,
+ GDK_CURRENT_TIME );
}
else
{
@@ -2158,23 +2170,25 @@ void GtkSalFrame::grabPointer( sal_Bool bGrab, sal_Bool bOwnerEvents )
//
// this is of course a bad hack, especially as we cannot
// set the right cursor this way
- XGrabPointer( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW( m_pWindow->window),
- bOwnerEvents,
- PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
- GrabModeAsync,
- GrabModeAsync,
- None,
- None,
- CurrentTime
- );
+ if( !pEnv || !*pEnv )
+ XGrabPointer( getDisplay()->GetDisplay(),
+ GDK_WINDOW_XWINDOW( m_pWindow->window),
+ bOwnerEvents,
+ PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ None,
+ None,
+ CurrentTime
+ );
}
}
else
{
// Two GdkDisplays may be open
- gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME);
+ if( !pEnv || !*pEnv )
+ gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME);
}
}
}
@@ -2195,7 +2209,7 @@ void GtkSalFrame::SetPointerPos( long nX, long nY )
GdkScreen *pScreen = gtk_window_get_screen( GTK_WINDOW(pFrame->m_pWindow) );
GdkDisplay *pDisplay = gdk_screen_get_display( pScreen );
- /* #87921# when the application tries to center the mouse in the dialog the
+ /* when the application tries to center the mouse in the dialog the
* window isn't mapped already. So use coordinates relative to the root window.
*/
unsigned int nWindowLeft = maGeometry.nX + nX;
@@ -2256,6 +2270,18 @@ SalFrame::SalPointerState GtkSalFrame::GetPointerState()
return aState;
}
+SalFrame::SalIndicatorState GtkSalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = GetX11SalData()->GetDisplay()->GetIndicatorState();
+ return aState;
+}
+
+void GtkSalFrame::SimulateKeyPress( sal_uInt16 nKeyCode )
+{
+ GetX11SalData()->GetDisplay()->SimulateKeyPress(nKeyCode);
+}
+
void GtkSalFrame::SetInputContext( SalInputContext* pContext )
{
if( ! pContext )
@@ -2389,7 +2415,7 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
}
// free xrender resources
- for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+ for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
if( m_aGraphics[i].bInUse )
m_aGraphics[i].pGraphics->SetDrawable( None, m_nScreen );
@@ -2424,7 +2450,7 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
}
// update graphics
- for( unsigned int i = 0; i < sizeof(m_aGraphics)/sizeof(m_aGraphics[0]); i++ )
+ for( unsigned int i = 0; i < SAL_N_ELEMENTS(m_aGraphics); i++ )
{
if( m_aGraphics[i].bInUse )
{
@@ -2812,13 +2838,15 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f
GTK_YIELD_GRAB();
+ X11SalInstance *pSalInstance =
+ static_cast< X11SalInstance* >(GetSalData()->m_pInstance);
+
// check if printers have changed (analogous to salframe focus handler)
- vcl_sal::PrinterUpdate::update();
+ pSalInstance->updatePrinterUpdate();
if( !pEvent->in )
{
pThis->m_nKeyModifiers = 0;
- pThis->m_bSingleAltPress = false;
pThis->m_bSendModChangeOnRelease = false;
}
@@ -2826,9 +2854,8 @@ gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer f
pThis->m_pIMHandler->focusChanged( pEvent->in );
// ask for changed printers like generic implementation
- if( pEvent->in )
- if( static_cast< X11SalInstance* >(GetSalData()->m_pInstance)->isPrinterInit() )
- vcl_sal::PrinterUpdate::update();
+ if( pEvent->in && pSalInstance->isPrinterInit() )
+ pSalInstance->updatePrinterUpdate();
// FIXME: find out who the hell steals the focus from our frame
// while we have the pointer grabbed, this should not come from
@@ -3022,10 +3049,7 @@ gboolean GtkSalFrame::signalKey( GtkWidget*, GdkEventKey* pEvent, gpointer frame
if( pThis->m_pIMHandler )
{
if( pThis->m_pIMHandler->handleKeyEvent( pEvent ) )
- {
- pThis->m_bSingleAltPress = false;
return sal_True;
- }
}
GTK_YIELD_GRAB();
@@ -3112,36 +3136,6 @@ gboolean GtkSalFrame::signalKey( GtkWidget*, GdkEventKey* pEvent, gpointer frame
pThis->CallCallback( SALEVENT_KEYMODCHANGE, &aModEvt );
- if( ! aDel.isDeleted() )
- {
- // emulate KEY_MENU
- if( ( pEvent->keyval == GDK_Alt_L || pEvent->keyval == GDK_Alt_R ) &&
- ( nModCode & ~(KEY_MOD3|KEY_MOD2)) == 0 )
- {
- if( pEvent->type == GDK_KEY_PRESS )
- pThis->m_bSingleAltPress = true;
-
- else if( pThis->m_bSingleAltPress )
- {
- SalKeyEvent aKeyEvt;
-
- aKeyEvt.mnCode = KEY_MENU | nModCode;
- aKeyEvt.mnRepeat = 0;
- aKeyEvt.mnTime = pEvent->time;
- aKeyEvt.mnCharCode = 0;
-
- // simulate KEY_MENU
- pThis->CallCallback( SALEVENT_KEYINPUT, &aKeyEvt );
- if( ! aDel.isDeleted() )
- {
- pThis->CallCallback( SALEVENT_KEYUP, &aKeyEvt );
- pThis->m_bSingleAltPress = false;
- }
- }
- }
- else
- pThis->m_bSingleAltPress = false;
- }
}
else
{
@@ -3154,10 +3148,7 @@ gboolean GtkSalFrame::signalKey( GtkWidget*, GdkEventKey* pEvent, gpointer frame
(pEvent->type == GDK_KEY_PRESS),
false );
if( ! aDel.isDeleted() )
- {
pThis->m_bSendModChangeOnRelease = false;
- pThis->m_bSingleAltPress = false;
- }
}
if( !aDel.isDeleted() && pThis->m_pIMHandler )
@@ -3543,6 +3534,10 @@ void GtkSalFrame::IMHandler::signalIMCommit( GtkIMContext* CONTEXT_ARG, gchar* p
{
GTK_YIELD_GRAB();
+ const bool bWasPreedit =
+ (pThis->m_aInputEvent.mpTextAttr != 0) ||
+ pThis->m_bPreeditJustChanged;
+
pThis->m_aInputEvent.mnTime = 0;
pThis->m_aInputEvent.mpTextAttr = 0;
pThis->m_aInputEvent.maText = String( pText, RTL_TEXTENCODING_UTF8 );
@@ -3566,9 +3561,6 @@ void GtkSalFrame::IMHandler::signalIMCommit( GtkIMContext* CONTEXT_ARG, gchar* p
* or because there never was a preedit.
*/
bool bSingleCommit = false;
- bool bWasPreedit =
- (pThis->m_aInputEvent.mpTextAttr != 0) ||
- pThis->m_bPreeditJustChanged;
if( ! bWasPreedit
&& pThis->m_aInputEvent.maText.Len() == 1
&& ! pThis->m_aPrevKeyPresses.empty()
@@ -3756,11 +3748,18 @@ uno::Reference<accessibility::XAccessibleEditableText> lcl_GetxText()
uno::Reference<accessibility::XAccessibleEditableText> xText;
Window* pFocusWin = ImplGetSVData()->maWinData.mpFocusWin;
if (!pFocusWin)
- return xText;
+ return xText;
- uno::Reference< accessibility::XAccessible > xAccessible( pFocusWin->GetAccessible( true ) );
- if (xAccessible.is())
- xText = FindFocus(xAccessible->getAccessibleContext());
+ try
+ {
+ uno::Reference< accessibility::XAccessible > xAccessible( pFocusWin->GetAccessible( true ) );
+ if (xAccessible.is())
+ xText = FindFocus(xAccessible->getAccessibleContext());
+ }
+ catch(const uno::Exception& e)
+ {
+ g_warning( "Exception in getting input method surrounding text" );
+ }
return xText;
}
@@ -3792,9 +3791,7 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
if (xText.is())
{
sal_uInt32 nPosition = xText->getCaretPosition();
- // --> OD 2010-06-04 #i111768# - apply patch from kstribley:
- // range checking
-// xText->deleteText(nPosition + offset, nPosition + offset + nchars);
+ // #i111768# range checking
sal_Int32 nDeletePos = nPosition + offset;
sal_Int32 nDeleteEnd = nDeletePos + nchars;
if (nDeletePos < 0)
@@ -3805,9 +3802,10 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
nDeleteEnd = xText->getCharacterCount();
xText->deleteText(nDeletePos, nDeleteEnd);
- // <--
return sal_True;
}
return sal_False;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtkobject.cxx b/vcl/unx/gtk/window/gtkobject.cxx
index 68c8f1f1286d..04dcde7ff4e3 100644
--- a/vcl/unx/gtk/window/gtkobject.cxx
+++ b/vcl/unx/gtk/window/gtkobject.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +29,12 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_vcl.hxx"
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
#include <unx/gtk/gtkobject.hxx>
#include <unx/gtk/gtkframe.hxx>
#include <unx/gtk/gtkdata.hxx>
@@ -210,7 +217,16 @@ void GtkSalObject::signalDestroy( GtkObject* pObj, gpointer object )
}
}
+void GtkSalObject::SetForwardKey( sal_Bool bEnable )
+{
+ if( bEnable )
+ gtk_widget_add_events( GTK_WIDGET( m_pSocket ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE );
+ else
+ gtk_widget_set_events( GTK_WIDGET( m_pSocket ), ~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE) & gtk_widget_get_events( GTK_WIDGET( m_pSocket ) ) );
+}
+
void GtkSalObject::InterceptChildWindowKeyDown( sal_Bool /*bIntercept*/ )
{
}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */