return frame;
}
+/* Invisible window used to get B_SCREEN_CHANGED events. */
+class EmacsScreenChangeMonitor : public BWindow
+{
+ BRect previous_screen_frame;
+
+public:
+ EmacsScreenChangeMonitor (void) : BWindow (BRect (-100, -100, 0, 0), "",
+ B_NO_BORDER_WINDOW_LOOK,
+ B_FLOATING_ALL_WINDOW_FEEL,
+ B_AVOID_FRONT | B_AVOID_FOCUS)
+ {
+ BScreen screen (this);
+
+ if (!screen.IsValid ())
+ return;
+
+ previous_screen_frame = screen.Frame ();
+
+ /* Immediately show this window upon creation. It will end up
+ hidden since there are no windows in its subset. */
+ Show ();
+
+ if (!LockLooper ())
+ return;
+
+ Hide ();
+ UnlockLooper ();
+ }
+
+ void
+ DispatchMessage (BMessage *msg, BHandler *handler)
+ {
+ struct haiku_screen_changed_event rq;
+ BRect frame;
+
+ if (msg->what == B_SCREEN_CHANGED)
+ {
+ if (msg->FindInt64 ("when", &rq.when) != B_OK)
+ rq.when = 0;
+
+ if (msg->FindRect ("frame", &frame) != B_OK
+ || frame != previous_screen_frame)
+ {
+ haiku_write (SCREEN_CHANGED_EVENT, &rq);
+
+ if (frame.IsValid ())
+ previous_screen_frame = frame;
+ }
+ }
+
+ BWindow::DispatchMessage (msg, handler);
+ }
+};
+
class Emacs : public BApplication
{
public:
BMessage settings;
bool settings_valid_p = false;
+ EmacsScreenChangeMonitor *monitor;
- Emacs () : BApplication ("application/x-vnd.GNU-emacs")
+ Emacs (void) : BApplication ("application/x-vnd.GNU-emacs")
{
BPath settings_path;
return;
settings_valid_p = true;
+ monitor = new EmacsScreenChangeMonitor;
+ }
+
+ ~Emacs (void)
+ {
+ if (monitor->LockLooper ())
+ monitor->Quit ();
+ else
+ delete monitor;
}
void
}
else if (msg->what == SEND_MOVE_FRAME_EVENT)
FrameMoved (Frame ().LeftTop ());
+ else if (msg->what == B_SCREEN_CHANGED)
+ {
+ if (fullscreen_mode != FULLSCREEN_MODE_NONE)
+ SetFullscreen (fullscreen_mode);
+
+ BWindow::DispatchMessage (msg, handler);
+ }
else
BWindow::DispatchMessage (msg, handler);
}
{
BRect zoom_rect, frame;
- if (fullscreen_mode == mode)
- return;
-
frame = ClearFullscreen (mode);
switch (mode)
BMessage_delete (b->message);
break;
}
+ case SCREEN_CHANGED_EVENT:
+ {
+ struct haiku_screen_changed_event *b = buf;
+
+ inev.kind = MONITORS_CHANGED_EVENT;
+ XSETTERMINAL (inev.arg, x_display_list->terminal);
+ inev.timestamp = b->when / 1000;
+ break;
+ }
case APP_QUIT_REQUESTED_EVENT:
inev.kind = SAVE_SESSION_EVENT;
inev.arg = Qt;