Merge remote-tracking branch 'upstream/master' into tray-child-window
This commit is contained in:
commit
0096fea839
@ -7,6 +7,9 @@ indent_style = space
|
||||
indent_size = 2
|
||||
charset = utf-8
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added experimental support for positioning the tray like a module
|
||||
- `internal/backlight`: `scroll-interval` option ([`#2696`](https://github.com/polybar/polybar/issues/2696), [`#2700`](https://github.com/polybar/polybar/pull/2700))
|
||||
- `internal/temperature`: Added `zone-type` setting ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2752`](https://github.com/polybar/polybar/pull/2752)) by [@xphoniex](https://github.com/xphoniex)
|
||||
- `internal/xwindow`: `%class%` and `%instance%` tokens, which show the contents of the `WM_CLASS` property of the active window ([`#2830`](https://github.com/polybar/polybar/pull/2830))
|
||||
|
||||
### Changed
|
||||
- `internal/fs`: Use `/` as a fallback if no mountpoints are specified ([`#2572`](https://github.com/polybar/polybar/issues/2572), [`#2705`](https://github.com/polybar/polybar/pull/2705))
|
||||
@ -40,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- config:
|
||||
- Error reporting for deprecated config values ([`#2724`](https://github.com/polybar/polybar/issues/2724))
|
||||
- Also monitor include-files for changes when --reload is set ([`#675`](https://github.com/polybar/polybar/issues/675), [`#2759`](https://github.com/polybar/polybar/pull/2759))
|
||||
- `internal/xwindow`: module does not crash when a tag is not provided in format ([`#2826`](https://github.com/polybar/polybar/issues/2826), [`#2833`](https://github.com/polybar/polybar/pull/2833)) by [@VanillaViking](https://github.com/VanillaViking)
|
||||
|
||||
## [3.6.3] - 2022-05-04
|
||||
### Fixed
|
||||
|
@ -17,13 +17,23 @@ add_custom_target(uninstall
|
||||
# folders where the clang tools should operate
|
||||
set(CLANG_SEARCH_PATHS ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/tests)
|
||||
|
||||
# Target: codeformat (clang-format) {{{
|
||||
# Runs clang-format on all source files
|
||||
add_custom_target(
|
||||
clangformat
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/common/file-runner.py
|
||||
--dirs ${CLANG_SEARCH_PATHS}
|
||||
-- clang-format -style=file -i --verbose
|
||||
)
|
||||
|
||||
add_custom_target(codeformat)
|
||||
add_custom_command(TARGET codeformat
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/common/clang-format.sh ${CLANG_SEARCH_PATHS})
|
||||
# Dry-runs clang-format on all source files
|
||||
# Useful for CI since it will exit with an error code
|
||||
add_custom_target(
|
||||
clangformat-dryrun
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/common/file-runner.py
|
||||
--dirs ${CLANG_SEARCH_PATHS}
|
||||
-- clang-format -style=file --dry-run -Werror --verbose
|
||||
)
|
||||
|
||||
# }}}
|
||||
# Target: codecheck (clang-tidy) {{{
|
||||
|
||||
add_custom_target(codecheck)
|
||||
|
@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
main() {
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "$0 DIR..." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Search paths
|
||||
search="${*:-.}"
|
||||
|
||||
echo "$0 in $search"
|
||||
|
||||
# shellcheck disable=2086
|
||||
find $search -regex ".*.[c|h]pp" \
|
||||
-exec printf "\\033[32;1m** \\033[0mFormatting %s\\n" {} \; \
|
||||
-exec clang-format -style=file -i {} \;
|
||||
}
|
||||
|
||||
main "$@"
|
50
common/file-runner.py
Executable file
50
common/file-runner.py
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
EXTENSIONS = set('.' + ext for ext in ['c', 'h', 'cpp', 'hpp', 'inl'])
|
||||
|
||||
|
||||
def get_files(dirs):
|
||||
"""
|
||||
Generator which yields all files in the given directories with any of the
|
||||
EXTENSIONS.
|
||||
"""
|
||||
for dir in dirs:
|
||||
for root, _, files in os.walk(dir):
|
||||
for file in files:
|
||||
path = Path(os.path.join(root, file))
|
||||
if path.suffix in EXTENSIONS:
|
||||
yield path
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="""
|
||||
Run command on all C/C++ source files in the given directories
|
||||
""")
|
||||
parser.add_argument('--dirs', type=Path, nargs='+',
|
||||
help='Directories to search in')
|
||||
parser.add_argument('command', nargs='+',
|
||||
help='Command to which to pass found files')
|
||||
args = parser.parse_args()
|
||||
|
||||
all_files = list(str(file) for file in get_files(args.dirs))
|
||||
|
||||
if not all_files:
|
||||
print("No files found")
|
||||
sys.exit(1)
|
||||
|
||||
result = subprocess.run(args.command + all_files)
|
||||
print(f'Formatted {len(all_files)} files')
|
||||
|
||||
if result.returncode != 0:
|
||||
sys.exit(result.returncode)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -96,7 +96,7 @@ master_doc = 'index'
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
# language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
|
@ -11,13 +11,15 @@ POLYBAR_NS
|
||||
class connection;
|
||||
|
||||
namespace modules {
|
||||
class active_window {
|
||||
class active_window : public non_copyable_mixin, public non_movable_mixin {
|
||||
public:
|
||||
explicit active_window(xcb_connection_t* conn, xcb_window_t win);
|
||||
~active_window();
|
||||
|
||||
bool match(const xcb_window_t win) const;
|
||||
bool match(xcb_window_t win) const;
|
||||
string title() const;
|
||||
string instance_name() const;
|
||||
string class_name() const;
|
||||
|
||||
private:
|
||||
xcb_connection_t* m_connection{nullptr};
|
||||
@ -33,7 +35,7 @@ namespace modules {
|
||||
enum class state { NONE, ACTIVE, EMPTY };
|
||||
explicit xwindow_module(const bar_settings&, string);
|
||||
|
||||
void update(bool force = false);
|
||||
void update();
|
||||
bool build(builder* builder, const string& tag) const;
|
||||
|
||||
static constexpr auto TYPE = "internal/xwindow";
|
||||
@ -41,6 +43,8 @@ namespace modules {
|
||||
protected:
|
||||
void handle(const evt::property_notify& evt) override;
|
||||
|
||||
void reset_active_window();
|
||||
|
||||
private:
|
||||
static constexpr const char* TAG_LABEL{"<label>"};
|
||||
|
||||
@ -49,6 +53,6 @@ namespace modules {
|
||||
map<state, label_t> m_statelabels;
|
||||
label_t m_label;
|
||||
};
|
||||
} // namespace modules
|
||||
} // namespace modules
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -10,7 +10,7 @@ struct cached_atom {
|
||||
xcb_atom_t& atom;
|
||||
};
|
||||
|
||||
extern std::array<cached_atom, 36> ATOMS;
|
||||
extern std::array<cached_atom, 38> ATOMS;
|
||||
|
||||
extern xcb_atom_t _NET_SUPPORTED;
|
||||
extern xcb_atom_t _NET_CURRENT_DESKTOP;
|
||||
@ -48,3 +48,5 @@ extern xcb_atom_t ESETROOT_PMAP_ID;
|
||||
extern xcb_atom_t _COMPTON_SHADOW;
|
||||
extern xcb_atom_t _NET_WM_WINDOW_OPACITY;
|
||||
extern xcb_atom_t WM_HINTS;
|
||||
extern xcb_atom_t WM_NAME;
|
||||
extern xcb_atom_t WM_CLASS;
|
||||
|
@ -8,6 +8,7 @@ POLYBAR_NS
|
||||
|
||||
namespace icccm_util {
|
||||
string get_wm_name(xcb_connection_t* c, xcb_window_t w);
|
||||
pair<string, string> get_wm_class(xcb_connection_t* c, xcb_window_t w);
|
||||
string get_reply_string(xcb_icccm_get_text_property_reply_t* reply);
|
||||
|
||||
void set_wm_name(xcb_connection_t* c, xcb_window_t w, const char* wmname, size_t l, const char* wmclass, size_t l2);
|
||||
@ -15,6 +16,6 @@ namespace icccm_util {
|
||||
bool get_wm_urgency(xcb_connection_t* c, xcb_window_t w);
|
||||
|
||||
void set_wm_size_hints(xcb_connection_t* c, xcb_window_t w, int x, int y, int width, int height);
|
||||
}
|
||||
} // namespace icccm_util
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -42,6 +42,7 @@ namespace modules {
|
||||
* Get the title by returning the first non-empty value of:
|
||||
* _NET_WM_NAME
|
||||
* _NET_WM_VISIBLE_NAME
|
||||
* WM_NAME
|
||||
*/
|
||||
string active_window::title() const {
|
||||
string title;
|
||||
@ -57,6 +58,14 @@ namespace modules {
|
||||
}
|
||||
}
|
||||
|
||||
string active_window::instance_name() const {
|
||||
return icccm_util::get_wm_class(m_connection, m_window).first;
|
||||
}
|
||||
|
||||
string active_window::class_name() const {
|
||||
return icccm_util::get_wm_class(m_connection, m_window).second;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct module
|
||||
*/
|
||||
@ -84,12 +93,13 @@ namespace modules {
|
||||
*/
|
||||
void xwindow_module::handle(const evt::property_notify& evt) {
|
||||
if (evt->atom == _NET_ACTIVE_WINDOW) {
|
||||
update(true);
|
||||
} else if (evt->atom == _NET_CURRENT_DESKTOP) {
|
||||
update(true);
|
||||
} else if (evt->atom == _NET_WM_VISIBLE_NAME) {
|
||||
reset_active_window();
|
||||
update();
|
||||
} else if (evt->atom == _NET_WM_NAME) {
|
||||
} else if (evt->atom == _NET_CURRENT_DESKTOP) {
|
||||
reset_active_window();
|
||||
update();
|
||||
} else if (evt->atom == _NET_WM_NAME || evt->atom == _NET_WM_VISIBLE_NAME || evt->atom == WM_NAME ||
|
||||
evt->atom == WM_CLASS) {
|
||||
update();
|
||||
} else {
|
||||
return;
|
||||
@ -98,26 +108,31 @@ namespace modules {
|
||||
broadcast();
|
||||
}
|
||||
|
||||
void xwindow_module::reset_active_window() {
|
||||
m_active.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the currently active window and query its title
|
||||
*/
|
||||
void xwindow_module::update(bool force) {
|
||||
xcb_window_t win;
|
||||
|
||||
if (force) {
|
||||
m_active.reset();
|
||||
void xwindow_module::update() {
|
||||
if (!m_active) {
|
||||
xcb_window_t win = ewmh_util::get_active_window();
|
||||
if (win != XCB_NONE) {
|
||||
m_active = make_unique<active_window>(m_connection, win);
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_active && (win = ewmh_util::get_active_window()) != XCB_NONE) {
|
||||
m_active = make_unique<active_window>(m_connection, win);
|
||||
}
|
||||
|
||||
if (m_active) {
|
||||
m_label = m_statelabels.at(state::ACTIVE)->clone();
|
||||
m_label->reset_tokens();
|
||||
m_label->replace_token("%title%", m_active->title());
|
||||
} else {
|
||||
m_label = m_statelabels.at(state::EMPTY)->clone();
|
||||
if (!m_statelabels.empty()) {
|
||||
if (m_active) {
|
||||
m_label = m_statelabels.at(state::ACTIVE)->clone();
|
||||
m_label->reset_tokens();
|
||||
m_label->replace_token("%title%", m_active->title());
|
||||
m_label->replace_token("%instance%", m_active->instance_name());
|
||||
m_label->replace_token("%class%", m_active->class_name());
|
||||
} else {
|
||||
m_label = m_statelabels.at(state::EMPTY)->clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,11 @@ xcb_atom_t ESETROOT_PMAP_ID;
|
||||
xcb_atom_t _COMPTON_SHADOW;
|
||||
xcb_atom_t _NET_WM_WINDOW_OPACITY;
|
||||
xcb_atom_t WM_HINTS;
|
||||
xcb_atom_t WM_NAME;
|
||||
xcb_atom_t WM_CLASS;
|
||||
|
||||
// clang-format off
|
||||
std::array<cached_atom, 36> ATOMS = {{
|
||||
std::array<cached_atom, 38> ATOMS = {{
|
||||
{"_NET_SUPPORTED", _NET_SUPPORTED},
|
||||
{"_NET_CURRENT_DESKTOP", _NET_CURRENT_DESKTOP},
|
||||
{"_NET_ACTIVE_WINDOW", _NET_ACTIVE_WINDOW},
|
||||
@ -78,5 +80,7 @@ std::array<cached_atom, 36> ATOMS = {{
|
||||
{"_COMPTON_SHADOW", _COMPTON_SHADOW},
|
||||
{"_NET_WM_WINDOW_OPACITY", _NET_WM_WINDOW_OPACITY},
|
||||
{"WM_HINTS", WM_HINTS},
|
||||
{"WM_NAME", WM_NAME},
|
||||
{"WM_CLASS", WM_CLASS},
|
||||
}};
|
||||
// clang-format on
|
||||
|
@ -13,6 +13,16 @@ namespace icccm_util {
|
||||
return "";
|
||||
}
|
||||
|
||||
pair<string, string> get_wm_class(xcb_connection_t* c, xcb_window_t w) {
|
||||
pair<string, string> result{"", ""};
|
||||
xcb_icccm_get_wm_class_reply_t reply{};
|
||||
if (xcb_icccm_get_wm_class_reply(c, xcb_icccm_get_wm_class(c, w), &reply, nullptr)) {
|
||||
result = {string(reply.instance_name), string(reply.class_name)};
|
||||
xcb_icccm_get_wm_class_reply_wipe(&reply);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string get_reply_string(xcb_icccm_get_text_property_reply_t* reply) {
|
||||
string str;
|
||||
if (reply) {
|
||||
|
Loading…
Reference in New Issue
Block a user