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>
|
|
|
|
|
2012-09-13 18:56:58 -07:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
2008-10-10 08:04:34 -07:00
|
|
|
typedef gboolean (*GdkKeymapHaveBidiLayoutsType)(GdkKeymap *keymap);
|
2012-07-30 07:20:58 -07:00
|
|
|
static GdkKeymapHaveBidiLayoutsType GdkKeymapHaveBidiLayouts = nullptr;
|
2012-09-13 18:56:58 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
|
|
|
|
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
|
|
|
{
|
2012-09-13 18:56:58 -07:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
|
|
|
PRLibrary *gtklib = nullptr;
|
2008-08-06 13:48:55 -07:00
|
|
|
#if defined(MOZ_X11)
|
2012-09-13 18:56:58 -07:00
|
|
|
if (!GdkKeymapHaveBidiLayouts) {
|
|
|
|
GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType)
|
|
|
|
PR_FindFunctionSymbolAndLibrary("gdk_keymap_have_bidi_layouts",
|
|
|
|
>klib);
|
|
|
|
if (gtklib)
|
|
|
|
PR_UnloadLibrary(gtklib);
|
|
|
|
}
|
2008-08-06 13:48:55 -07:00
|
|
|
#endif
|
2008-04-16 13:03:19 -07:00
|
|
|
|
2012-09-13 18:56:58 -07:00
|
|
|
mHaveBidiKeyboards = false;
|
|
|
|
if (GdkKeymapHaveBidiLayouts)
|
2013-10-08 11:47:37 -07:00
|
|
|
mHaveBidiKeyboards = (*GdkKeymapHaveBidiLayouts)(nullptr);
|
2012-09-13 18:56:58 -07:00
|
|
|
#else
|
|
|
|
mHaveBidiKeyboards = gdk_keymap_have_bidi_layouts(gdk_keymap_get_default());
|
|
|
|
#endif
|
2013-07-10 00:57:33 -07:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsBidiKeyboard::~nsBidiKeyboard()
|
|
|
|
{
|
2012-09-13 18:56:58 -07:00
|
|
|
#if (MOZ_WIDGET_GTK == 2)
|
|
|
|
GdkKeymapHaveBidiLayouts = nullptr;
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|