1
0
mirror of https://github.com/artizirk/wdisplays.git synced 2024-11-21 16:30:59 +02:00

improve form consistency

This commit is contained in:
Jason Francis 2019-07-06 13:12:28 -04:00
parent b278730ddd
commit e7ac3fa7ad
8 changed files with 552 additions and 401 deletions

View File

@ -2,11 +2,55 @@
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkAdjustment" id="scal">
<property name="upper">99999999999999</property>
<object class="GtkAdjustment" id="height_adjustment">
<property name="upper">16383</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkPopover" id="modes">
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="mode_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkAdjustment" id="pos_x_adjustment">
<property name="lower">-16384</property>
<property name="upper">16383</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="pos_y_adjustment">
<property name="lower">-16384</property>
<property name="upper">16383</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="refresh_adjustment">
<property name="upper">2147483.647</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="scale_adjustment">
<property name="upper">99999</property>
<property name="step_increment">0.1</property>
<property name="page_increment">0.5</property>
</object>
<object class="GtkAdjustment" id="width_adjustment">
<property name="upper">16383</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkGrid" id="form">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -52,8 +96,8 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="width_chars">6</property>
<property name="adjustment">scal</property>
<property name="width_chars">9</property>
<property name="adjustment">scale_adjustment</property>
<property name="digits">2</property>
<property name="value">1</property>
<signal name="change-value" handler="scale" swapped="no"/>
@ -67,7 +111,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Scale</property>
<property name="label" translatable="yes">DPI _Scale</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">scale</property>
<property name="xalign">1</property>
@ -77,20 +121,6 @@
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Si_ze</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">width</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@ -105,184 +135,6 @@
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Refresh</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">refresh</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="spacing">8</property>
<child>
<object class="GtkEntry" id="refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">10</property>
<property name="input_purpose">number</property>
<signal name="changed" handler="refresh" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hz</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<child>
<object class="GtkEntry" id="pos_x">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="input_purpose">number</property>
<signal name="changed" handler="pos_x" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">,</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="pos_y">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="input_purpose">number</property>
<signal name="changed" handler="pos_y" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<child>
<object class="GtkEntry" id="width">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="input_purpose">number</property>
<signal name="changed" handler="width" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">×</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="height">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="input_purpose">number</property>
<signal name="changed" handler="height" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="mode_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Select Mode Preset</property>
<property name="margin_start">8</property>
<property name="popover">modes</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@ -325,13 +177,68 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Transform</property>
<property name="label" translatable="yes">Si_ze</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">width</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="spacing">8</property>
<child>
<object class="GtkSpinButton" id="refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">9</property>
<property name="input_purpose">number</property>
<property name="adjustment">refresh_adjustment</property>
<property name="digits">3</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Hz</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Refresh Rate</property>
<property name="use_underline">True</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -349,6 +256,19 @@
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Transform</property>
<property name="use_underline">True</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="flipped">
<property name="label" translatable="yes">_Flipped</property>
@ -366,28 +286,126 @@
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<object class="GtkPopover" id="modes">
<property name="can_focus">False</property>
<property name="relative_to">mode_button</property>
<child>
<object class="GtkBox" id="mode_box">
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="orientation">vertical</property>
<property name="row_spacing">8</property>
<child>
<object class="GtkSpinButton" id="pos_x">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="text" translatable="yes">0</property>
<property name="input_purpose">number</property>
<property name="adjustment">pos_x_adjustment</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="pos_y">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">6</property>
<property name="text" translatable="yes">0</property>
<property name="input_purpose">number</property>
<property name="adjustment">pos_y_adjustment</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="width">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="input_purpose">number</property>
<property name="adjustment">width_adjustment</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="width_request">20</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">×</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="height">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="input_purpose">number</property>
<property name="adjustment">height_adjustment</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="mode_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Select Mode Preset</property>
<property name="margin_left">8</property>
<property name="margin_start">8</property>
<property name="popover">modes</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">view-more-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="height">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<object class="GtkPopover" id="transforms">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/">
<file compressed="true" preprocess="xml-stripblanks">waydisplay.ui</file>
<file compressed="true" preprocess="xml-stripblanks">wdisplay.ui</file>
<file compressed="true" preprocess="xml-stripblanks">head.ui</file>
<file compressed="true">style.css</file>
</gresource>

