mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix: cancel thread and fix window close
This commit is contained in:
@ -3,11 +3,11 @@
|
||||
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
|
||||
* Copyright 2009 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright 2009 Tim Gardner <tim.gardner@canonical.com>
|
||||
*
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
@ -17,24 +17,24 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||
|
||||
#include "util/rfkill.hpp"
|
||||
#include <linux/rfkill.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstring>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <linux/rfkill.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/poll.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
waybar::util::Rfkill::Rfkill(const enum rfkill_type rfkill_type)
|
||||
: rfkill_type_(rfkill_type) {
|
||||
}
|
||||
waybar::util::Rfkill::Rfkill(const enum rfkill_type rfkill_type) : rfkill_type_(rfkill_type) {}
|
||||
|
||||
void waybar::util::Rfkill::waitForEvent() {
|
||||
struct rfkill_event event;
|
||||
struct pollfd p;
|
||||
ssize_t len;
|
||||
int fd, n;
|
||||
struct pollfd p;
|
||||
ssize_t len;
|
||||
int fd, n;
|
||||
|
||||
fd = open("/dev/rfkill", O_RDONLY);
|
||||
if (fd < 0) {
|
||||
@ -53,8 +53,7 @@ void waybar::util::Rfkill::waitForEvent() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
continue;
|
||||
if (n == 0) continue;
|
||||
|
||||
len = read(fd, &event, sizeof(event));
|
||||
if (len < 0) {
|
||||
@ -67,17 +66,13 @@ void waybar::util::Rfkill::waitForEvent() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(event.type == rfkill_type_ && event.op == RFKILL_OP_CHANGE) {
|
||||
if (event.type == rfkill_type_ && event.op == RFKILL_OP_CHANGE) {
|
||||
state_ = event.soft || event.hard;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool waybar::util::Rfkill::getState() const {
|
||||
return state_;
|
||||
}
|
||||
bool waybar::util::Rfkill::getState() const { return state_; }
|
||||
|
Reference in New Issue
Block a user