mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Cycle active window with button
A new button is added to the UI so that we can cycle the currently active window when there are more windows to capture. It's like pressing the F11 button but it works on Android too.
This commit is contained in:
committed by
Baldur Karlsson
parent
c132142723
commit
369d93b99c
@@ -122,6 +122,7 @@ LiveCapture::LiveCapture(ICaptureContext &ctx, const QString &hostname, const QS
|
||||
ui->triggerDelayedCapture->setEnabled(false);
|
||||
ui->triggerImmediateCapture->setEnabled(false);
|
||||
ui->queueCap->setEnabled(false);
|
||||
ui->cycleActiveWindow->setEnabled(false);
|
||||
|
||||
ui->target->setText(QString());
|
||||
|
||||
@@ -282,6 +283,11 @@ void LiveCapture::on_triggerImmediateCapture_clicked()
|
||||
m_CaptureNumFrames = (int)ui->numFrames->value();
|
||||
}
|
||||
|
||||
void LiveCapture::on_cycleActiveWindow_clicked()
|
||||
{
|
||||
m_Connection->CycleActiveWindow();
|
||||
}
|
||||
|
||||
void LiveCapture::on_triggerDelayedCapture_clicked()
|
||||
{
|
||||
if(ui->captureDelay->value() == 0.0)
|
||||
@@ -1257,6 +1263,12 @@ void LiveCapture::connectionThreadEntry()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(msg.type == TargetControlMessageType::CapturableWindowCount)
|
||||
{
|
||||
uint32_t windows = msg.capturableWindowCount;
|
||||
GUIInvoke::call(this, [this, windows]() { ui->cycleActiveWindow->setEnabled(windows > 1); });
|
||||
}
|
||||
}
|
||||
|
||||
GUIInvoke::call(this, [this]() {
|
||||
@@ -1269,6 +1281,7 @@ void LiveCapture::connectionThreadEntry()
|
||||
ui->triggerDelayedCapture->setEnabled(false);
|
||||
ui->triggerImmediateCapture->setEnabled(false);
|
||||
ui->queueCap->setEnabled(false);
|
||||
ui->cycleActiveWindow->setEnabled(false);
|
||||
|
||||
ui->apiStatus->setText(tr("None"));
|
||||
ui->apiIcon->setVisible(false);
|
||||
|
||||
@@ -70,6 +70,7 @@ private slots:
|
||||
void on_captures_itemActivated(QListWidgetItem *item);
|
||||
void on_childProcesses_itemActivated(QListWidgetItem *item);
|
||||
void on_triggerImmediateCapture_clicked();
|
||||
void on_cycleActiveWindow_clicked();
|
||||
void on_triggerDelayedCapture_clicked();
|
||||
void on_queueCap_clicked();
|
||||
void on_previewSplit_splitterMoved(int pos, int index);
|
||||
|
||||
@@ -190,7 +190,14 @@
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="2" column="1">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="triggerImmediateCapture">
|
||||
<property name="text">
|
||||
<string>Capture Frame(s) Immediately</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="captureDelay">
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
@@ -212,7 +219,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="captureFrame">
|
||||
<property name="prefix">
|
||||
<string>Frame </string>
|
||||
@@ -225,14 +232,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="triggerDelayedCapture">
|
||||
<property name="text">
|
||||
<string>Capture After Delay:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="queueCap">
|
||||
<property name="text">
|
||||
<string>Capture Specific Frame(s):</string>
|
||||
@@ -267,7 +274,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -280,10 +287,10 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="triggerImmediateCapture">
|
||||
<item row="6" column="0">
|
||||
<widget class="QPushButton" name="cycleActiveWindow">
|
||||
<property name="text">
|
||||
<string>Capture Frame(s) Immediately</string>
|
||||
<string>Cycle Active Window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -542,6 +542,9 @@ When valid, will be in the range of 0.0 to 1.0 (0 - 100%). If not valid when a c
|
||||
or has finished, it will be -1.0
|
||||
)");
|
||||
float capProgress = -1.0f;
|
||||
|
||||
DOCUMENT("The number of the capturable windows");
|
||||
uint32_t capturableWindowCount = 0;
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_STRUCT(TargetControlMessage);
|
||||
|
||||
@@ -1342,6 +1342,9 @@ The details of the types of messages that can be received are listed under
|
||||
)");
|
||||
virtual TargetControlMessage ReceiveMessage(RENDERDOC_ProgressCallback progress) = 0;
|
||||
|
||||
DOCUMENT("Cycle the currently active window if there are more windows to capture.");
|
||||
virtual void CycleActiveWindow() = 0;
|
||||
|
||||
protected:
|
||||
ITargetControl() = default;
|
||||
~ITargetControl() = default;
|
||||
|
||||
@@ -3143,6 +3143,7 @@ enum class TargetControlMessageType : uint32_t
|
||||
RegisterAPI,
|
||||
NewChild,
|
||||
CaptureProgress,
|
||||
CapturableWindowCount
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_ENUM(TargetControlMessageType);
|
||||
|
||||
+26
-21
@@ -542,27 +542,7 @@ void RenderDoc::Tick()
|
||||
|
||||
if(!prev_focus && cur_focus)
|
||||
{
|
||||
m_Cap = 0;
|
||||
|
||||
// can only shift focus if we have multiple windows
|
||||
if(m_WindowFrameCapturers.size() > 1)
|
||||
{
|
||||
for(auto it = m_WindowFrameCapturers.begin(); it != m_WindowFrameCapturers.end(); ++it)
|
||||
{
|
||||
if(it->first == m_ActiveWindow)
|
||||
{
|
||||
auto nextit = it;
|
||||
++nextit;
|
||||
|
||||
if(nextit != m_WindowFrameCapturers.end())
|
||||
m_ActiveWindow = nextit->first;
|
||||
else
|
||||
m_ActiveWindow = m_WindowFrameCapturers.begin()->first;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CycleActiveWindow();
|
||||
}
|
||||
if(!prev_cap && cur_cap)
|
||||
{
|
||||
@@ -573,6 +553,31 @@ void RenderDoc::Tick()
|
||||
prev_cap = cur_cap;
|
||||
}
|
||||
|
||||
void RenderDoc::CycleActiveWindow()
|
||||
{
|
||||
m_Cap = 0;
|
||||
|
||||
// can only shift focus if we have multiple windows
|
||||
if(m_WindowFrameCapturers.size() > 1)
|
||||
{
|
||||
for(auto it = m_WindowFrameCapturers.begin(); it != m_WindowFrameCapturers.end(); ++it)
|
||||
{
|
||||
if(it->first == m_ActiveWindow)
|
||||
{
|
||||
auto nextit = it;
|
||||
++nextit;
|
||||
|
||||
if(nextit != m_WindowFrameCapturers.end())
|
||||
m_ActiveWindow = nextit->first;
|
||||
else
|
||||
m_ActiveWindow = m_WindowFrameCapturers.begin()->first;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string RenderDoc::GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags)
|
||||
{
|
||||
const bool activeWindow = (flags & eOverlay_ActiveWindow);
|
||||
|
||||
@@ -536,6 +536,8 @@ public:
|
||||
|
||||
string GetOverlayText(RDCDriver driver, uint32_t frameNumber, int flags);
|
||||
|
||||
void CycleActiveWindow();
|
||||
uint32_t GetCapturableWindowCount() { return (uint32_t)m_WindowFrameCapturers.size(); }
|
||||
private:
|
||||
RenderDoc();
|
||||
~RenderDoc();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "os/os_specific.h"
|
||||
#include "serialise/serialiser.h"
|
||||
|
||||
static const uint32_t TargetControlProtocolVersion = 3;
|
||||
static const uint32_t TargetControlProtocolVersion = 4;
|
||||
|
||||
static bool IsProtocolVersionSupported(const uint32_t protocolVersion)
|
||||
{
|
||||
@@ -38,6 +38,10 @@ static bool IsProtocolVersionSupported(const uint32_t protocolVersion)
|
||||
if(protocolVersion == 2)
|
||||
return true;
|
||||
|
||||
// 3 -> 4 added active window cycle and window count packets
|
||||
if(protocolVersion == 3)
|
||||
return true;
|
||||
|
||||
if(protocolVersion == TargetControlProtocolVersion)
|
||||
return true;
|
||||
|
||||
@@ -57,6 +61,8 @@ enum PacketType : uint32_t
|
||||
ePacket_QueueCapture,
|
||||
ePacket_NewChild,
|
||||
ePacket_CaptureProgress,
|
||||
ePacket_CycleActiveWindow,
|
||||
ePacket_CapturableWindowCount
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_ENUM(PacketType);
|
||||
@@ -77,6 +83,8 @@ std::string DoStringise(const PacketType &el)
|
||||
STRINGISE_ENUM_NAMED(ePacket_QueueCapture, "Queue Capture");
|
||||
STRINGISE_ENUM_NAMED(ePacket_NewChild, "New Child");
|
||||
STRINGISE_ENUM_NAMED(ePacket_CaptureProgress, "Capture Progress");
|
||||
STRINGISE_ENUM_NAMED(ePacket_CycleActiveWindow, "Cycle Active Window");
|
||||
STRINGISE_ENUM_NAMED(ePacket_CapturableWindowCount, "Capturable Window Count");
|
||||
}
|
||||
END_ENUM_STRINGISE();
|
||||
}
|
||||
@@ -131,6 +139,7 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli
|
||||
std::vector<pair<uint32_t, uint32_t> > children;
|
||||
std::map<RDCDriver, bool> drivers;
|
||||
float prevCaptureProgress = captureProgress;
|
||||
uint32_t prevWindows = 0;
|
||||
|
||||
while(client)
|
||||
{
|
||||
@@ -148,6 +157,8 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli
|
||||
std::vector<CaptureData> caps = RenderDoc::Inst().GetCaptures();
|
||||
std::vector<pair<uint32_t, uint32_t> > childprocs = RenderDoc::Inst().GetChildProcesses();
|
||||
|
||||
uint32_t curWindows = RenderDoc::Inst().GetCapturableWindowCount();
|
||||
|
||||
if(curdrivers != drivers)
|
||||
{
|
||||
// find the first difference, either a new key or a key with a different value, and send it.
|
||||
@@ -242,6 +253,16 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(version >= 4 && prevWindows != curWindows)
|
||||
{
|
||||
prevWindows = curWindows;
|
||||
|
||||
WRITE_DATA_SCOPE();
|
||||
{
|
||||
SCOPED_SERIALISE_CHUNK(ePacket_CapturableWindowCount);
|
||||
SERIALISE_ELEMENT(curWindows);
|
||||
}
|
||||
}
|
||||
|
||||
if(curtime > pingtime)
|
||||
{
|
||||
@@ -321,6 +342,10 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli
|
||||
RenderDoc::Inst().MarkCaptureRetrieved(id);
|
||||
}
|
||||
}
|
||||
else if(type == ePacket_CycleActiveWindow)
|
||||
{
|
||||
RenderDoc::Inst().CycleActiveWindow();
|
||||
}
|
||||
|
||||
reader.EndChunk();
|
||||
|
||||
@@ -602,6 +627,18 @@ public:
|
||||
SAFE_DELETE(m_Socket);
|
||||
}
|
||||
|
||||
void CycleActiveWindow()
|
||||
{
|
||||
if(m_Version < 4)
|
||||
return;
|
||||
|
||||
WRITE_DATA_SCOPE();
|
||||
SCOPED_SERIALISE_CHUNK(ePacket_CycleActiveWindow);
|
||||
|
||||
if(ser.IsErrored())
|
||||
SAFE_DELETE(m_Socket);
|
||||
}
|
||||
|
||||
TargetControlMessage ReceiveMessage(RENDERDOC_ProgressCallback progress)
|
||||
{
|
||||
TargetControlMessage msg;
|
||||
@@ -778,6 +815,16 @@ public:
|
||||
reader.EndChunk();
|
||||
return msg;
|
||||
}
|
||||
else if(type == ePacket_CapturableWindowCount)
|
||||
{
|
||||
msg.type = TargetControlMessageType::CapturableWindowCount;
|
||||
uint32_t windows = 0;
|
||||
READ_DATA_SCOPE();
|
||||
SERIALISE_ELEMENT(windows);
|
||||
msg.capturableWindowCount = windows;
|
||||
reader.EndChunk();
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
RDCERR("Unexpected packed received: %d", type);
|
||||
|
||||
Reference in New Issue
Block a user