* dlg.h: Remove "first" field for dialogs and DLG_HAS_MENUBAR.

* dlg.c (dlg_mouse_event): Remove menubar hack.
* screen.c (do_panel_event): Redirect mouse events on the upper
frame to the menubar if it's invisible.
(panel_event): Don't repaint the panel after redirected events.
This commit is contained in:
Pavel Roskin 2003-09-13 05:23:53 +00:00
parent 312972109a
commit 9941a0bb6a
5 changed files with 38 additions and 24 deletions

View File

@ -1,3 +1,11 @@
2003-09-13 Pavel Roskin <proski@gnu.org>
* dlg.h: Remove "first" field for dialogs and DLG_HAS_MENUBAR.
* dlg.c (dlg_mouse_event): Remove menubar hack.
* screen.c (do_panel_event): Redirect mouse events on the upper
frame to the menubar if it's invisible.
(panel_event): Don't repaint the panel after redirected events.
2003-09-12 Pavel Roskin <proski@gnu.org>
* screen.c (panel_event): Make sure that the panel is repainted

View File

@ -255,7 +255,6 @@ add_widget (Dlg_head *h, void *w)
} else {
widget->prev = widget;
widget->next = widget;
h->first = widget;
}
if ((h->flags & DLG_REVERSE) || !h->current)
@ -631,11 +630,6 @@ dlg_mouse_event (Dlg_head * h, Gpm_Event * event)
int x = event->x;
int y = event->y;
/* kludge for the menubar: start at h->first, not current */
/* Must be careful in the insertion order to the dlg list */
if (y == 1 && (h->flags & DLG_HAS_MENUBAR))
starting_widget = h->first;
item = starting_widget;
do {
Widget *widget = item;

View File

@ -86,7 +86,6 @@ typedef struct Dlg_head {
/* Internal variables */
int count; /* Number of widgets */
struct Widget *current; /* Curently active widget */
struct Widget *first; /* First widget added to the dialog */
dlg_cb_fn callback;
void *previous_dialog; /* Pointer to the previously running Dlg_head */
@ -130,10 +129,9 @@ Dlg_head *create_dlg (int y1, int x1, int lines, int cols,
/* The flags: */
#define DLG_WANT_IDLE 64 /* Dialog wants idle events */
#define DLG_REVERSE 32 /* Tab order is opposite to the add order */
#define DLG_WANT_TAB 16 /* Should the tab key be sent to the dialog? */
#define DLG_HAS_MENUBAR 8 /* GrossHack: Send events on row 1 to a menubar? */
#define DLG_WANT_IDLE 8 /* Dialog wants idle events */
#define DLG_COMPACT 4 /* Suppress spaces around the frame */
#define DLG_TRYUP 2 /* Try to move two lines up the dialog */
#define DLG_CENTER 1 /* Center the dialog */

View File

@ -1752,7 +1752,7 @@ do_nc (void)
midnight_dlg =
create_dlg (0, 0, LINES, COLS, midnight_colors, midnight_callback,
"[main]", NULL, DLG_HAS_MENUBAR | DLG_WANT_IDLE);
"[main]", NULL, DLG_WANT_IDLE);
/* Check if we were invoked as an editor or file viewer */
if (mc_maybe_editor_or_viewer ())

View File

@ -33,7 +33,6 @@
#include "color.h"
#include "tree.h"
#include "win.h"
#include "main.h"
#include "ext.h" /* regexp_command */
#include "mouse.h" /* For Gpm_Event */
#include "layout.h" /* Most layout variables are here */
@ -45,6 +44,9 @@
#include "profile.h"
#include "execute.h"
#include "widget.h"
#include "menu.h" /* menubar_visible */
#define WANT_WIDGETS
#include "main.h" /* the_menubar */
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
@ -2259,9 +2261,12 @@ mark_if_marking (WPanel *panel, Gpm_Event *event)
return 0;
}
/* Mouse callback of the panel minus repainting */
/*
* Mouse callback of the panel minus repainting.
* If the event is redirected to the menu, *redir is set to 1.
*/
static int
do_panel_event (Gpm_Event *event, WPanel *panel)
do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
{
const int lines = llines (panel);
@ -2278,29 +2283,36 @@ do_panel_event (Gpm_Event *event, WPanel *panel)
}
/* "<" button */
if (event->type & GPM_DOWN && event->x == 1 + 1 && event->y == 0 + 1) {
if (event->type & GPM_DOWN && event->x == 2 && event->y == 1) {
directory_history_prev (panel);
return MOU_NORMAL;
}
/* ">" button */
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 2 + 1
&& event->y == 0 + 1) {
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 1
&& event->y == 1) {
directory_history_next (panel);
return MOU_NORMAL;
}
/* "v" button */
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 3 + 1
&& event->y == 0 + 1) {
if (event->type & GPM_DOWN && event->x == panel->widget.cols - 2
&& event->y == 1) {
directory_history_list (panel);
return MOU_NORMAL;
}
/* rest of the upper frame, the menu is invisible - call menu */
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) {
*redir = 1;
event->x += panel->widget.x;
return (*(the_menubar->widget.mouse)) (event, the_menubar);
}
event->y -= 2;
if ((event->type & (GPM_DOWN | GPM_DRAG))) {
if (panel != (WPanel *) current_dlg->current)
if (&panel->widget != current_dlg->current)
change_panel ();
if (event->y <= 0) {
@ -2312,9 +2324,8 @@ do_panel_event (Gpm_Event *event, WPanel *panel)
return MOU_REPEAT;
}
if (!
((panel->top_file + event->y <= panel->count)
&& event->y <= lines)) {
if (!((panel->top_file + event->y <= panel->count)
&& event->y <= lines)) {
mark_if_marking (panel, event);
if (mouse_move_pages)
next_page (panel);
@ -2353,9 +2364,12 @@ static int
panel_event (Gpm_Event *event, WPanel *panel)
{
int ret;
int redir = 0;
ret = do_panel_event (event, panel, &redir);
if (!redir)
panel_update_contents (panel);
ret = do_panel_event (event, panel);
panel_update_contents (panel);
return ret;
}