1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "nsBidiKeyboard.h"
11 #include "nsIWidget.h"
14 NS_IMPL_ISUPPORTS(nsBidiKeyboard
, nsIBidiKeyboard
)
16 nsBidiKeyboard::nsBidiKeyboard() { Reset(); }
19 nsBidiKeyboard::Reset() {
20 // NB: The default keymap can be null (e.g. in xpcshell). In that case,
21 // simply assume that we don't have bidi keyboards.
22 mHaveBidiKeyboards
= false;
24 GdkDisplay
* display
= gdk_display_get_default();
25 if (!display
) return NS_OK
;
27 GdkKeymap
* keymap
= gdk_keymap_get_for_display(display
);
28 mHaveBidiKeyboards
= keymap
&& gdk_keymap_have_bidi_layouts(keymap
);
32 nsBidiKeyboard::~nsBidiKeyboard() = default;
35 nsBidiKeyboard::IsLangRTL(bool* aIsRTL
) {
36 if (!mHaveBidiKeyboards
) return NS_ERROR_FAILURE
;
38 *aIsRTL
= (gdk_keymap_get_direction(gdk_keymap_get_default()) ==
44 NS_IMETHODIMP
nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult
) {
45 // not implemented yet
46 return NS_ERROR_NOT_IMPLEMENTED
;
50 already_AddRefed
<nsIBidiKeyboard
> nsIWidget::CreateBidiKeyboardInner() {
51 return do_AddRef(new nsBidiKeyboard());