I use Scintilla within a Windows dialog.
If I now use multiple views within the dialog,
then there is increased CPU utilization due to SC_WIN_IDLE messages.
Here is an example setup for illustration
The DIAGNOSTICS dialog has the following methods, among others
```Rust
...
pub fn create_doc(&self) -> isize {
self.editor.call(SCI_CREATEDOCUMENT, 0, 0)
}
pub fn release_doc(&self, doc: isize) {
self.editor.call(SCI_RELEASEDOCUMENT, 0, doc);
}
pub fn switch_doc(& mut self, new_doc: isize) {
if new_doc != self.current_doc {
let current_doc = self.editor.call(SCI_GETDOCPOINTER, 0, 0);
self.editor.call(SCI_ADDREFDOCUMENT, 0, current_doc);
self.editor.call(SCI_SETDOCPOINTER, 0, new_doc);
self.editor.call(SCI_SETTABWIDTH, 2, 0);
self.current_doc = new_doc;
}
}
...
```other code calls it
```Rust
if self.diagnostic_view == -1 {
self.diagnostic_view = DIAGNOSTICS.create_doc();
}
DIAGNOSTICS.switch_doc(self.diagnostic_view);
```If this Scintilla control now receives text,
it results in a large number of SC_WIN_IDLE (5001) messages being received,
which leads to increased CPU utilization.
procid dialog timestamp ms
[16816] diagnostics 1737838727402 HWND(0xd0866) 5001 WPARAM(2273467515) LPARAM(0)
[16816] diagnostics 1737838727409 HWND(0xd0866) 5001 WPARAM(2273467515) LPARAM(0)
[16816] diagnostics 1737838727417 HWND(0xd0866) 5001 WPARAM(2273467515) LPARAM(0)
[16816] diagnostics 1737838727420 HWND(0xd0866) 5001 WPARAM(2273467515) LPARAM(0)
[16816] diagnostics 1737838727422 HWND(0xd0866) 5001 WPARAM(2273467515) LPARAM(0)
...which only subsides again when the document no longer contains any text.
My subclassing code
```Rust
extern "system" fn subclassed_scintilla_proc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM, _uid_subclass: usize, _dw_ref_data: usize) -> LRESULT {
use std::time::{SystemTime, UNIX_EPOCH};
if let Ok(n) = SystemTime::now().duration_since(UNIX_EPOCH) {
plugin_utils::helper::output_debug_string(&format!("diagnostics {:>14?} {hwnd:?} {msg} {wparam:?} {lparam:?} \n", n.as_millis()));
}
if msg == WM_GETDLGCODE {
return LRESULT((DLGC_WANTARROWS | DLGC_WANTCHARS) as isize);
}
unsafe { DefSubclassProc(hwnd, msg, wparam, lparam) }
}
```Btw. even if I do not subclass the Scintilla control, the CPU load is increased.
Am I missing something here?
Thx
Eren