2002-04-27 20:26:10 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-12-07 08:23:56 +03:00
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
#include "prlink.h"
|
|
|
|
|
2001-12-07 08:23:56 +03:00
|
|
|
#include "nsBidiKeyboard.h"
|
2008-04-17 00:03:19 +04:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
|
2001-12-07 08:23:56 +03:00
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
nsBidiKeyboard::nsBidiKeyboard()
|
2013-07-10 11:57:33 +04:00
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBidiKeyboard::Reset()
|
2001-12-07 08:23:56 +03:00
|
|
|
{
|
2015-04-11 01:18:05 +03:00
|
|
|
// NB: The default keymap can be null (e.g. in xpcshell). In that case,
|
|
|
|
// simply assume that we don't have bidi keyboards.
|
2015-05-04 20:12:43 +03:00
|
|
|
mHaveBidiKeyboards = false;
|
|
|
|
|
|
|
|
GdkDisplay *display = gdk_display_get_default();
|
|
|
|
if (!display)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
GdkKeymap *keymap = gdk_keymap_get_for_display(display);
|
2015-04-11 01:18:05 +03:00
|
|
|
mHaveBidiKeyboards = keymap && gdk_keymap_have_bidi_layouts(keymap);
|
2013-07-10 11:57:33 +04:00
|
|
|
return NS_OK;
|
2001-12-07 08:23:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBidiKeyboard::~nsBidiKeyboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
|
2001-12-07 08:23:56 +03:00
|
|
|
{
|
2008-04-17 00:03:19 +04:00
|
|
|
if (!mHaveBidiKeyboards)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-09-14 05:56:58 +04:00
|
|
|
*aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL);
|
2008-04-17 00:03:19 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
|
2011-09-15 18:54:50 +04:00
|
|
|
{
|
|
|
|
// not implemented yet
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|