Skip to content
Permalink
Browse files

Don't send commands to daemon while idle

  • Loading branch information
tatokis committed Mar 16, 2020
1 parent afd0e19 commit 50865dc8e49e2e072b12a8b5eb761ef64e67e0a4
Showing with 11 additions and 9 deletions.
  1. +3 −5 src/gui/kb.cpp
  2. +3 −2 src/gui/kbbind.cpp
  3. +1 −1 src/gui/kbbind.h
  4. +2 −1 src/gui/kblight.cpp
  5. +2 −0 src/gui/kbperf.cpp
@@ -451,14 +451,12 @@ void Kb::frameUpdate(){
index = 3 + index % 3;

// Send lighting/binding to driver
cmd.write(QString("mode %1 switch ").arg(index + 1).toLatin1());
if(prevMode != _currentMode || changed)
cmd.write(QString("mode %1 switch ").arg(index + 1).toLatin1());
perf->applyIndicators(index, iState);
light->frameUpdate(cmd, monochrome);
cmd.write(QString("\n@%1 ").arg(notifyNumber).toLatin1());
bind->update(cmd, changed);
cmd.write(" ");
bind->update(cmd, notifyNumber, changed);
perf->update(cmd, notifyNumber, changed, true);
cmd.write("\n");
cmd.flush();
}

@@ -237,14 +237,14 @@ void KbBind::setAction(const QString& key, const QString& action){
_bind[rKey] = new KeyAction(action, this);
}

void KbBind::update(QFile& cmd, bool force){
void KbBind::update(QFile& cmd, int notify, bool force){
if(!force && !_needsUpdate && lastGlobalRemapTime == globalRemapTime)
return;
lastGlobalRemapTime = globalRemapTime;
emit updated();
_needsUpdate = false;
// Reset all keys and enable notifications for all
cmd.write("rebind all notify all");
cmd.write(QString("\n@%1 rebind all notify all").arg(notify).toLatin1());
// Make sure modifier keys are included as they may be remapped globally
QHash<QString, KeyAction*> bind(_bind);
if(!_bind.contains("caps")) bind["caps"] = 0;
@@ -299,6 +299,7 @@ void KbBind::update(QFile& cmd, bool force){
// At last, send Macro definitions if available.
// If no definitions are made, clear macro will be sent only to reset all macros,
cmd.write(macros.toLatin1());
cmd.write("\n");
lastCmd = &cmd;
}

@@ -85,7 +85,7 @@ class KbBind : public QObject

// Updates bindings to the driver. Write "mode %d" first.
// By default, nothing will be written unless bindings have changed. Use force = true or call setNeedsUpdate() to override.
void update(QFile& cmd, bool force = false);
void update(QFile& cmd, int notify, bool force = false);
inline void setNeedsUpdate() { _needsUpdate = true; }

////////
@@ -356,7 +356,7 @@ void KbLight::frameUpdate(QFile& cmd, bool monochrome){

// If brightness is at 0%, turn off lighting entirely
if(_dimming == 3){
cmd.write("rgb 000000");
cmd.write("rgb 000000\n");
return;
}

@@ -382,6 +382,7 @@ void KbLight::frameUpdate(QFile& cmd, bool monochrome){
// Apply light
cmd.write("rgb");
printRGB(cmd, _animMap);
cmd.write("\n");
}

void KbLight::base(QFile &cmd, bool ignoreDim, bool monochrome){
@@ -509,6 +509,7 @@ void KbPerf::update(QFile& cmd, int notifyNumber, bool force, bool saveCustomDpi
return;
emit settingsUpdated();
_needsUpdate = false;
cmd.write(" ");
// Save DPI stage 0 (sniper)
// If the mouse is set to a custom DPI, save it in stage 0
int stage = pushedDpis.isEmpty() ? dpiBaseIdx : 0;
@@ -549,6 +550,7 @@ void KbPerf::update(QFile& cmd, int notifyNumber, bool force, bool saveCustomDpi
cmd.write(" iauto ");
cmd.write(iNames[i]);
}
cmd.write("\n");
}

void KbPerf::lightIndicator(const char* name, QRgb rgba){

0 comments on commit 50865dc

Please sign in to comment.
You can’t perform that action at this time.