Bug 1777562 [wpt PR 34663] - [FedCM] Rename FederatedCredential to IdentityCredential...
[gecko.git] / widget / gtk / nsBidiKeyboard.cpp
bloba57235195b941e0d35d0ac27cadf2c8b8f845baa
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:expandtab:shiftwidth=4:tabstop=4:
3 */
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/. */
8 #include "prlink.h"
10 #include "nsBidiKeyboard.h"
11 #include "nsIWidget.h"
12 #include <gtk/gtk.h>
14 NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
16 nsBidiKeyboard::nsBidiKeyboard() { Reset(); }
18 NS_IMETHODIMP
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);
29 return NS_OK;
32 nsBidiKeyboard::~nsBidiKeyboard() = default;
34 NS_IMETHODIMP
35 nsBidiKeyboard::IsLangRTL(bool* aIsRTL) {
36 if (!mHaveBidiKeyboards) return NS_ERROR_FAILURE;
38 *aIsRTL = (gdk_keymap_get_direction(gdk_keymap_get_default()) ==
39 PANGO_DIRECTION_RTL);
41 return NS_OK;
44 NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) {
45 // not implemented yet
46 return NS_ERROR_NOT_IMPLEMENTED;
49 // static
50 already_AddRefed<nsIBidiKeyboard> nsIWidget::CreateBidiKeyboardInner() {
51 return do_AddRef(new nsBidiKeyboard());