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