View File

@ -7,3 +7,13 @@ spinner {
spinner.visible {
opacity: 1;
}
.head {
border: 1px solid @borders;
border-radius: 1px;
background-color: @theme_bg_color;
transition: background-color 200ms ease-in-out;
}
.head:hover {
background-color: @theme_selected_bg_color;
}

View File

@ -2,78 +2,180 @@
<!-- Generated with glade 3.22.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<!-- interface-css-provider-path style.css -->
<object class="GtkPopover" id="main_menu">
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="action_name">app.auto-apply</property>
<property name="text" translatable="yes">_Automatically Apply Changes</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkWindow" id="heads_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Waydisplay</property>
<signal name="destroy" handler="destroy" swapped="no"/>
<child>
<object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkPaned">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">400</property>
<property name="position_set">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="heads_scroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLayout" id="heads_layout">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="width">400</property>
<signal name="draw" handler="heads_draw" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<object class="GtkInfoBar" id="heads_info">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStackSwitcher" id="heads_stack_switcher">
<property name="visible">True</property>
<property name="no_show_all">True</property>
<property name="valign">start</property>
<property name="message_type">error</property>
<property name="show_close_button">True</property>
<property name="revealed">False</property>
<signal name="response" handler="info_response" swapped="no"/>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="margin_start">8</property>
<property name="margin_end">8</property>
<property name="margin_top">8</property>
<property name="hexpand">True</property>
<property name="stack">heads_stack</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="heads_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="heads_info_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">400</property>
<property name="position_set">True</property>
<child>
<object class="GtkScrolledWindow" id="heads_scroll">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkLayout" id="heads_layout">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="width">400</property>
<signal name="draw" handler="heads_draw" swapped="no"/>
</object>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStackSwitcher" id="heads_stack_switcher">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_start">8</property>
<property name="margin_end">8</property>
<property name="margin_top">8</property>
<property name="hexpand">True</property>
<property name="stack">heads_stack</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkStack" id="heads_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="transition_type">crossfade</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
@ -94,59 +196,6 @@
<property name="pass_through">True</property>
</packing>
</child>
<child type="overlay">
<object class="GtkInfoBar" id="heads_info">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="valign">start</property>
<property name="message_type">error</property>
<property name="show_close_button">True</property>
<property name="revealed">False</property>
<signal name="response" handler="info_response" swapped="no"/>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="heads_info_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="index">1</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
@ -158,7 +207,7 @@
<object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Waydisplay</property>
<property name="title" translatable="yes">wdisplay</property>
<property name="has_subtitle">False</property>
<property name="show_close_button">True</property>
<child>
@ -230,6 +279,25 @@
</child>
</object>
</child>
<child>
<object class="GtkMenuButton" id="menu_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="popover">main_menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">title</property>

View File

@ -41,6 +41,7 @@ __attribute__((noreturn)) void wd_fatal_error(int status, const char *message) {
static const char *MODE_PREFIX = "mode";
static const char *TRANSFORM_PREFIX = "transform";
static const char *APP_PREFIX = "app";
#define NUM_ROTATIONS 4
static const char *ROTATE_IDS[NUM_ROTATIONS] = {
@ -66,25 +67,27 @@ static bool has_changes(const struct wd_state *state) {
if (head->enabled != gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "enabled")))) {
return TRUE;
}
if (head->scale != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "scale")))) {
double old_scale = round(head->scale * 100.) / 100.;
double new_scale = round(gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "scale"))) * 100.) / 100.;
if (old_scale != new_scale) {
return TRUE;
}
if (head->x != atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_x"))))) {
if (head->x != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_x")))) {
return TRUE;
}
if (head->y != atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_y"))))) {
if (head->y != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_y")))) {
return TRUE;
}
int w = head->mode != NULL ? head->mode->width : head->custom_mode.width;
if (w != atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "width"))))) {
if (w != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "width")))) {
return TRUE;
}
int h = head->mode != NULL ? head->mode->height : head->custom_mode.height;
if (h != atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "height"))))) {
if (h != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "height")))) {
return TRUE;
}
int r = head->mode != NULL ? head->mode->refresh : head->custom_mode.refresh;
if (r / 1000. != atof(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "refresh"))))) {
if (r / 1000. != gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "refresh")))) {
return TRUE;
}
for (int i = 0; i < NUM_ROTATIONS; i++) {
@ -109,10 +112,85 @@ static bool has_changes(const struct wd_state *state) {
return FALSE;
}
void fill_output_from_form(struct wd_head_config *output, GtkWidget *form) {
GtkBuilder *builder = GTK_BUILDER(g_object_get_data(G_OBJECT(form), "builder"));
output->head = g_object_get_data(G_OBJECT(form), "head");
output->enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "enabled")));
output->scale = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "scale")));
output->x = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_x")));
output->y = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_y")));
output->width = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "width")));
output->height = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "height")));
output->refresh = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "refresh"))) * 1000.;
gboolean flipped = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "flipped")));
for (int i = 0; i < NUM_ROTATIONS; i++) {
GtkWidget *rotate = GTK_WIDGET(gtk_builder_get_object(builder, ROTATE_IDS[i]));
gboolean selected;
g_object_get(rotate, "active", &selected, NULL);
if (selected) {
switch (i) {
case 0: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED : WL_OUTPUT_TRANSFORM_NORMAL; break;
case 1: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_90 : WL_OUTPUT_TRANSFORM_90; break;
case 2: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_180 : WL_OUTPUT_TRANSFORM_180; break;
case 3: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_270 : WL_OUTPUT_TRANSFORM_270; break;
}
break;
}
}
}
static gboolean send_apply(gpointer data) {
struct wd_state *state = data;
struct wl_list *outputs = calloc(1, sizeof(*outputs));
wl_list_init(outputs);
g_autoptr(GList) forms = gtk_container_get_children(GTK_CONTAINER(state->stack));
for (GList *form_iter = forms; form_iter != NULL; form_iter = form_iter->next) {
struct wd_head_config *output = calloc(1, sizeof(*output));
wl_list_insert(outputs, &output->link);
fill_output_from_form(output, GTK_WIDGET(form_iter->data));
}
wd_apply_state(state, outputs);
state->apply_pending = false;
return FALSE;
}
static void apply_state(struct wd_state *state) {
gtk_stack_set_visible_child_name(GTK_STACK(state->header_stack), "title");
if (!state->autoapply) {
gtk_style_context_add_class(gtk_widget_get_style_context(state->spinner), "visible");
gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(state->overlay), state->spinner, FALSE);
gtk_widget_set_sensitive(state->stack_switcher, FALSE);
gtk_widget_set_sensitive(state->stack, FALSE);
gtk_widget_set_sensitive(state->zoom_in, FALSE);
gtk_widget_set_sensitive(state->zoom_reset, FALSE);
gtk_widget_set_sensitive(state->zoom_out, FALSE);
gtk_widget_set_sensitive(state->menu_button, FALSE);
}
/* queue this once per iteration in order to prevent duplicate updates */
if (!state->apply_pending) {
state->apply_pending = true;
g_idle_add(send_apply, state);
}
}
static gboolean apply_done_reset(gpointer data) {
wd_ui_reset_all(data);
return FALSE;
}
// BEGIN FORM CALLBACKS
static void show_apply(struct wd_state *state) {
bool changed = has_changes(state);
gtk_stack_set_visible_child_name(GTK_STACK(state->header_stack), changed ? "apply" : "title");
const gchar *page = "title";
if (has_changes(state)) {
if (state->autoapply) {
apply_state(state);
} else {
page = "apply";
}
}
gtk_stack_set_visible_child_name(GTK_STACK(state->header_stack), page);
gtk_widget_queue_draw(state->canvas);
}
@ -167,12 +245,9 @@ static void update_mode_entries(GtkWidget *form, int32_t w, int32_t h, int32_t r
GtkWidget *height = GTK_WIDGET(gtk_builder_get_object(builder, "height"));
GtkWidget *refresh = GTK_WIDGET(gtk_builder_get_object(builder, "refresh"));
g_autofree gchar *widthstr = g_strdup_printf("%d", w);
gtk_entry_set_text(GTK_ENTRY(width), widthstr);
g_autofree gchar *heightstr = g_strdup_printf("%d", h);
gtk_entry_set_text(GTK_ENTRY(height), heightstr);
g_autofree gchar *refreshstr = g_strdup_printf("%0.3f", r / 1000.0);
gtk_entry_set_text(GTK_ENTRY(refresh), refreshstr);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(width), w);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(height), h);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(refresh), r / 1000.);
}
static void mode_selected(GSimpleAction *action, GVariant *param, gpointer data) {
@ -203,6 +278,10 @@ static void update_canvas_size(struct wd_state *state) {
w = head->mode->width;
h = head->mode->height;
}
if (head->scale > 0.) {
w /= head->scale;
h /= head->scale;
}
int x2 = head->x + w;
int y2 = head->y + h;
@ -255,10 +334,8 @@ static void update_head_form(GtkWidget *form, unsigned int fields) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(scale), head->scale);
}
if (fields & WD_FIELD_POSITION) {
g_autofree gchar *xstr = g_strdup_printf("%d", head->x);
gtk_entry_set_text(GTK_ENTRY(pos_x), xstr);
g_autofree gchar *ystr = g_strdup_printf("%d", head->y);
gtk_entry_set_text(GTK_ENTRY(pos_y), ystr);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pos_x), head->x);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pos_y), head->y);
}
if (fields & WD_FIELD_MODE) {
@ -362,11 +439,11 @@ void wd_ui_reset_heads(struct wd_state *state) {
g_signal_connect_swapped(gtk_builder_get_object(builder, "enabled"), "toggled", G_CALLBACK(update_sensitivity), form);
g_signal_connect_swapped(gtk_builder_get_object(builder, "enabled"), "toggled", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "scale"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "pos_x"), "changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "pos_y"), "changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "width"), "changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "height"), "changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "refresh"), "changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "pos_x"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "pos_y"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "width"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "height"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "refresh"), "value-changed", G_CALLBACK(show_apply), state);
g_signal_connect_swapped(gtk_builder_get_object(builder, "flipped"), "toggled", G_CALLBACK(show_apply), state);
} else {
@ -418,7 +495,11 @@ void wd_ui_apply_done(struct wd_state *state, struct wl_list *outputs) {
gtk_widget_set_sensitive(state->zoom_in, TRUE);
gtk_widget_set_sensitive(state->zoom_reset, TRUE);
gtk_widget_set_sensitive(state->zoom_out, TRUE);
show_apply(state);
gtk_widget_set_sensitive(state->menu_button, TRUE);
if (!state->autoapply) {
show_apply(state);
}
g_idle_add(apply_done_reset, state);
}
void wd_ui_show_error(struct wd_state *state, const char *message) {
@ -427,33 +508,6 @@ void wd_ui_show_error(struct wd_state *state, const char *message) {
gtk_info_bar_set_revealed(GTK_INFO_BAR(state->info_bar), TRUE);
}
void fill_output_from_form(struct wd_head_config *output, GtkWidget *form) {
GtkBuilder *builder = GTK_BUILDER(g_object_get_data(G_OBJECT(form), "builder"));
output->head = g_object_get_data(G_OBJECT(form), "head");
output->enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "enabled")));
output->scale = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "scale")));
output->x = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_x"))));
output->y = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_y"))));
output->width = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "width"))));
output->height = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "height"))));
output->refresh = atof(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "refresh")))) * 1000.;
gboolean flipped = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "flipped")));
for (int i = 0; i < NUM_ROTATIONS; i++) {
GtkWidget *rotate = GTK_WIDGET(gtk_builder_get_object(builder, ROTATE_IDS[i]));
gboolean selected;
g_object_get(rotate, "active", &selected, NULL);
if (selected) {
switch (i) {
case 0: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED : WL_OUTPUT_TRANSFORM_NORMAL; break;
case 1: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_90 : WL_OUTPUT_TRANSFORM_90; break;
case 2: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_180 : WL_OUTPUT_TRANSFORM_180; break;
case 3: output->transform = flipped ? WL_OUTPUT_TRANSFORM_FLIPPED_270 : WL_OUTPUT_TRANSFORM_270; break;
}
break;
}
}
}
// BEGIN GLOBAL CALLBACKS
static void cleanup(GtkWidget *window, gpointer state) {
g_free(state);
@ -482,15 +536,17 @@ gboolean draw(GtkWidget *widget, cairo_t *cr, gpointer data) {
GtkBuilder *builder = GTK_BUILDER(g_object_get_data(G_OBJECT(form_iter->data), "builder"));
gboolean enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "enabled")));
if (enabled) {
int x = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_x"))));
int y = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "pos_y"))));
int w = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "width"))));
int h = atoi(gtk_entry_get_text(GTK_ENTRY(gtk_builder_get_object(builder, "height"))));
int x = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_x")));
int y = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "pos_y")));
int w = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "width")));
int h = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "height")));
double scale = gtk_spin_button_get_value(GTK_SPIN_BUTTON(gtk_builder_get_object(builder, "scale")));
if (scale <= 0.) scale = 1.;
cairo_rectangle(cr,
x * state->zoom + .5 - scroll_x - state->xorigin,
y * state->zoom + .5 - scroll_y - state->yorigin,
w * state->zoom,
h * state->zoom);
w * state->zoom / scale,
h * state->zoom / scale);
cairo_stroke(cr);
}
}
@ -505,26 +561,7 @@ static void cancel_changes(GtkButton *button, gpointer data) {
}
static void apply_changes(GtkButton *button, gpointer data) {
struct wd_state *state = data;
gtk_stack_set_visible_child_name(GTK_STACK(state->header_stack), "title");
gtk_style_context_add_class(gtk_widget_get_style_context(state->spinner), "visible");
gtk_overlay_set_overlay_pass_through(GTK_OVERLAY(state->overlay), state->spinner, FALSE);
gtk_widget_set_sensitive(state->stack_switcher, FALSE);
gtk_widget_set_sensitive(state->stack, FALSE);
gtk_widget_set_sensitive(state->zoom_in, FALSE);
gtk_widget_set_sensitive(state->zoom_reset, FALSE);
gtk_widget_set_sensitive(state->zoom_out, FALSE);
struct wl_list *outputs = calloc(1, sizeof(*outputs));
wl_list_init(outputs);
g_autoptr(GList) forms = gtk_container_get_children(GTK_CONTAINER(state->stack));
for (GList *form_iter = forms; form_iter != NULL; form_iter = form_iter->next) {
struct wd_head_config *output = calloc(1, sizeof(*output));
wl_list_insert(outputs, &output->link);
fill_output_from_form(output, GTK_WIDGET(form_iter->data));
}
wd_apply_state(state, outputs);
apply_state(data);
}
static void update_zoom(struct wd_state *state) {
@ -567,6 +604,12 @@ static void info_bar_animation_done(GObject *object, GParamSpec *pspec, gpointer
}
}
static void auto_apply_selected(GSimpleAction *action, GVariant *param, gpointer data) {
struct wd_state *state = data;
state->autoapply = !state->autoapply;
g_simple_action_set_state(action, g_variant_new_boolean(state->autoapply));
}
static void activate(GtkApplication* app, gpointer user_data) {
GdkDisplay *gdk_display = gdk_display_get_default();
if (!GDK_IS_WAYLAND_DISPLAY(gdk_display)) {
@ -582,7 +625,7 @@ static void activate(GtkApplication* app, gpointer user_data) {
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
GtkBuilder *builder = gtk_builder_new_from_resource("/wd.ui");
GtkBuilder *builder = gtk_builder_new_from_resource("/wdisplay.ui");
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "heads_window"));
state->header_stack = GTK_WIDGET(gtk_builder_get_object(builder, "header_stack"));
state->stack_switcher = GTK_WIDGET(gtk_builder_get_object(builder, "heads_stack_switcher"));
@ -596,6 +639,7 @@ static void activate(GtkApplication* app, gpointer user_data) {
state->overlay = GTK_WIDGET(gtk_builder_get_object(builder, "overlay"));
state->info_bar = GTK_WIDGET(gtk_builder_get_object(builder, "heads_info"));
state->info_label = GTK_WIDGET(gtk_builder_get_object(builder, "heads_info_label"));
state->menu_button = GTK_WIDGET(gtk_builder_get_object(builder, "menu_button"));
gtk_builder_add_callback_symbol(builder, "heads_draw", G_CALLBACK(draw));
gtk_builder_add_callback_symbol(builder, "apply_changes", G_CALLBACK(apply_changes));
gtk_builder_add_callback_symbol(builder, "cancel_changes", G_CALLBACK(cancel_changes));
@ -603,10 +647,20 @@ static void activate(GtkApplication* app, gpointer user_data) {
gtk_builder_add_callback_symbol(builder, "zoom_reset", G_CALLBACK(zoom_reset));
gtk_builder_add_callback_symbol(builder, "zoom_in", G_CALLBACK(zoom_in));
gtk_builder_add_callback_symbol(builder, "info_response", G_CALLBACK(info_response));
gtk_builder_add_callback_symbol(builder, "destroy", G_CALLBACK(cleanup));
gtk_builder_connect_signals(builder, state);
gtk_box_set_homogeneous(GTK_BOX(gtk_builder_get_object(builder, "zoom_box")), FALSE);
update_zoom(state);
GSimpleActionGroup *main_actions = g_simple_action_group_new();
gtk_widget_insert_action_group(state->menu_button, APP_PREFIX, G_ACTION_GROUP(main_actions));
g_object_unref(main_actions);
GSimpleAction *autoapply_action = g_simple_action_new_stateful("auto-apply", NULL,
g_variant_new_boolean(state->autoapply));
g_signal_connect(autoapply_action, "activate", G_CALLBACK(auto_apply_selected), state);
g_action_map_add_action(G_ACTION_MAP(main_actions), G_ACTION(autoapply_action));
/* first child of GtkInfoBar is always GtkRevealer */
g_autoptr(GList) info_children = gtk_container_get_children(GTK_CONTAINER(state->info_bar));
g_signal_connect(info_children->data, "notify::child-revealed", G_CALLBACK(info_bar_animation_done), state);
@ -620,7 +674,6 @@ static void activate(GtkApplication* app, gpointer user_data) {
gtk_application_add_window(app, GTK_WINDOW(window));
gtk_widget_show_all(window);
g_signal_connect(window, "destroy", G_CALLBACK(cleanup), state);
g_object_unref(builder);
}
// END GLOBAL CALLBACKS

View File

@ -17,5 +17,6 @@ executable(
wayland_client,
client_protos,
gtk
]
],
install: true
)

View File

@ -65,7 +65,6 @@ static void config_handle_failed(void *data,
struct zwlr_output_configuration_v1 *config) {
struct wd_pending_config *pending = data;
zwlr_output_configuration_v1_destroy(config);
wd_ui_reset_all(pending->state);
wd_ui_apply_done(pending->state, NULL);
wd_ui_show_error(pending->state,
"The display server was not able to process your changes.");
@ -76,7 +75,6 @@ static void config_handle_cancelled(void *data,
struct zwlr_output_configuration_v1 *config) {
struct wd_pending_config *pending = data;
zwlr_output_configuration_v1_destroy(config);
wd_ui_reset_all(pending->state);
wd_ui_apply_done(pending->state, NULL);
wd_ui_show_error(pending->state,
"The display configuration was modified by the server before updates were processed. "

View File

@ -103,6 +103,8 @@ struct wd_state {
struct wl_list heads;
uint32_t serial;
bool apply_pending;
bool autoapply;
double zoom;
int xorigin;
int yorigin;
@ -119,6 +121,7 @@ struct wd_state {
GtkWidget *overlay;
GtkWidget *info_bar;
GtkWidget *info_label;
GtkWidget *menu_button;
};
/*