From patchwork Mon Mar 18 11:31:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 780912 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp1377265wrs; Mon, 18 Mar 2024 04:32:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVN3CI+c3xxr8/hGCjIVYcsSM4dQybrxWNeKlPiXbi7zvsaytiiCPOBHTB4U8ZXeYSUIKGGhgTG40wnx2J9QoUR X-Google-Smtp-Source: AGHT+IF6xjDbH9ftIMqJCmsCGar6VEViyiX8/lKP87deBHxzL+PZ8pOiHw63iZn2pC5YbO8Kwe7g X-Received: by 2002:a05:620a:801c:b0:789:e7ec:d606 with SMTP id ee28-20020a05620a801c00b00789e7ecd606mr13289224qkb.6.1710761545294; Mon, 18 Mar 2024 04:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710761545; cv=none; d=google.com; s=arc-20160816; b=HRpjQqv6IwnctQfgP+27cJl/CACsVt0S8wep15bnBbCYDxt6pXfJ+kyluEQJarUfHj gEsGxsqY99ZKZZIwdYCBHT4qN+Ew9FJUvjR+1R55oj1JZD44oDYI7OlKXtpS39/HOjrK k5vgXMLC1AYNCSAyVDMqqNYp8B1QQdGj9aY7GAsNMTRsrU2Prdjpp7V3smGb7a05cATA 4NeAqx2n2lrcGTUh6bfeVOIMtIji4pQfzdrRumVtBjMlLNp5Wxxh1rNT6Xzs8WIN9J6O Vu3PD2uRx5+8e0m5bb/e67YGw8i4MmbTTAa817ga1b0NNEaMjaT5pavan1rdxZPPr5h8 d9Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CYjr201DlEJ4l0jHNZURE4npfEFxYjcehCBVscFCuRE=; fh=ZHIWNRx+rEvHyVsyvIT+SxJMVv6/ti8EiM9uHXaYuG4=; b=Weg87THQvYj8hwG8bCr9Hw7Hd1HakJd4zEFBVudC00KeMuD1H7DukjhNFSYYAy67Y+ Kyvwh5SheBXQuR2vT+2p7kdGH9mZUrlWBG6aaHKTXj0yKZ5PtfFnanKpkOVGCEn6EFUd UXfNwQm9zFfdjLB04gOH1WxzOgmMtyumSYEyvlJudLbbHMUc5OmYIBEM35EhQt9ZVoNF U71tJ6iXlZU/r6kj6542s9x36KlyZY/h3GzbWhCwpkUn4+nbEuVmdGHFz/fLE5ZiaNqU COeZl7g4V/nv2Ro0fooK/VknJ2OTR0IE/q8ucGxFPGeaxS87AEAxKW6kOOB+DxAvdxOA YXTw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqpNx0VC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id de7-20020a05620a370700b00789d99cc609si9203531qkb.549.2024.03.18.04.32.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Mar 2024 04:32:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JqpNx0VC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rmBDe-00086b-Gi; Mon, 18 Mar 2024 07:31:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rmBDc-000865-SG for qemu-devel@nongnu.org; Mon, 18 Mar 2024 07:31:52 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rmBDb-00073e-61 for qemu-devel@nongnu.org; Mon, 18 Mar 2024 07:31:52 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-33e672e10cfso2125108f8f.0 for ; Mon, 18 Mar 2024 04:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710761509; x=1711366309; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CYjr201DlEJ4l0jHNZURE4npfEFxYjcehCBVscFCuRE=; b=JqpNx0VCRlsxEdNDVGEWoRghM25n95vy7Q03+PhyY2LFAFSNm6x3Zppkv++hRQ4B/X BkcI6OrsbWsY3XMyt1uP9f82UK0PMTC8fm6k080K8qo8kTaXIUc+AaKw/29xzgt4U5df LMeLQnpwUVG15ts0sgCZVv8IbtOouX9lizCbJRj9QUHllQjmzPuBtGXxULIIGevPbxA8 AYPlB3BwucCLn33QR45C6uBXMCLxCxFBBKeYep1NFC4mmecy853gSUdA3nDqwSOPIeHV sI2lg/XB4KDxr9vF9s12e3WxP8xYYKTPcijmLhMAPT+VCa8RZNiO3XraKbS7pzTBRGnm mQZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710761509; x=1711366309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CYjr201DlEJ4l0jHNZURE4npfEFxYjcehCBVscFCuRE=; b=OhZgMF18T6uOqbAgEy7QHpfR0IxSJb8Re6lGv+BdwOA+gD9StZBFsUCNql76KFs2/L zmdUhR11/tQ2BIy1bzJgqbqLB5V2rYiVX9BkdGZ44NJlRNXqaFt00qydBJYTTtp5MzO8 YJJWCIW8Kd+XEXfflObqi/xNy+N8kphUeKZ5F2LAELyPdpAbLY7DqVOoePXfQpV4Us5Y AkVJbI8Wm/wmSnHxqOXuoa79DYXdvrn2v/OipoeOTN08xcd2Wnvq/XVM0VXOWiVK7YVe CWhtNg9pppDOGnsC3puVSZppNJfW0z//80O2twudTXTNrEqJi05TZbwcEGZnH18mwwcS 7ACA== X-Gm-Message-State: AOJu0Yx2Y00qpv+V3SPZYKq44tHOPc5tRY+LDTGN5C7xaGXoXUWvG94i n0OZKoU+McsrvlIorPoH1v/gBIKtyFEKghPpGzoBJFZc8RA7k4KX/crmH+0TeC4wLUs9dmP3hJ5 k X-Received: by 2002:adf:ca88:0:b0:33e:6495:3273 with SMTP id r8-20020adfca88000000b0033e64953273mr8314765wrh.4.1710761509290; Mon, 18 Mar 2024 04:31:49 -0700 (PDT) Received: from m1x-phil.lan (vit94-h02-176-184-29-165.dsl.sta.abo.bbox.fr. [176.184.29.165]) by smtp.gmail.com with ESMTPSA id bq24-20020a5d5a18000000b0033ed8643638sm6202549wrb.106.2024.03.18.04.31.47 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 18 Mar 2024 04:31:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Akihiko Odaki , qemu-arm@nongnu.org, =?utf-8?q?Mar?= =?utf-8?q?c-Andr=C3=A9_Lureau?= , Gerd Hoffmann , Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.1 v2 1/3] ui/console: Introduce API to change console orientation Date: Mon, 18 Mar 2024 12:31:38 +0100 Message-ID: <20240318113140.88151-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240318113140.88151-1-philmd@linaro.org> References: <20240318113140.88151-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Extract the following methods: - qemu_console_set_rotate() - qemu_console_is_rotated() - qemu_console_get_rotate_arcdegree() Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki --- include/ui/console.h | 3 +++ ui/console.c | 16 ++++++++++++++++ ui/input.c | 9 ++++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index a4a49ffc64..86ba36e391 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -422,15 +422,18 @@ bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); bool qemu_console_is_gl_blocked(QemuConsole *con); +bool qemu_console_is_rotated(QemuConsole *con); char *qemu_console_get_label(QemuConsole *con); int qemu_console_get_index(QemuConsole *con); uint32_t qemu_console_get_head(QemuConsole *con); int qemu_console_get_width(QemuConsole *con, int fallback); int qemu_console_get_height(QemuConsole *con, int fallback); +unsigned qemu_console_get_rotate_arcdegree(QemuConsole *con); /* Return the low-level window id for the console */ int qemu_console_get_window_id(QemuConsole *con); /* Set the low-level window id for the console */ void qemu_console_set_window_id(QemuConsole *con, int window_id); +void qemu_console_set_rotate(QemuConsole *con, unsigned arcdegree); void console_select(unsigned int index); void qemu_console_resize(QemuConsole *con, int width, int height); diff --git a/ui/console.c b/ui/console.c index 832055675c..84aee76846 100644 --- a/ui/console.c +++ b/ui/console.c @@ -37,6 +37,7 @@ #include "trace.h" #include "exec/memory.h" #include "qom/object.h" +#include "sysemu/sysemu.h" #include "console-priv.h" @@ -207,6 +208,21 @@ void qemu_console_set_window_id(QemuConsole *con, int window_id) con->window_id = window_id; } +void qemu_console_set_rotate(QemuConsole *con, unsigned arcdegree) +{ + graphic_rotate = arcdegree; +} + +bool qemu_console_is_rotated(QemuConsole *con) +{ + return graphic_rotate != 0; +} + +unsigned qemu_console_get_rotate_arcdegree(QemuConsole *con) +{ + return graphic_rotate; +} + void graphic_hw_invalidate(QemuConsole *con) { if (!con) { diff --git a/ui/input.c b/ui/input.c index dc745860f4..951806bf05 100644 --- a/ui/input.c +++ b/ui/input.c @@ -1,5 +1,4 @@ #include "qemu/osdep.h" -#include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qapi-commands-ui.h" #include "trace.h" @@ -179,10 +178,10 @@ static int qemu_input_transform_invert_abs_value(int value) return (int64_t)INPUT_EVENT_ABS_MAX - value + INPUT_EVENT_ABS_MIN; } -static void qemu_input_transform_abs_rotate(InputEvent *evt) +static void qemu_input_transform_abs_rotate(QemuConsole *src, InputEvent *evt) { InputMoveEvent *move = evt->u.abs.data; - switch (graphic_rotate) { + switch (qemu_console_get_rotate_arcdegree(src)) { case 90: if (move->axis == INPUT_AXIS_X) { move->axis = INPUT_AXIS_Y; @@ -341,8 +340,8 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt) qemu_input_event_trace(src, evt); /* pre processing */ - if (graphic_rotate && (evt->type == INPUT_EVENT_KIND_ABS)) { - qemu_input_transform_abs_rotate(evt); + if (qemu_console_is_rotated(src) && (evt->type == INPUT_EVENT_KIND_ABS)) { + qemu_input_transform_abs_rotate(src, evt); } /* send event */