技术标签: java
码云地址:https://gitee.com/zhang_yi_qiang/A-simple-hybrid-calculator
写了好几天了终于写完了这个四则运算计算器,总代码放在后面
截图如下:
首先是布局都比较简单,最上面的一个框是总的输出框,
第二个框是每次输入的数字显示在框内,
对于每一个按钮都增加监听器,
对于数字按钮:当长度大于8的 或者等号已经出现之后就不再处理按钮事件
if(e.getSource().equals(button1)) {
s=numberText.getText();
//数字长度大于8或者等号已出现
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("1");
}else {
numberText.setText(s + "1");
}
}
其余的按钮都差不多。
当按钮为小数点时,长度大于7就不再处理,因为总的长度不能超过8,而小数点后面还要与数字,
同时标记小数点已经出现过,因为一个数中最多出现一个小数点
//当按钮为小数点时
if(e.getSource().equals(buttonpoint)) {
s=numberText.getText();
if(s.length()>7 || equalbook == 1) {
}
if(pointbook==0) {
numberText.setText(s + ".");
pointbook = 1;
}
}
当按钮为加号时:
当数字输入框为空时不做处理
也有可能是最后一位是小数点,当然也不处理
当最上方的输出框的最后一位是右括号的时候,可以用加号
//当按钮为加号时
if(e.getSource().equals(buttonadd)) {
s=numberText.getText();
char ch1[] = s.toCharArray();
int length1 = s.length() - 1;
String S = expressText.getText();
char ch2[] = S.toCharArray();
int length2 = S.length() - 1;
//当数字为空或为0或数字的最后一位是小数点时不作处理
if((length2 == -1 ||ch2[length2] != ')') && (s.equals("0") || s.equals("") || ch1[length1] == '.')) {
}else {
numberText.setText("");
expressText.setText(expressText.getText() + s + "+");
}
}
+, -, *, /都差不多
当前面是运算符或者左括号的时候才能用左括号, 注意当框内无元素的时候也可以加左括号, 但是需要判断元素的个数是否大于0
if(e.getSource().equals(buttonleft)) {
if(!numberText.getText().equals("0") && !numberText.getText().contentEquals("")) {
expressText.setText(expressText.getText() + numberText.getText());
}
s=expressText.getText();
char ch[] = s.toCharArray();
int length = s.length() - 1;
/*
* 当前面是运算符或者左括号的时候才能用左括号
* 注意当框内无元素的时候也可以加左括号
* 但是需要判断元素的个数是否大于0
*/
if(length == -1 || ch[length] == '+' || ch[length] == '-' ||
ch[length] == '*' || ch[length] == '/' ||
ch[length] == '(' || s.equals("")) {
expressText.setText(expressText.getText() + '(');
leftNum++;
}
}
右括号就不一样
if(e.getSource().equals(buttonright)) {
if(!numberText.getText().equals("0")) {
expressText.setText(expressText.getText() + numberText.getText());
numberText.setText("");
}
s=expressText.getText();
char ch[] = s.toCharArray();
int length = s.length() - 1;
/*
* 只有前面是数字的时候且左括
* 号的数量大于右括号的数量的时候才能加右括号
*/
if(Character.isDigit(ch[length]) && leftNum > rightNum) {
rightNum++;
expressText.setText(expressText.getText() + ')');
}
}
当按钮为 C时,清除所有内容并更新等号状态, 左括号数量, 右括号数量, 小数点状态,当一次计算完成之后,只有按C按钮才能进行新的计算。
当按钮为CE时,只清除数字框中的内容。
if(e.getSource().equals(buttonC)) {
numberText.setText("0");
expressText.setText("");
leftNum = 0;
rightNum = 0;
pointbook = 0;
equalbook = 0;
}
当按钮为等号时就把总输出框中显示的字符串取出进行计算,因为这个计算器是带括号的,所以这里我用了逆波兰表达式做的,需要把中缀表达式变为后缀表达式,然后进行计算,这一点我认为是最困难的一点,后面有时间我会再写关于 逆波兰表达式实现以及 逆波兰表达式的求值。
需要注意588行的代码,最后的两个括号的条件没有加上,导致花了周末一天在找bug......
else if((ch[j] == '*' || ch[j] == '/') &&
(operater1=='+' || operater1=='-') ||
(operater1=='(' || operater1 == ')')) {
Operater.push(ch[j]);
break;
}
所有代码:
package cn.edu.shengda;
/*
* author 201705050153 张宜强
*/
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Stack;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
public class Calculator extends JFrame implements ActionListener {
Calculator() {
init();
}
public void init() {
JFrame frame = new JFrame ("计算器");
frame.setLayout(null);
//放置数字0
button0 = new JButton("0");
button0.setBounds(20, 200, 100, 25);
frame.add(button0);
//放置数字1
button1 = new JButton("1");
button1.setBounds(20, 170, 45, 25);
frame.add(button1);
//放置数字2
button2 = new JButton("2");
button2.setBounds(75, 170, 45, 25);
frame.add(button2);
//放置数字3
button3 = new JButton("3");
button3.setBounds(130, 170, 45, 25);
frame.add(button3);
//放置数字4
button4 = new JButton("4");
button4.setBounds(20, 140, 45, 25);
frame.add(button4);
//放置数字5
button5 = new JButton("5");
button5.setBounds(75, 140, 45, 25);
frame.add(button5);
//放置数字6
button6 = new JButton("6");
button6.setBounds(130, 140, 45, 25);
frame.add(button6);
//放置数字7
button7 = new JButton("7");
button7.setBounds(20, 110, 45, 25);
frame.add(button7);
//放置数字8
button8 = new JButton("8");
button8.setBounds(75, 110, 45, 25);
frame.add(button8);
//放置数字9
button9 = new JButton("9");
button9.setBounds(130, 110, 45, 25);
frame.add(button9);
//放置 .
buttonpoint = new JButton(".");
buttonpoint.setBounds(130, 200, 45, 25);
frame.add(buttonpoint);
//放置 +
buttonadd = new JButton("+");
buttonadd.setBounds(185, 200, 45, 25);
frame.add(buttonadd);
//放置 -
buttonreduce = new JButton("-");
buttonreduce.setBounds(185, 170, 45, 25);
frame.add(buttonreduce);
//放置 *
buttonride = new JButton("*");
buttonride.setBounds(185, 140, 45, 25);
frame.add(buttonride);
//放置 /
buttonexcept = new JButton("/");
buttonexcept.setBounds(185, 110, 45, 25);
frame.add(buttonexcept);
//放置 =
buttonequal = new JButton("=");
buttonequal.setBounds(240, 170, 55, 55);
frame.add(buttonequal);
//计算1/x
buttoninvert = new JButton("1/x");
buttoninvert.setBounds(240, 110, 55, 55);
frame.add(buttoninvert);
//放置左括号
buttonleft = new JButton("(");
buttonleft.setBounds(20, 80, 45, 25);
frame.add(buttonleft);
//放置右括号
buttonright = new JButton(")");
buttonright.setBounds(75, 80, 45, 25);
frame.add(buttonright);
//放置C 消除所有输入
buttonC = new JButton("C");
buttonC.setBounds(130, 80, 75, 25);
frame.add(buttonC);
//放置CE 消除当前输入
buttonCE = new JButton("CE");
buttonCE.setBounds(220, 80, 75, 25);
frame.add(buttonCE);
//添加表达式文本框
expressText = new JTextField();
expressText.setBounds(20, 10, 300, 30);
frame.add(expressText);
//添加数字文本框
numberText = new JTextField("0");
numberText.setBounds(20, 40, 300, 30);
frame.add(numberText);
//加监听器
button0.addActionListener(this);
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
button6.addActionListener(this);
button7.addActionListener(this);
button8.addActionListener(this);
button9.addActionListener(this);
buttonpoint.addActionListener(this);
buttonadd.addActionListener(this);
buttonreduce.addActionListener(this);
buttonride.addActionListener(this);
buttonexcept.addActionListener(this);
buttoninvert.addActionListener(this);
buttonequal.addActionListener(this);
buttonleft.addActionListener(this);
buttonright.addActionListener(this);
buttonC.addActionListener(this);
buttonCE.addActionListener(this);
numberText.addActionListener(this);
expressText.addActionListener(this);
frame.setBounds(0, 0, 350, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
JButton button0;
JButton button1;
JButton button2;
JButton button3;
JButton button4;
JButton button5;
JButton button6;
JButton button7;
JButton button8;
JButton button9;
JButton buttonpoint;
JButton buttonadd;
JButton buttonreduce;
JButton buttonride;
JButton buttonexcept;
JButton buttonequal;
JButton buttoninvert;
JButton buttonleft;
JButton buttonright;
JButton buttonC;
JButton buttonCE;
JTextField numberText;
JTextField expressText;
String s = null;
//记录小数点是否出现,每次当前数字框中只能出现一个小数点
int pointbook = 0;
//记录等号是否出现,每次计算的总算式只能出现一个等号
int equalbook = 0;
//记录左括号的数量
int leftNum = 0;
//记录有括号的数量
int rightNum = 0;
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//当按钮为0时
if(e.getSource().equals(button0)) {
s=numberText.getText();
if(s.length()>8) {
}
else if(s.equals("0") || equalbook == 1) {
}else {
numberText.setText(s + "0");
}
}
//当按钮为1时
if(e.getSource().equals(button1)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("1");
}else {
numberText.setText(s + "1");
}
}
//当按钮为2时
if(e.getSource().equals(button2)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("2");
}else {
numberText.setText(s + "2");
}
}
//当按钮为3时
if(e.getSource().equals(button3)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("3");
}else {
numberText.setText(s + "3");
}
}
//当按钮为4时
if(e.getSource().equals(button4)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("4");
}else {
numberText.setText(s + "4");
}
}
//当按钮为5时
if(e.getSource().equals(button5)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("5");
}else {
numberText.setText(s + "5");
}
}
//当按钮为6时
if(e.getSource().equals(button6)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("6");
}else {
numberText.setText(s + "6");
}
}
//当按钮为7时
if(e.getSource().equals(button7)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("7");
}else {
numberText.setText(s + "7");
}
}
//当按钮为3时
if(e.getSource().equals(button8)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("8");
}else {
numberText.setText(s + "8");
}
}
//当按钮为9时
if(e.getSource().equals(button9)) {
s=numberText.getText();
if(s.length()>8 || equalbook == 1) {
}
else if(s.equals("0") || s.equals("")) {
numberText.setText("9");
}else {
numberText.setText(s + "9");
}
}
//当按钮为小数点时
if(e.getSource().equals(buttonpoint)) {
s=numberText.getText();
if(s.length()>7 || equalbook == 1) {
}
if(pointbook==0) {
numberText.setText(s + ".");
pointbook = 1;
}
}
//当按钮为加号时
if(e.getSource().equals(buttonadd)) {
s=numberText.getText();
char ch1[] = s.toCharArray();
int length1 = s.length() - 1;
String S = expressText.getText();
char ch2[] = S.toCharArray();
int length2 = S.length() - 1;
//当数字为空或为0或数字的最后一位是小数点时不作处理
if((length2 == -1 ||ch2[length2] != ')') && (s.equals("0") || s.equals("") || ch1[length1] == '.')) {
}else {
numberText.setText("");
expressText.setText(expressText.getText() + s + "+");
}
}
//当按钮为减号时
if(e.getSource().equals(buttonreduce)) {
s=numberText.getText();
char ch1[] = s.toCharArray();
int length1 = s.length() - 1;
String S = expressText.getText();
char ch2[] = S.toCharArray();
int length2 = S.length() - 1;
if((length2 == -1 ||ch2[length2] != ')') && (s.equals("0") || s.equals("") || ch1[length1]=='.')) {
}else {
numberText.setText("");
expressText.setText(expressText.getText() + s + "-");
}
}
//当按钮为乘号时
if(e.getSource().equals(buttonride)) {
s=numberText.getText();
char ch1[] = s.toCharArray();
int length1 = s.length() - 1;
String S = expressText.getText();
char ch2[] = S.toCharArray();
int length2 = S.length() - 1;
if((length2 == -1 ||ch2[length2] != ')') && (s.equals("0") || s.equals("") || ch1[length1]=='.')) {
}else {
numberText.setText("");
expressText.setText(expressText.getText() + s + "*");
}
}
//当按钮为除号时
if(e.getSource().equals(buttonexcept)) {
s=numberText.getText();
char ch1[] = s.toCharArray();
int length1 = s.length() - 1;
String S = expressText.getText();
char ch2[] = S.toCharArray();
int length2 = S.length() - 1;
if((length2 == -1 ||ch2[length2] != ')') && (s.equals("0") || s.equals("") || ch1[length1]=='.')) {
}else {
numberText.setText("");
expressText.setText(expressText.getText() + s + "/");
}
}
//当按钮为左括号时
if(e.getSource().equals(buttonleft)) {
if(!numberText.getText().equals("0") && !numberText.getText().contentEquals("")) {
expressText.setText(expressText.getText() + numberText.getText());
}
s=expressText.getText();
char ch[] = s.toCharArray();
int length = s.length() - 1;
/*
* 当前面是运算符或者左括号的时候才能用左括号
* 注意当框内无元素的时候也可以加左括号
* 但是需要判断元素的个数是否大于0
*/
if(length == -1 || ch[length] == '+' || ch[length] == '-' ||
ch[length] == '*' || ch[length] == '/' ||
ch[length] == '(' || s.equals("")) {
expressText.setText(expressText.getText() + '(');
leftNum++;
}
}
//当按钮为右括号时
if(e.getSource().equals(buttonright)) {
if(!numberText.getText().equals("0")) {
expressText.setText(expressText.getText() + numberText.getText());
numberText.setText("");
}
s=expressText.getText();
char ch[] = s.toCharArray();
int length = s.length() - 1;
/*
* 只有前面是数字的时候且左括
* 号的数量大于右括号的数量的时候才能加右括号
*/
if(Character.isDigit(ch[length]) && leftNum > rightNum) {
rightNum++;
expressText.setText(expressText.getText() + ')');
}
}
/*
*当按钮为 C时
*清除所有内容
*并更新等号状态, 左括号数量, 右括号数量, 小数点状态
*当一次计算完成之后,只有按CE按钮才能进行新的计算
*/
if(e.getSource().equals(buttonC)) {
numberText.setText("0");
expressText.setText("");
leftNum = 0;
rightNum = 0;
pointbook = 0;
equalbook = 0;
}
/*
*当按钮为CE时,
*清除当前数字框中内容
*更新小数点状态
*/
if(e.getSource().equals(buttonCE)) {
numberText.setText("0");
pointbook = 0;
}
//当按钮为1/x时把输入框中的值变为倒数
if(e.getSource().equals(buttoninvert) ) {
s = numberText.getText();
//等于0的时候不进行操作
if(s.equals("0")) {
}else {
double a = Double.parseDouble(numberText.getText());
a = 1/a;
numberText.setText(String.valueOf(a));
}
}
//当按钮为等于号时
if(e.getSource().equals(buttonequal)) {
s=numberText.getText();
if(!s.equals("0") && !s.equals("")) {
expressText.setText(expressText.getText() + s);
}
//当等号没有出现时才能输入等号
if(equalbook == 0) {
numberText.setText("");
//补全右括号
for(int i = 0; i < leftNum - rightNum; i++) {
expressText.setText(expressText.getText() + ')');
}
/*
* 声明栈
* 一个char型存储运算符
* 将中缀表达式转化为逆波兰表达式
*/
String[] ansString = new String[100];
int Size = 0;
Stack<Character> Operater = new Stack<Character>();
s = expressText.getText();
char ch[] = s.toCharArray();
int length = ch.length;
for(int j = 0; j < length; j++) {
//当数组元素为数字时
if(ch[j] >='0' && ch[j] <= '9') {
double Number = ch[j] - '0';
//继续往后遍历,直到不是数字和小数点
//记录小数点是否出现
int point = 0;
//记录小数点出现后的位数
int bit = 1;
if(j==length-1) {
ansString[Size++] = String.valueOf(Number);
}
for(j++; j<length; j++) {
if((ch[j] < '0' || ch[j] >'9') && ch[j]!='.') {
j--;
ansString[Size++] = String.valueOf(Number);
break;
}
if(ch[j] == '.') {
point = 1;
continue;
}
if(ch[j] >= '0' && ch[j] <= '9') {
/*
* 当小数点没有出现时和没出现时要分开讨论
*/
if(point == 0) {
Number = Number * 10 + (ch[j] - '0');
} else {
Number = Number + Math.pow(10, -bit) * (ch[j]-'0');
bit++;
}
}
}
} else { //考虑运算符
if(ch[j] =='(') {
Operater.push('(');
} else if(ch[j]==')') {
while(!Operater.peek().equals('(')) {
ansString[Size++] = String.valueOf(Operater.peek());
Operater.pop();
}
Operater.pop();
} else {
if(Operater.empty()) {
Operater.push(ch[j]);
}
else {
//System.out.println("!" + ch[j]);
while(true) {
if(Operater.empty()) {
Operater.push(ch[j]);
break;
}
char operater1 = Operater.peek();
if((ch[j] == '*' || ch[j] == '/') &&
(operater1=='+' || operater1=='-') || (operater1=='(' || operater1 == ')')) {
Operater.push(ch[j]);
break;
}
else {
ansString[Size++] = String.valueOf(Operater.peek());
Operater.pop();
}
}
}
}
}
}//System.out.println(s);
while(!Operater.empty()) {
ansString[Size++] = String.valueOf(Operater.peek());
Operater.pop();
}
// for(int i=0; i<Size; i++)
// System.out.println(ansString[i]);
//最后计算逆波兰表达式的值
Stack<Double> Last = new Stack<Double>();
for(int i=0; i<Size; i++) {
String s1 = ansString[i];
char ch2[] = s1.toCharArray();
if(ch2[0]>='0' && ch2[0]<='9') {
Last.push(Double.parseDouble(s1));
}
else {
double num1 = Last.pop();
double num2 = Last.pop();
double num3 = 0;
if(ch2[0]=='+')
num3 = num2 + num1;
else if(ch2[0]=='-')
num3 = num2 - num1;
else if(ch2[0]=='*')
num3 = num2 * num1;
else if(ch2[0]=='/')
num3 = num2 / num1;
Last.push(num3);
}
}
expressText.setText(expressText.getText() + "=" + Last.pop());
equalbook = 1;
}
}
}
public static void main(String []args) {
Calculator calculator = new Calculator();
}
}
文章浏览阅读1k次。通过使用ajax方法跨域请求是浏览器所不允许的,浏览器出于安全考虑是禁止的。警告信息如下:不过jQuery对跨域问题也有解决方案,使用jsonp的方式解决,方法如下:$.ajax({ async:false, url: 'http://www.mysite.com/demo.do', // 跨域URL ty..._nginx不停的xhr
文章浏览阅读2k次。关于在 Oracle 中配置 extproc 以访问 ST_Geometry,也就是我们所说的 使用空间SQL 的方法,官方文档链接如下。http://desktop.arcgis.com/zh-cn/arcmap/latest/manage-data/gdbs-in-oracle/configure-oracle-extproc.htm其实简单总结一下,主要就分为以下几个步骤。..._extproc
文章浏览阅读1.5w次。linux下没有上面的两个函数,需要使用函数 mbstowcs和wcstombsmbstowcs将多字节编码转换为宽字节编码wcstombs将宽字节编码转换为多字节编码这两个函数,转换过程中受到系统编码类型的影响,需要通过设置来设定转换前和转换后的编码类型。通过函数setlocale进行系统编码的设置。linux下输入命名locale -a查看系统支持的编码_linux c++ gbk->utf8
文章浏览阅读750次。今天准备从生产库向测试库进行数据导入,结果在imp导入的时候遇到“ IMP-00009:导出文件异常结束” 错误,google一下,发现可能有如下原因导致imp的数据太大,没有写buffer和commit两个数据库字符集不同从低版本exp的dmp文件,向高版本imp导出的dmp文件出错传输dmp文件时,文件损坏解决办法:imp时指定..._imp-00009导出文件异常结束
文章浏览阅读143次。当下是一个大数据的时代,各个行业都离不开数据的支持。因此,网络爬虫就应运而生。网络爬虫当下最为火热的是Python,Python开发爬虫相对简单,而且功能库相当完善,力压众多开发语言。本次教程我们爬取前程无忧的招聘信息来分析Python程序员需要掌握那些编程技术。首先在谷歌浏览器打开前程无忧的首页,按F12打开浏览器的开发者工具。浏览器开发者工具是用于捕捉网站的请求信息,通过分析请求信息可以了解请..._初级python程序员能力要求
文章浏览阅读7.6k次,点赞2次,收藏6次。@Service标注的bean,类名:ABDemoService查看源码后发现,原来是经过一个特殊处理:当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致public class AnnotationBeanNameGenerator implements BeanNameGenerator { private static final String C..._@service beanname
文章浏览阅读6.9w次,点赞73次,收藏463次。1.前序创建#include<stdio.h>#include<string.h>#include<stdlib.h>#include<malloc.h>#include<iostream>#include<stack>#include<queue>using namespace std;typed_二叉树的建立
文章浏览阅读7.1k次。在Asp.net上使用Excel导出功能,如果文件名出现中文,便会以乱码视之。 解决方法: fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);_asp.net utf8 导出中文字符乱码
文章浏览阅读2.1k次,点赞4次,收藏23次。第一次实验 词法分析实验报告设计思想词法分析的主要任务是根据文法的词汇表以及对应约定的编码进行一定的识别,找出文件中所有的合法的单词,并给出一定的信息作为最后的结果,用于后续语法分析程序的使用;本实验针对 PL/0 语言 的文法、词汇表编写一个词法分析程序,对于每个单词根据词汇表输出: (单词种类, 单词的值) 二元对。词汇表:种别编码单词符号助记符0beginb..._对pl/0作以下修改扩充。增加单词
文章浏览阅读773次。我在使用adb.exe时遇到了麻烦.我想使用与bash相同的adb.exe shell提示符,所以我决定更改默认的bash二进制文件(当然二进制文件是交叉编译的,一切都很完美)更改bash二进制文件遵循以下顺序> adb remount> adb push bash / system / bin /> adb shell> cd / system / bin> chm..._adb shell mv 权限
文章浏览阅读6.8k次,点赞12次,收藏125次。1. 单目相机标定引言相机标定已经研究多年,标定的算法可以分为基于摄影测量的标定和自标定。其中,应用最为广泛的还是张正友标定法。这是一种简单灵活、高鲁棒性、低成本的相机标定算法。仅需要一台相机和一块平面标定板构建相机标定系统,在标定过程中,相机拍摄多个角度下(至少两个角度,推荐10~20个角度)的标定板图像(相机和标定板都可以移动),即可对相机的内外参数进行标定。下面介绍张氏标定法(以下也这么称呼)的原理。原理相机模型和单应矩阵相机标定,就是对相机的内外参数进行计算的过程,从而得到物体到图像的投影_相机-投影仪标定
文章浏览阅读2.2k次。文章目录Wayland 架构Wayland 渲染Wayland的 硬件支持简 述: 翻译一篇关于和 wayland 有关的技术文章, 其英文标题为Wayland Architecture .Wayland 架构若是想要更好的理解 Wayland 架构及其与 X (X11 or X Window System) 结构;一种很好的方法是将事件从输入设备就开始跟踪, 查看期间所有的屏幕上出现的变化。这就是我们现在对 X 的理解。 内核是从一个输入设备中获取一个事件,并通过 evdev 输入_wayland