2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2002-04-27 20:26:10 +04:00
|
|
|
/* 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"
|
2018-09-15 21:38:44 +03:00
|
|
|
#include "nsIWidget.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() { Reset(); }
|
2013-07-10 11:57:33 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsBidiKeyboard::Reset() {
|
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;
|
2001-12-07 08:23:56 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
GdkDisplay* display = gdk_display_get_default();
|
2001-12-07 08:23:56 +03:00
|
|
|
if (!display) return NS_OK;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
GdkKeymap* keymap = gdk_keymap_get_for_display(display);
|
2001-12-07 08:23:56 +03:00
|
|
|
mHaveBidiKeyboards = keymap && gdk_keymap_have_bidi_layouts(keymap);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2020-03-16 13:56:57 +03:00
|
|
|
nsBidiKeyboard::~nsBidiKeyboard() = default;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2008-04-17 00:03:19 +04:00
|
|
|
NS_IMETHODIMP
|
2019-05-01 11:47:10 +03:00
|
|
|
nsBidiKeyboard::IsLangRTL(bool* aIsRTL) {
|
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;
|
|
|
|
}
|
|
|
|
|
2019-05-01 11:47:10 +03:00
|
|
|
NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) {
|
2011-09-15 18:54:50 +04:00
|
|
|
// not implemented yet
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2018-09-15 21:38:44 +03:00
|
|
|
|
|
|
|
// static
|
|
|
|
already_AddRefed<nsIBidiKeyboard> nsIWidget::CreateBidiKeyboardInner() {
|
|
|
|
return do_AddRef(new nsBidiKeyboard());
|
|
|
|
}
|