mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Call menu using mouse for all panel types.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
aa601f831b
commit
15354fdbb4
33
src/info.c
33
src/info.c
@ -25,21 +25,25 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/tty/key.h" /* is_idle() */
|
||||
#include "../src/tty/mouse.h" /* Gpm_Event */
|
||||
#include "../src/tty/color.h"
|
||||
|
||||
#include "dialog.h"
|
||||
#include "widget.h" /* default_proc*/
|
||||
#include "info.h"
|
||||
#include "main-widgets.h" /* the_menubar*/
|
||||
#include "dir.h" /* required by panel */
|
||||
#include "panel.h" /* for the panel structure */
|
||||
#include "main.h" /* other_panel, current_panel definitions */
|
||||
#include "menu.h" /* menubar_visible */
|
||||
#include "util.h" /* size_trunc_len */
|
||||
#include "layout.h"
|
||||
#include "../src/tty/key.h" /* is_idle() */
|
||||
#include "mountlist.h"
|
||||
#include "unixcompat.h"
|
||||
#include "strutil.h"
|
||||
#include "info.h"
|
||||
|
||||
#ifndef VERSION
|
||||
# define VERSION "undefined"
|
||||
@ -51,7 +55,7 @@ struct WInfo {
|
||||
};
|
||||
|
||||
/* Have we called the init_my_statfs routine? */
|
||||
static int initialized;
|
||||
static gboolean initialized = FALSE;
|
||||
static struct my_statfs myfs_stats;
|
||||
|
||||
static void info_box (Dlg_head *h, struct WInfo *info)
|
||||
@ -266,17 +270,32 @@ info_callback (Widget *w, widget_msg_t msg, int parm)
|
||||
}
|
||||
}
|
||||
|
||||
struct WInfo *info_new ()
|
||||
static int
|
||||
info_event (Gpm_Event *event, void *data)
|
||||
{
|
||||
Widget *w = &((WInfo *) data)->widget;
|
||||
|
||||
/* rest of the upper frame, the menu is invisible - call menu */
|
||||
if (event->type & GPM_DOWN && event->y == 1 && !menubar_visible) {
|
||||
event->x += w->x;
|
||||
return the_menubar->widget.mouse (event, the_menubar);
|
||||
}
|
||||
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
WInfo *
|
||||
info_new (void)
|
||||
{
|
||||
struct WInfo *info = g_new (struct WInfo, 1);
|
||||
|
||||
init_widget (&info->widget, 0, 0, 0, 0, info_callback, NULL);
|
||||
init_widget (&info->widget, 0, 0, 0, 0, info_callback, info_event);
|
||||
|
||||
/* We do not want the cursor */
|
||||
widget_want_cursor (info->widget, 0);
|
||||
|
||||
if (!initialized){
|
||||
initialized = 1;
|
||||
if (!initialized) {
|
||||
initialized = TRUE;
|
||||
init_my_statfs ();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#define MC_INFO_H
|
||||
|
||||
struct WInfo;
|
||||
struct WInfo *info_new (void);
|
||||
typedef struct WInfo WInfo;
|
||||
|
||||
WInfo *info_new (void);
|
||||
|
||||
#endif
|
||||
|
43
src/screen.c
43
src/screen.c
@ -2520,20 +2520,11 @@ do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
|
||||
|
||||
int my_index;
|
||||
|
||||
/* Mouse wheel events */
|
||||
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
|
||||
if (panel->top_file > 0)
|
||||
prev_page (panel);
|
||||
else /* We are in first page */
|
||||
move_up (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
|
||||
if (panel->top_file + ITEMS (panel) < panel->count)
|
||||
next_page (panel);
|
||||
else /* We are in last page */
|
||||
move_down (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);
|
||||
}
|
||||
|
||||
/* "<" button */
|
||||
@ -2556,16 +2547,24 @@ do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
|
||||
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);
|
||||
/* Mouse wheel events */
|
||||
if ((event->buttons & GPM_B_UP) && (event->type & GPM_DOWN)) {
|
||||
if (panel->top_file > 0)
|
||||
prev_page (panel);
|
||||
else /* We are in first page */
|
||||
move_up (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
if ((event->buttons & GPM_B_DOWN) && (event->type & GPM_DOWN)) {
|
||||
if (panel->top_file + ITEMS (panel) < panel->count)
|
||||
next_page (panel);
|
||||
else /* We are in last page */
|
||||
move_down (panel);
|
||||
return MOU_NORMAL;
|
||||
}
|
||||
|
||||
event->y -= 2;
|
||||
if ((event->type & (GPM_DOWN | GPM_DRAG))) {
|
||||
|
||||
if (!dlg_widget_active (panel))
|
||||
change_panel ();
|
||||
|
||||
@ -2587,6 +2586,7 @@ do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
|
||||
move_down (panel);
|
||||
return MOU_REPEAT;
|
||||
}
|
||||
|
||||
my_index = panel->top_file + event->y - 1;
|
||||
if (panel->split) {
|
||||
if (event->x > ((panel->widget.cols - 2) / 2))
|
||||
@ -2604,7 +2604,6 @@ do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
|
||||
|
||||
/* This one is new */
|
||||
mark_if_marking (panel, event);
|
||||
|
||||
} else if ((event->type & (GPM_UP | GPM_DOUBLE)) ==
|
||||
(GPM_UP | GPM_DOUBLE)) {
|
||||
if (event->y > 0 && event->y <= lines)
|
||||
@ -2619,7 +2618,7 @@ panel_event (Gpm_Event *event, void *data)
|
||||
{
|
||||
WPanel *panel = data;
|
||||
int ret;
|
||||
int redir = 0;
|
||||
int redir = MOU_NORMAL;
|
||||
|
||||
ret = do_panel_event (event, panel, &redir);
|
||||
if (!redir)
|
||||
|
13
src/tree.c
13
src/tree.c
@ -51,13 +51,15 @@
|
||||
#include "widget.h"
|
||||
#include "panel.h"
|
||||
#include "main.h"
|
||||
#include "file.h" /* For copy_dir_dir(), move_dir_dir(), erase_dir() */
|
||||
#include "main-widgets.h" /* the_menubar */
|
||||
#include "menu.h" /* menubar_visible */
|
||||
#include "file.h" /* copy_dir_dir(), move_dir_dir(), erase_dir() */
|
||||
#include "help.h"
|
||||
#include "tree.h"
|
||||
#include "treestore.h"
|
||||
#include "cmd.h"
|
||||
#include "history.h"
|
||||
#include "strutil.h"
|
||||
#include "tree.h"
|
||||
|
||||
#define tlines(t) (t->is_panel ? t->widget.lines-2 - (show_mini_info ? 2 : 0) : t->widget.lines)
|
||||
|
||||
@ -496,6 +498,13 @@ event_callback (Gpm_Event *event, void *data)
|
||||
{
|
||||
WTree *tree = data;
|
||||
|
||||
/* rest of the upper frame, the menu is invisible - call menu */
|
||||
if (tree->is_panel && (event->type & GPM_DOWN)
|
||||
&& event->y == 1 && !menubar_visible) {
|
||||
event->x += tree->widget.x;
|
||||
return the_menubar->widget.mouse (event, the_menubar);
|
||||
}
|
||||
|
||||
if (!(event->type & GPM_UP))
|
||||
return MOU_NORMAL;
|
||||
|
||||
|
@ -40,10 +40,15 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "../src/tty/tty.h"
|
||||
|
||||
#include "../src/strutil.h"
|
||||
#include "../src/main.h"
|
||||
#include "../src/charsets.h"
|
||||
#include "../src/tty/tty.h"
|
||||
#include "../src/main-widgets.h" /* the_menubar */
|
||||
#include "../src/menu.h" /* menubar_visible */
|
||||
|
||||
#include "internal.h"
|
||||
#include "mcviewer.h"
|
||||
|
||||
@ -80,12 +85,20 @@ int mcview_mouse_move_pages = 1;
|
||||
|
||||
/* Both views */
|
||||
static int
|
||||
mcview_event (mcview_t * view, Gpm_Event * event, int *result)
|
||||
mcview_event (mcview_t *view, Gpm_Event *event, int *result)
|
||||
{
|
||||
screen_dimen y, x;
|
||||
|
||||
*result = MOU_NORMAL;
|
||||
|
||||
/* rest of the upper frame, the menu is invisible - call menu */
|
||||
if (mcview_is_in_panel (view) && (event->type & GPM_DOWN)
|
||||
&& event->y == 1 && !menubar_visible) {
|
||||
event->x += view->widget.x;
|
||||
*result = the_menubar->widget.mouse (event, the_menubar);
|
||||
return 0; /* don't draw viewer over menu */
|
||||
}
|
||||
|
||||
/* We are not interested in the release events */
|
||||
if (!(event->type & (GPM_DOWN | GPM_DRAG)))
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user