#define __DALI_INTERNAL_WINDOW_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <orientation.h>
#include <render-surface.h>
#include <drag-and-drop-detector.h>
+#include <window-devel.h>
namespace Dali
{
{
public:
typedef Dali::Window::IndicatorSignalType IndicatorSignalType;
+ typedef Dali::DevelWindow::FocusSignalType FocusSignalType;
typedef Signal< void () > SignalType;
/**
Dali::Any GetNativeHandle() const;
/**
+ * @brief Sets whether window accepts focus or not.
+ *
+ * @param[in] accept If focus is accepted or not. Default is true.
+ */
+ void SetAcceptFocus( bool accept );
+
+ /**
+ * @brief Returns whether window accepts focus or not.
+ *
+ * @param[in] window The window to accept focus
+ * @return True if the window accept focus, false otherwise
+ */
+ bool IsFocusAcceptable();
+
+ /**
* Called from Orientation after the Change signal has been sent
*/
void RotationDone( int orientation, int width, int height );
IndicatorSignalType& IndicatorVisibilityChangedSignal() { return mIndicatorVisibilityChangedSignal; }
/**
+ * The user should connect to this signal to get a timing when window gains focus or loses focus.
+ */
+ FocusSignalType& FocusChangedSignal() { return mFocusChangedSignal; }
+
+ /**
* This signal is emitted when the window is requesting to be deleted
*/
SignalType& DeleteRequestSignal() { return mDeleteRequestSignal; }
bool mIsTransparent:1;
bool mWMRotationAppSet:1;
bool mEcoreEventHander:1;
+ bool mIsFocusAcceptable:1;
IndicatorInterface* mIndicator;
Dali::Window::WindowOrientation mIndicatorOrientation;
Dali::Window::WindowOrientation mNextIndicatorOrientation;
// Signals
IndicatorSignalType mIndicatorVisibilityChangedSignal;
+ FocusSignalType mFocusChangedSignal;
SignalType mDeleteRequestSignal;
};
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <adaptors/devel-api/adaptor-framework/window-devel.h>
+#include <adaptors/common/window-impl.h>
+
+namespace Dali
+{
+
+namespace DevelWindow
+{
+
+FocusSignalType& FocusChangedSignal( Window window )
+{
+ return GetImplementation( window ).FocusChangedSignal();
+}
+
+void SetAcceptFocus( Window window, bool accept )
+{
+ GetImplementation( window ).SetAcceptFocus( accept );
+}
+
+bool IsFocusAcceptable( Window window )
+{
+ return GetImplementation( window ).IsFocusAcceptable();
+}
+
+} // namespace DevelWindow
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_WINDOW_DEVEL_H
+#define DALI_WINDOW_DEVEL_H
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#ifdef DALI_ADAPTOR_COMPILATION // full path doesn't exist until adaptor is installed so we have to use relative
+#include <window.h>
+#else
+#include <dali/public-api/adaptor-framework/window.h>
+#endif
+
+namespace Dali
+{
+
+namespace DevelWindow
+{
+
+typedef Signal< void (bool) > FocusSignalType; ///< Window focus signal type
+
+/**
+ * @brief The user should connect to this signal to get a timing when window gains focus or loses focus.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName( bool focusIn );
+ * @endcode
+ * The parameter is true if window gains focus, otherwise false.
+ *
+ * @param[in] window The window to get a signal
+ * @return The signal to connect to
+ */
+FocusSignalType& FocusChangedSignal( Window window );
+
+/**
+ * @brief Sets whether window accepts focus or not.
+ *
+ * @param[in] window The window to accept focus
+ * @param[in] accept If focus is accepted or not. Default is true.
+ */
+void SetAcceptFocus( Window window, bool accept );
+
+/**
+ * @brief Returns whether window accepts focus or not.
+ *
+ * @param[in] window The window to accept focus
+ * @return True if the window accept focus, false otherwise
+ */
+bool IsFocusAcceptable( Window window );
+
+} // namespace DevelWindow
+
+} // namespace Dali
+
+#endif // DALI_WINDOW_DEVEL_H
$(adaptor_devel_api_dir)/adaptor-framework/tilt-sensor.cpp \
$(adaptor_devel_api_dir)/adaptor-framework/lifecycle-controller.cpp \
$(adaptor_devel_api_dir)/adaptor-framework/video-player.cpp \
- $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp
+ $(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.cpp \
+ $(adaptor_devel_api_dir)/adaptor-framework/window-devel.cpp
devel_api_adaptor_framework_header_files = \
$(adaptor_devel_api_dir)/adaptor-framework/video-player.h \
$(adaptor_devel_api_dir)/adaptor-framework/video-player-plugin.h \
$(adaptor_devel_api_dir)/adaptor-framework/virtual-keyboard.h \
- $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h
+ $(adaptor_devel_api_dir)/adaptor-framework/physical-keyboard.h \
+ $(adaptor_devel_api_dir)/adaptor-framework/window-devel.h
+
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
// CLASS HEADER
-#include "window-impl.h"
+#include <window-impl.h>
// EXTERNAL HEADERS
#include <Ecore.h>
#include <ecore-indicator-impl.h>
#include <window-visibility-observer.h>
#include <orientation-impl.h>
+
namespace
{
const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
: mWindow( window ),
mWindowPropertyHandler( NULL ),
mWindowIconifyStateHandler( NULL ),
+ mWindowFocusInHandler( NULL ),
+ mWindowFocusOutHandler( NULL ),
mEcoreWindow( 0 )
{
// store ecore window handle
if( mWindow->mEcoreEventHander )
{
mWindowIconifyStateHandler = ecore_event_handler_add( ECORE_WL_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this );
+ mWindowFocusInHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this );
+ mWindowFocusOutHandler = ecore_event_handler_add( ECORE_WL_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this );
}
-
}
/**
{
ecore_event_handler_del( mWindowIconifyStateHandler );
}
+ if( mWindowFocusInHandler )
+ {
+ ecore_event_handler_del( mWindowFocusInHandler );
+ }
+ if( mWindowFocusOutHandler )
+ {
+ ecore_event_handler_del( mWindowFocusOutHandler );
+ }
}
// Static methods
/// Called when the window iconify state is changed.
static Eina_Bool EcoreEventWindowIconifyStateChanged( void* data, int type, void* event )
{
- Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( (Ecore_Wl_Event_Window_Iconify_State_Change*)event );
- EventHandler* handler( (EventHandler*)data );
+ Ecore_Wl_Event_Window_Iconify_State_Change* iconifyChangedEvent( static_cast< Ecore_Wl_Event_Window_Iconify_State_Change* >( event ) );
+ EventHandler* handler( static_cast< EventHandler* >( data ) );
Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
if ( handler && handler->mWindow )
{
WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
- if ( observer && ( iconifyChangedEvent->win == (unsigned int) ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
+ if ( observer && ( iconifyChangedEvent->win == static_cast< unsigned int> ( ecore_wl_window_id_get( handler->mEcoreWindow ) ) ) )
{
if( iconifyChangedEvent->iconified == EINA_TRUE )
{
return handled;
}
+ /// Called when the window gains focus
+ static Eina_Bool EcoreEventWindowFocusIn( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Focus_In* focusInEvent( static_cast< Ecore_Wl_Event_Focus_In* >( event ) );
+ EventHandler* handler( static_cast< EventHandler* >( data ) );
+
+ if ( handler && handler->mWindow && focusInEvent->win == static_cast< unsigned int >( ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" );
+
+ handler->mWindow->mFocusChangedSignal.Emit( true );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
+ /// Called when the window loses focus
+ static Eina_Bool EcoreEventWindowFocusOut( void* data, int type, void* event )
+ {
+ Ecore_Wl_Event_Focus_Out* focusOutEvent( static_cast< Ecore_Wl_Event_Focus_Out* >( event ) );
+ EventHandler* handler( static_cast< EventHandler* >( data ) );
+
+ if ( handler && handler->mWindow && focusOutEvent->win == static_cast< unsigned int >(ecore_wl_window_id_get( handler->mEcoreWindow ) ) )
+ {
+ DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" );
+
+ handler->mWindow->mFocusChangedSignal.Emit( false );
+ }
+
+ return ECORE_CALLBACK_PASS_ON;
+ }
+
// Data
Window* mWindow;
Ecore_Event_Handler* mWindowPropertyHandler;
Ecore_Event_Handler* mWindowIconifyStateHandler;
+ Ecore_Event_Handler* mWindowFocusInHandler;
+ Ecore_Event_Handler* mWindowFocusOutHandler;
Ecore_Wl_Window* mEcoreWindow;
};
-
Window* Window::New(const PositionSize& posSize, const std::string& name, const std::string& className, bool isTransparent)
{
Window* window = new Window();
DoShowIndicator( mIndicatorOrientation );
}
-void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
+void Window::RotateIndicator( Dali::Window::WindowOrientation orientation )
{
DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
}
Window::Window()
-: mSurface(NULL),
- mIndicatorVisible(Dali::Window::VISIBLE),
- mIndicatorIsShown(false),
- mShowRotatedIndicatorOnClose(false),
- mStarted(false),
- mIsTransparent(false),
- mWMRotationAppSet(false),
- mEcoreEventHander(true),
- mIndicator(NULL),
- mIndicatorOrientation(Dali::Window::PORTRAIT),
- mNextIndicatorOrientation(Dali::Window::PORTRAIT),
- mIndicatorOpacityMode(Dali::Window::OPAQUE),
- mOverlay(NULL),
- mAdaptor(NULL),
- mEventHandler(NULL),
- mPreferredOrientation(Dali::Window::PORTRAIT)
+: mSurface( NULL ),
+ mIndicatorVisible( Dali::Window::VISIBLE ),
+ mIndicatorIsShown( false ),
+ mShowRotatedIndicatorOnClose( false ),
+ mStarted( false ),
+ mIsTransparent( false ),
+ mWMRotationAppSet( false ),
+ mEcoreEventHander( true ),
+ mIsFocusAcceptable( true ),
+ mIndicator( NULL ),
+ mIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mIndicatorOpacityMode( Dali::Window::OPAQUE ),
+ mOverlay( NULL ),
+ mAdaptor( NULL ),
+ mEventHandler( NULL ),
+ mPreferredOrientation( Dali::Window::PORTRAIT )
{
}
return mPreferredOrientation;
}
+void Window::SetAcceptFocus( bool accept )
+{
+ mIsFocusAcceptable = accept;
+
+ ecore_wl_window_focus_skip_set( mEventHandler->mEcoreWindow, !accept );
+}
+
+bool Window::IsFocusAcceptable()
+{
+ return mIsFocusAcceptable;
+}
+
void Window::RotationDone( int orientation, int width, int height )
{
ecore_wl_window_rotation_change_done_send( mEventHandler->mEcoreWindow );
}
-
} // Adaptor
} // Internal
} // Dali
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define __DALI_WINDOW_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class DALI_IMPORT_API Window : public BaseHandle
{
public:
- typedef Signal< void (bool) > IndicatorSignalType;
+ typedef Signal< void (bool) > IndicatorSignalType; ///< Indicator state signal type @SINCE_1_0.0
public:
}
Window::Window()
-: mSurface(NULL),
- mIndicatorVisible(Dali::Window::VISIBLE),
- mIndicatorIsShown(false),
- mShowRotatedIndicatorOnClose(false),
- mStarted(false),
- mIsTransparent(false),
- mWMRotationAppSet(false),
- mIndicator(NULL),
- mIndicatorOrientation(Dali::Window::PORTRAIT),
- mNextIndicatorOrientation(Dali::Window::PORTRAIT),
- mIndicatorOpacityMode(Dali::Window::OPAQUE),
- mOverlay(NULL),
- mAdaptor(NULL),
- mPreferredOrientation(Dali::Window::PORTRAIT)
+: mSurface( NULL ),
+ mIndicatorVisible( Dali::Window::VISIBLE ),
+ mIndicatorIsShown( false ),
+ mShowRotatedIndicatorOnClose( false ),
+ mStarted( false ),
+ mIsTransparent( false ),
+ mWMRotationAppSet( false ),
+ mIsFocusAcceptable( true ),
+ mIndicator( NULL ),
+ mIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mIndicatorOpacityMode( Dali::Window::OPAQUE ),
+ mOverlay( NULL ),
+ mAdaptor( NULL ),
+ mPreferredOrientation( Dali::Window::PORTRAIT )
{
mEventHandler = NULL;
}
return mPreferredOrientation;
}
-void Window::RotationDone( int orientation, int width, int height )
+void Window::SetAcceptFocus( bool accept )
+{
+ mIsFocusAcceptable = accept;
+}
+
+bool Window::IsFocusAcceptable()
{
+ return mIsFocusAcceptable;
}
+void Window::RotationDone( int orientation, int width, int height )
+{
+}
} // Adaptor
} // Internal
}
Window::Window()
-: mSurface(NULL),
- mIndicatorVisible(Dali::Window::INVISIBLE),
- mIndicatorIsShown(false),
- mShowRotatedIndicatorOnClose(false),
- mStarted(false),
- mIsTransparent(false),
- mWMRotationAppSet(false),
- mEcoreEventHander(true),
- mIndicator(NULL),
- mIndicatorOrientation(Dali::Window::PORTRAIT),
- mNextIndicatorOrientation(Dali::Window::PORTRAIT),
- mIndicatorOpacityMode(Dali::Window::OPAQUE),
- mOverlay(NULL),
- mAdaptor(NULL),
- mEventHandler(NULL),
- mPreferredOrientation(Dali::Window::PORTRAIT)
+: mSurface( NULL ),
+ mIndicatorVisible( Dali::Window::INVISIBLE ),
+ mIndicatorIsShown( false ),
+ mShowRotatedIndicatorOnClose( false ),
+ mStarted( false ),
+ mIsTransparent( false ),
+ mWMRotationAppSet( false ),
+ mEcoreEventHander( true ),
+ mIsFocusAcceptable( true ),
+ mIndicator( NULL ),
+ mIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mNextIndicatorOrientation( Dali::Window::PORTRAIT ),
+ mIndicatorOpacityMode( Dali::Window::OPAQUE ),
+ mOverlay( NULL ),
+ mAdaptor( NULL ),
+ mEventHandler( NULL ),
+ mPreferredOrientation( Dali::Window::PORTRAIT )
{
// Detect if we're not running in a ecore main loop (e.g. libuv).
return mPreferredOrientation;
}
+void Window::SetAcceptFocus( bool accept )
+{
+ mIsFocusAcceptable = accept;
+}
+
+bool Window::IsFocusAcceptable()
+{
+ return mIsFocusAcceptable;
+}
+
void Window::RotationDone( int orientation, int width, int height )
{
// Tell window manager we're done
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/dali.h>
#include <Ecore_X.h>
#include <devel-api/adaptor-framework/drag-and-drop-detector.h>
+#include <devel-api/adaptor-framework/window-devel.h>
#include <dali-test-suite-utils.h>
using namespace Dali;
END_TEST;
}
-int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
+int UtcDaliWindowSetAcceptFocusN(void)
{
Dali::Window window;
try
{
- window.IndicatorVisibilityChangedSignal();
+ DevelWindow::SetAcceptFocus( window, true );
DALI_TEST_CHECK( false ); // Should not reach here!
}
catch( ... )
END_TEST;
}
+int UtcDaliWindowIsFocusAcceptableN(void)
+{
+ Dali::Window window;
+ try
+ {
+ DevelWindow::IsFocusAcceptable( window );
+ DALI_TEST_CHECK( false ); // Should not reach here!
+ }
+ catch( ... )
+ {
+ DALI_TEST_CHECK( true );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliWindowIndicatorVisibilityChangedSignalN(void)
+{
+ Dali::Window window;
+ try
+ {
+ window.IndicatorVisibilityChangedSignal();
+ DALI_TEST_CHECK( false ); // Should not reach here!
+ }
+ catch( ... )
+ {
+ DALI_TEST_CHECK( true );
+ }
+ END_TEST;
+}
+int UtcDaliWindowFocusChangedSignalN(void)
+{
+ Dali::Window window;
+ try
+ {
+ DevelWindow::FocusChangedSignal( window );
+ DALI_TEST_CHECK( false ); // Should not reach here!
+ }
+ catch( ... )
+ {
+ DALI_TEST_CHECK( true );
+ }
+ END_TEST;
+}