2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
#include "prlink.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsBidiKeyboard.h"
|
2008-04-16 13:03:19 -07:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
nsBidiKeyboard::nsBidiKeyboard()
|
2013-07-10 00:57:33 -07:00
|
|
|
{
|
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBidiKeyboard::Reset()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2015-04-10 15:18:05 -07: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 10:12:43 -07:00
|
|
|
mHaveBidiKeyboards = false;
|
|
|
|
|
|
|
|
GdkDisplay *display = gdk_display_get_default();
|
|
|
|
if (!display)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
GdkKeymap *keymap = gdk_keymap_get_for_display(display);
|
2015-04-10 15:18:05 -07:00
|
|
|
mHaveBidiKeyboards = keymap && gdk_keymap_have_bidi_layouts(keymap);
|
2013-07-10 00:57:33 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBidiKeyboard::~nsBidiKeyboard()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-16 13:03:19 -07:00
|
|
|
NS_IMETHODIMP
|
2011-09-28 23:19:26 -07:00
|
|
|
nsBidiKeyboard::IsLangRTL(bool *aIsRTL)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-04-16 13:03:19 -07:00
|
|
|
if (!mHaveBidiKeyboards)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2012-09-13 18:56:58 -07:00
|
|
|
*aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) == PANGO_DIRECTION_RTL);
|
2008-04-16 13:03:19 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
|
2011-09-15 07:54:50 -07:00
|
|
|
{
|
|
|
|
// not implemented yet
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|